org.apache.axis
Class MessageContext

java.lang.Object
  |
  +--org.apache.axis.MessageContext

public class MessageContext
extends java.lang.Object

Some more general docs will go here. This class also contains constants for accessing some well-known properties. Using a hierarchical namespace is strongly suggested in order to lower the chance for conflicts. (These constants should be viewed as an explicit list of well known and widely used context keys, there's nothing wrong with directly using the key strings. This is the reason for the hierarchical constant namespace. Actually I think we might just list the keys in the docs and provide no such constants since they create yet another namespace, but we'd have no compile-time checks then. Whaddya think? - todo by Jacek)

Author:
Doug Davis (dug@us.ibm.com), Jacek Kopecky (jacek@idoox.com)

Field Summary
static java.lang.String ATTACHMENTS_DIR
          The directory where in coming attachments are created.
static java.lang.String AUTHUSER
          Place to store an AuthenticatedUser
static java.lang.String CALL
          If on the client - this is the Call object
static java.lang.String ENGINE_HANDLER
          Contains an instance of Handler, which is the ServiceContext and the entrypoint of this service.
protected static org.apache.commons.logging.Log log
           
static java.lang.String QUIT_REQUESTED
          Has a quit been requested? Hackish...
protected static java.lang.String systemTempDir
           
static java.lang.String TRANS_URL
          This String is the URL that the message came to
 
Constructor Summary
MessageContext(AxisEngine engine)
           
 
Method Summary
 void clearProperty(java.lang.String propName)
           
 AxisEngine getAxisEngine()
           
 java.lang.ClassLoader getClassLoader()
           
static MessageContext getCurrentContext()
          Get the active message context.
 Message getCurrentMessage()
          Return the current (i.e.
 java.lang.String getEncodingStyle()
          Returns the encoding style as a URI that should be used for the SOAP message.
 boolean getMaintainSession()
          Are we maintaining session state?
 OperationDesc getOperation()
           
 OperationDesc getOperationByQName(QName qname)
           
 int getOperationStyle()
          Get the operation style.
 java.lang.String getPassword()
          Get the password
 boolean getPastPivot()
          Determine when we've passed the pivot
 OperationDesc[] getPossibleOperationsByQName(QName qname)
           
 java.lang.Object getProperty(java.lang.String name)
          Returns the value associated with the named property - or null if not defined/set.
 Message getRequestMessage()
          Get the request message.
 Message getResponseMessage()
          Get the response message.
 SOAPService getService()
           
 Session getSession()
          Sessions
 java.lang.String getSOAPActionURI()
          Get the soapAction URI.
 SOAPConstants getSOAPConstants()
          SOAP constants
 java.lang.String getStrProp(java.lang.String propName)
          Just a util so we don't have to cast the result
static java.lang.String getStyleFromInt(int style)
          Utility function to return a string representation of a style constant.
static int getStyleFromString(java.lang.String operationStyle)
          Utility function to convert string to operation style constants
 java.lang.String getTargetService()
           
 int getTimeout()
          Get timeout from our MessageContext.
 java.lang.String getTransportName()
          Transport
 TypeMapping getTypeMapping()
          Return the type mapping currently in scope for our encoding style
 TypeMappingRegistry getTypeMappingRegistry()
          Get the currently in-scope type mapping registry.
 java.lang.String getUsername()
          Get the user name
 boolean isClient()
          Let us know whether this is the client or the server.
 boolean isEncoded()
          Encoding
 boolean isPropertyTrue(java.lang.String propName)
          Tests to see if the named property is set in the 'bag'.
 boolean isPropertyTrue(java.lang.String propName, boolean defaultVal)
          Tests to see if the named property is set in the 'bag'.
 void reset()
           
 void setClassLoader(java.lang.ClassLoader cl)
           
 void setCurrentMessage(Message curMsg)
          Set the current (i.e.
 void setEncodingStyle(java.lang.String namespaceURI)
          Sets the encoding style to the URL passed in.
 void setMaintainSession(boolean yesno)
          Set whether we are maintaining session state
 void setOperation(OperationDesc operation)
           
 void setOperationStyle(int operationStyle)
          Set the operation style.
 void setPassword(java.lang.String password)
          Set the password.
 void setPastPivot(boolean pastPivot)
          Indicate when we've passed the pivot
 void setProperty(java.lang.String name, java.lang.Object value)
          Allows you to set a named property to the passed in value.
 void setPropertyParent(java.util.Hashtable parent)
           
 void setRequestMessage(Message reqMsg)
          Set the request message, and make sure that message is associated with this MessageContext.
 void setResponseMessage(Message respMsg)
          Set the response message, and make sure that message is associated with this MessageContext.
 void setService(SOAPService sh)
           
 void setSession(Session session)
           
 void setSOAPActionURI(java.lang.String SOAPActionURI)
          Set the soapAction URI.
 void setSOAPConstants(SOAPConstants soapConstants)
           
 void setTargetService(java.lang.String tServ)
          Set the target service for this message.
 void setTimeout(int value)
          Set timeout in our MessageContext.
 void setTransportName(java.lang.String transportName)
           
 void setTypeMappingRegistry(TypeMappingRegistry reg)
           
 void setUsername(java.lang.String username)
          Set the username.
 void setUseSOAPAction(boolean useSOAPAction)
          Should soapAction be used?
 boolean useSOAPAction()
          Are we using soapAction?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log

systemTempDir

protected static java.lang.String systemTempDir

ENGINE_HANDLER

public static java.lang.String ENGINE_HANDLER
Contains an instance of Handler, which is the ServiceContext and the entrypoint of this service. (if it has been so configured - will our deployment tool do this by default? - todo by Jacek)

TRANS_URL

public static java.lang.String TRANS_URL
This String is the URL that the message came to

QUIT_REQUESTED

public static java.lang.String QUIT_REQUESTED
Has a quit been requested? Hackish... but useful... -- RobJ

AUTHUSER

public static java.lang.String AUTHUSER
Place to store an AuthenticatedUser

CALL

public static java.lang.String CALL
If on the client - this is the Call object

ATTACHMENTS_DIR

public static java.lang.String ATTACHMENTS_DIR
The directory where in coming attachments are created.
Constructor Detail

MessageContext

public MessageContext(AxisEngine engine)
Method Detail

getOperation

public OperationDesc getOperation()

setOperation

public void setOperation(OperationDesc operation)

getPossibleOperationsByQName

public OperationDesc[] getPossibleOperationsByQName(QName qname)

getOperationByQName

public OperationDesc getOperationByQName(QName qname)

getCurrentContext

public static MessageContext getCurrentContext()
Get the active message context.
Returns:
the current active message context

setTypeMappingRegistry

public void setTypeMappingRegistry(TypeMappingRegistry reg)

getTypeMappingRegistry

public TypeMappingRegistry getTypeMappingRegistry()
Get the currently in-scope type mapping registry. By default, will return a reference to the AxisEngine's TMR until someone sets our local one (usually as a result of setting the serviceHandler).
Returns:
the type mapping registry to use for this request.

getTypeMapping

public TypeMapping getTypeMapping()
Return the type mapping currently in scope for our encoding style

getTransportName

public java.lang.String getTransportName()
Transport

setTransportName

public void setTransportName(java.lang.String transportName)

getSOAPConstants

public SOAPConstants getSOAPConstants()
SOAP constants

setSOAPConstants

public void setSOAPConstants(SOAPConstants soapConstants)

getSession

public Session getSession()
Sessions

setSession

public void setSession(Session session)

isEncoded

public boolean isEncoded()
Encoding

setMaintainSession

public void setMaintainSession(boolean yesno)
Set whether we are maintaining session state

getMaintainSession

public boolean getMaintainSession()
Are we maintaining session state?

getRequestMessage

public Message getRequestMessage()
Get the request message.
Returns:
the request message (may be null).

setRequestMessage

public void setRequestMessage(Message reqMsg)
Set the request message, and make sure that message is associated with this MessageContext.
Parameters:
reqMsg - the new request Message.

getResponseMessage

public Message getResponseMessage()
Get the response message.
Returns:
the response message (may be null).

setResponseMessage

public void setResponseMessage(Message respMsg)
Set the response message, and make sure that message is associated with this MessageContext.
Parameters:
respMsg - the new response Message.

getCurrentMessage

public Message getCurrentMessage()
Return the current (i.e. request before the pivot, response after) message.

setCurrentMessage

public void setCurrentMessage(Message curMsg)
Set the current (i.e. request before the pivot, response after) message.

getPastPivot

public boolean getPastPivot()
Determine when we've passed the pivot

setPastPivot

public void setPastPivot(boolean pastPivot)
Indicate when we've passed the pivot

setTimeout

public void setTimeout(int value)
Set timeout in our MessageContext.
Parameters:
value - the maximum amount of time, in milliseconds

getTimeout

public int getTimeout()
Get timeout from our MessageContext.
Returns:
value the maximum amount of time, in milliseconds

getClassLoader

public java.lang.ClassLoader getClassLoader()

setClassLoader

public void setClassLoader(java.lang.ClassLoader cl)

getTargetService

public java.lang.String getTargetService()

getAxisEngine

public AxisEngine getAxisEngine()

setTargetService

public void setTargetService(java.lang.String tServ)
                      throws AxisFault
Set the target service for this message. This looks up the named service in the registry, and has the side effect of setting our TypeMappingRegistry to the service's.
Parameters:
tServ - the name of the target service.

getService

public SOAPService getService()

setService

public void setService(SOAPService sh)

isClient

public boolean isClient()
Let us know whether this is the client or the server.

getStrProp

public java.lang.String getStrProp(java.lang.String propName)
Just a util so we don't have to cast the result

isPropertyTrue

public boolean isPropertyTrue(java.lang.String propName)
Tests to see if the named property is set in the 'bag'. If not there then 'false' is returned. If there, then... if its a Boolean, we'll return booleanValue() if its an Integer, we'll return 'false' if its '0' else 'true' if its a String, we'll return 'false' if its 'false' or '0' else 'true' All other types return 'true'

isPropertyTrue

public boolean isPropertyTrue(java.lang.String propName,
                              boolean defaultVal)
Tests to see if the named property is set in the 'bag'. If not there then 'defaultVal' will be returned. If there, then... if its a Boolean, we'll return booleanValue() if its an Integer, we'll return 'false' if its '0' else 'true' if its a String, we'll return 'false' if its 'false' or '0' else 'true' All other types return 'true'

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Allows you to set a named property to the passed in value. There are a few known properties (like username, password, etc) that are variables in Call. The rest of the properties are stored in a Hashtable. These common properties should be accessed via the accessors for speed/type safety, but they may still be obtained via this method. It's up to one of the Handlers (or the Axis engine itself) to go looking for one of them.
Parameters:
name - Name of the property
value - Value of the property

getProperty

public java.lang.Object getProperty(java.lang.String name)
Returns the value associated with the named property - or null if not defined/set.
Returns:
Object value of the property - or null

setPropertyParent

public void setPropertyParent(java.util.Hashtable parent)

setUsername

public void setUsername(java.lang.String username)
Set the username.

getUsername

public java.lang.String getUsername()
Get the user name

setPassword

public void setPassword(java.lang.String password)
Set the password.

getPassword

public java.lang.String getPassword()
Get the password

setOperationStyle

public void setOperationStyle(int operationStyle)
Set the operation style.

getOperationStyle

public int getOperationStyle()
Get the operation style.

setUseSOAPAction

public void setUseSOAPAction(boolean useSOAPAction)
Should soapAction be used?

useSOAPAction

public boolean useSOAPAction()
Are we using soapAction?

setSOAPActionURI

public void setSOAPActionURI(java.lang.String SOAPActionURI)
                      throws java.lang.IllegalArgumentException
Set the soapAction URI.

getSOAPActionURI

public java.lang.String getSOAPActionURI()
Get the soapAction URI.

setEncodingStyle

public void setEncodingStyle(java.lang.String namespaceURI)
Sets the encoding style to the URL passed in.
Parameters:
namespaceURI - URI of the encoding to use.

getEncodingStyle

public java.lang.String getEncodingStyle()
Returns the encoding style as a URI that should be used for the SOAP message.
Returns:
String URI of the encoding style to use

clearProperty

public void clearProperty(java.lang.String propName)

reset

public void reset()

getStyleFromString

public static int getStyleFromString(java.lang.String operationStyle)
Utility function to convert string to operation style constants
Parameters:
operationStyle - "rpc", "document", or "wrapped"
Returns:
either STYLE_RPC, STYLE_DOCUMENT or STYLE_WRAPPED (all defined in org.apache.axis.description.ServiceDesc)

getStyleFromInt

public static java.lang.String getStyleFromInt(int style)
Utility function to return a string representation of a style constant.


Copyright © 2001 Apache XML Project. All Rights Reserved.