Package org.apache.axis
Class MessageContext
- java.lang.Object
-
- org.apache.axis.MessageContext
-
- All Implemented Interfaces:
MessageContext,SOAPMessageContext
public class MessageContext extends java.lang.Object implements SOAPMessageContext
A MessageContext is the Axis implementation of the javax SOAPMessageContext class, and is core to message processing in handlers and other parts of the system. 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
Fields Modifier and Type Field Description static java.lang.StringACCEPTMISSINGPARAMSA boolean param, to control whether we accept missing parameters as nulls or refuse to acknowledge them.static java.lang.StringATTACHMENTS_DIRThe directory where in coming attachments are created.static java.lang.StringAUTHUSERPlace to store an AuthenticatedUser.static java.lang.StringCALLIf on the client - this is the Call object.static java.lang.StringENGINE_HANDLERContains an instance of Handler, which is the ServiceContext and the entrypoint of this service.static java.lang.StringHTTP_TRANSPORT_VERSIONThe value of the property is used by service WSDL generation (aka ?WSDL).static java.lang.StringIS_MSGAre we doing Msg vs RPC? - For Java Binding.protected static org.apache.commons.logging.LoglogTheLogused for logging all messages.static java.lang.StringQUIT_REQUESTEDHas a quit been requested? Hackish...static java.lang.StringSECURITY_PROVIDERThe security provider.protected static java.lang.StringsystemTempDirTemporary directory to store attachments.static java.lang.StringTRANS_URLThis String is the URL that the message came to.static java.lang.StringWSDLGEN_INTFNAMESPACEThe value of the property is used by service WSDL generation (aka ?WSDL) For the service's interface namespace if not set TRANS_URL property is used.static java.lang.StringWSDLGEN_SERV_LOC_URLThe value of the property is used by service WSDL generation (aka ?WSDL).
-
Constructor Summary
Constructors Constructor Description MessageContext(AxisEngine engine)Create a message context.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsProperty(java.lang.String name)Returns true if the MessageContext contains a property with the specified name.voiddispose()if a message (or subclass) has any disposal needs, this method is where it goes.protected voidfinalize()during finalization, the dispose() method is called.java.util.IteratorgetAllPropertyNames()Returns an Iterator view of the names of the properties in this MessageContext and any parents of the LockableHashtableAxisEnginegetAxisEngine()Get the axis engine.java.lang.ClassLoadergetClassLoader()Get the classloader, implicitly binding to the thread context classloader if an override has not been supplied.static MessageContextgetCurrentContext()Get the active message context.MessagegetCurrentMessage()Return the current (i.e.java.lang.StringgetEncodingStyle()Returns the encoding style as a URI that should be used for the SOAP message.booleangetMaintainSession()Discover if we are maintaining session state.SOAPMessagegetMessage()Gets the SOAPMessage from this message context.OperationDescgetOperation()The current operation.OperationDescgetOperationByQName(QName qname)get the first possible operation that could match a body containing an element of the given QName.StylegetOperationStyle()Get the operation style.UsegetOperationUse()Get the operation use.java.lang.StringgetPassword()Get the password.booleangetPastPivot()Determine when we've passed the pivot.OperationDesc[]getPossibleOperationsByQName(QName qname)Returns a list of operation descriptors that could may possibly match a body containing an element of the given QName.java.lang.ObjectgetProperty(java.lang.String name)Returns the value associated with the named property - or null if not defined/set.java.util.IteratorgetPropertyNames()Returns anIteratorview of the names of the properties in thisMessageContext.MessagegetRequestMessage()Get the request message.MessagegetResponseMessage()Get the response message.java.lang.String[]getRoles()Gets the SOAP actor roles associated with an execution of theHandlerChainand its containedHandlerinstances.SchemaVersiongetSchemaVersion()Get the XML schema version information.SOAPServicegetService()Get theSOAPServiceused to handle services in this context.SessiongetSession()Get the current session.java.lang.StringgetSOAPActionURI()Get the soapAction URI.SOAPConstantsgetSOAPConstants()Get theSOAPConstantsused by this message context.java.lang.StringgetStrProp(java.lang.String propName)Get aStringproperty by name.java.lang.StringgetTargetService()Get the name of the targed service for this message.intgetTimeout()Get timeout from our MessageContext.java.lang.StringgetTransportName()The name of the transport for this context.TypeMappinggetTypeMapping()Return the type mapping currently in scope for our encoding style.TypeMappingRegistrygetTypeMappingRegistry()Get the currently in-scope type mapping registry.java.lang.StringgetUsername()Get the user name.booleanisClient()Let us know whether this is the client or the server.booleanisEncoded()Indicates if the opration is encoded.booleanisHighFidelity()Read the high fidelity property.booleanisPropertyTrue(java.lang.String propName)Tests to see if the named property is set in the 'bag', returningfalseif it is not present at all.booleanisPropertyTrue(java.lang.String propName, boolean defaultVal)Test if a property is set to something we consider to be true in the 'bag'.voidremoveProperty(java.lang.String propName)Removes a property (name-value pair) from theMessageContext.voidreset()Return this context to a clean state.voidsetClassLoader(java.lang.ClassLoader cl)Set a new classloader.voidsetCurrentMessage(Message curMsg)Set the current message.voidsetEncodingStyle(java.lang.String namespaceURI)Sets the encoding style to the URI passed in.voidsetHighFidelity(boolean highFidelity)Set the high fidelity propert.voidsetMaintainSession(boolean yesno)Set whether we are maintaining session state.voidsetMessage(SOAPMessage message)Sets the SOAPMessage for this message context.voidsetOperation(OperationDesc operation)Set the current operation.voidsetPassword(java.lang.String password)Set the password.voidsetPastPivot(boolean pastPivot)Indicate when we've passed the pivot.voidsetProperty(java.lang.String name, java.lang.Object value)Allows you to set a named property to the passed in value.voidsetPropertyParent(java.util.Hashtable parent)Set the Hashtable that contains the default values for our properties.voidsetRequestMessage(Message reqMsg)Set the request message, and make sure that message is associated with this MessageContext.voidsetResponseMessage(Message respMsg)Set the response message, and make sure that message is associated with this MessageContext.voidsetRoles(java.lang.String[] roles)Set the SOAP actor roles associated with an executioni ofCodeHandlerChainand its containedHandlerinstances.voidsetSchemaVersion(SchemaVersion schemaVersion)Set the XML schema version this message context will use.voidsetService(SOAPService sh)Set theSOAPServiceused to handle services in this context.voidsetSession(Session session)Set the current session.voidsetSOAPActionURI(java.lang.String SOAPActionURI)Set the soapAction URI.voidsetSOAPConstants(SOAPConstants soapConstants)Set theSOAPConstantsused by this message context.voidsetTargetService(java.lang.String tServ)Set the target service for this message.voidsetTimeout(int value)Set timeout in our MessageContext.voidsetTransportName(java.lang.String transportName)Set the transport name for this context.voidsetTypeMappingRegistry(TypeMappingRegistry reg)Replace the engine's type mapping registry with a local one.voidsetUsername(java.lang.String username)Set the username.voidsetUseSOAPAction(boolean useSOAPAction)Enable or dissable the use of soap action information.booleanuseSOAPAction()Indicates wether the soap action URI is being used or not.
-
-
-
Field Detail
-
log
protected static org.apache.commons.logging.Log log
TheLogused for logging all messages.
-
systemTempDir
protected static java.lang.String systemTempDir
Temporary directory to store attachments.
-
ENGINE_HANDLER
public static final 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)- See Also:
- Constant Field Values
-
TRANS_URL
public static final java.lang.String TRANS_URL
This String is the URL that the message came to.- See Also:
- Constant Field Values
-
QUIT_REQUESTED
public static final java.lang.String QUIT_REQUESTED
Has a quit been requested? Hackish... but useful... -- RobJ- See Also:
- Constant Field Values
-
AUTHUSER
public static final java.lang.String AUTHUSER
Place to store an AuthenticatedUser.- See Also:
- Constant Field Values
-
CALL
public static final java.lang.String CALL
If on the client - this is the Call object.- See Also:
- Constant Field Values
-
IS_MSG
public static final java.lang.String IS_MSG
Are we doing Msg vs RPC? - For Java Binding.- See Also:
- Constant Field Values
-
ATTACHMENTS_DIR
public static final java.lang.String ATTACHMENTS_DIR
The directory where in coming attachments are created.- See Also:
- Constant Field Values
-
ACCEPTMISSINGPARAMS
public static final java.lang.String ACCEPTMISSINGPARAMS
A boolean param, to control whether we accept missing parameters as nulls or refuse to acknowledge them.- See Also:
- Constant Field Values
-
WSDLGEN_INTFNAMESPACE
public static final java.lang.String WSDLGEN_INTFNAMESPACE
The value of the property is used by service WSDL generation (aka ?WSDL) For the service's interface namespace if not set TRANS_URL property is used.- See Also:
- Constant Field Values
-
WSDLGEN_SERV_LOC_URL
public static final java.lang.String WSDLGEN_SERV_LOC_URL
The value of the property is used by service WSDL generation (aka ?WSDL). For the service's location if not set TRANS_URL property is used. (helps provide support through proxies.- See Also:
- Constant Field Values
-
HTTP_TRANSPORT_VERSION
public static final java.lang.String HTTP_TRANSPORT_VERSION
The value of the property is used by service WSDL generation (aka ?WSDL). Set this property to request a certain level of HTTP. The values MUST use org.apache.axis.transport.http.HTTPConstants.HEADER_PROTOCOL_10 for HTTP 1.0 The values MUST use org.apache.axis.transport.http.HTTPConstants.HEADER_PROTOCOL_11 for HTTP 1.1- See Also:
- Constant Field Values
-
SECURITY_PROVIDER
public static final java.lang.String SECURITY_PROVIDER
The security provider.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MessageContext
public MessageContext(AxisEngine engine)
Create a message context.- Parameters:
engine- the controlling axis engine. Null is actually accepted here, though passing a null engine in is strongly discouraged as many of the methods assume that it is in fact defined.
-
-
Method Detail
-
getOperation
public OperationDesc getOperation()
The current operation.- Returns:
- the current operation; may be
null
-
setOperation
public void setOperation(OperationDesc operation)
Set the current operation.- Parameters:
operation- theOperationthis context is executing
-
getPossibleOperationsByQName
public OperationDesc[] getPossibleOperationsByQName(QName qname) throws AxisFault
Returns a list of operation descriptors that could may possibly match a body containing an element of the given QName. For non-DOCUMENT, the list of operation descriptors that match the name is returned. For DOCUMENT, all the operations that have qname as a parameter are returned- Parameters:
qname- of the first element in the body- Returns:
- list of operation descriptions
- Throws:
AxisFault- if the operation names could not be looked up
-
getOperationByQName
public OperationDesc getOperationByQName(QName qname) throws AxisFault
get the first possible operation that could match a body containing an element of the given QName. Sets the currentOperation field in the process; if that field is already set then its value is returned instead- Parameters:
qname- name of the message body- Returns:
- an operation or null
- Throws:
AxisFault
-
getCurrentContext
public static MessageContext getCurrentContext()
Get the active message context.- Returns:
- the current active message context
-
finalize
protected void finalize()
during finalization, the dispose() method is called.- Overrides:
finalizein classjava.lang.Object- See Also:
dispose()
-
setTypeMappingRegistry
public void setTypeMappingRegistry(TypeMappingRegistry reg)
Replace the engine's type mapping registry with a local one. This will have no effect on any type mappings obtained before this call.- Parameters:
reg- the newTypeMappingRegistry
-
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.- Returns:
- the type mapping
-
getTransportName
public java.lang.String getTransportName()
The name of the transport for this context.- Returns:
- the transport name
-
setTransportName
public void setTransportName(java.lang.String transportName)
Set the transport name for this context.- Parameters:
transportName- the name of the transport
-
getSOAPConstants
public SOAPConstants getSOAPConstants()
Get theSOAPConstantsused by this message context.- Returns:
- the soap constants
-
setSOAPConstants
public void setSOAPConstants(SOAPConstants soapConstants)
Set theSOAPConstantsused by this message context. This may also affect the encoding style.- Parameters:
soapConstants- the new soap constants to use
-
getSchemaVersion
public SchemaVersion getSchemaVersion()
Get the XML schema version information.- Returns:
- the
SchemaVersionin use
-
setSchemaVersion
public void setSchemaVersion(SchemaVersion schemaVersion)
Set the XML schema version this message context will use.- Parameters:
schemaVersion- the newSchemaVersion
-
getSession
public Session getSession()
Get the current session.- Returns:
- the
Sessionthis message context is within
-
setSession
public void setSession(Session session)
Set the current session.- Parameters:
session- the newSession
-
isEncoded
public boolean isEncoded()
Indicates if the opration is encoded.- Returns:
trueif it is encoded,falseotherwise
-
setMaintainSession
public void setMaintainSession(boolean yesno)
Set whether we are maintaining session state.- Parameters:
yesno- flag to set totrueto maintain sessions
-
getMaintainSession
public boolean getMaintainSession()
Discover if we are maintaining session state.- Returns:
trueif we are maintaining state,falseotherwise
-
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.- Returns:
- the current
Message
-
getMessage
public SOAPMessage getMessage()
Gets the SOAPMessage from this message context.- Specified by:
getMessagein interfaceSOAPMessageContext- Returns:
- the
SOAPMessage,nullif no requestSOAPMessageis present in thisSOAPMessageContext
-
setCurrentMessage
public void setCurrentMessage(Message curMsg)
Set the current message. This will set the request before the pivot, and the response afterwards, as guaged by the passedPivod property.- Parameters:
curMsg- theMessageto assign
-
setMessage
public void setMessage(SOAPMessage message)
Sets the SOAPMessage for this message context. This is equivalent to castingmessagetoMessageand then passing it on tosetCurrentMessage().- Specified by:
setMessagein interfaceSOAPMessageContext- Parameters:
message- theSOAPMessagethis context is for
-
getPastPivot
public boolean getPastPivot()
Determine when we've passed the pivot.- Returns:
trueif we have,falseotherwise
-
setPastPivot
public void setPastPivot(boolean pastPivot)
Indicate when we've passed the pivot.- Parameters:
pastPivot- true if we are past the pivot point, false otherwise
-
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()
Get the classloader, implicitly binding to the thread context classloader if an override has not been supplied.- Returns:
- the class loader
-
setClassLoader
public void setClassLoader(java.lang.ClassLoader cl)
Set a new classloader. Setting to null will result in getClassLoader() binding back to the thread context class loader.- Parameters:
cl- the newClassLoaderornull
-
getTargetService
public java.lang.String getTargetService()
Get the name of the targed service for this message.- Returns:
- the target service
-
getAxisEngine
public AxisEngine getAxisEngine()
Get the axis engine. This will benullif the message was created outside an engine- Returns:
- the current axis engine
-
setTargetService
public void setTargetService(java.lang.String tServ) throws AxisFaultSet 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- Throws:
AxisFault- if anything goes wrong in resolving or setting the service
-
getService
public SOAPService getService()
Get theSOAPServiceused to handle services in this context.- Returns:
- the service handler
-
setService
public void setService(SOAPService sh) throws AxisFault
Set theSOAPServiceused to handle services in this context. This method configures a wide range ofMessageContextproperties to suit the handler.- Parameters:
sh- the new service handler- Throws:
AxisFault- if the service could not be set
-
isClient
public boolean isClient()
Let us know whether this is the client or the server.- Returns:
- true if we are a client
-
getStrProp
public java.lang.String getStrProp(java.lang.String propName)
Get aStringproperty by name.- Parameters:
propName- the name of the property to fetch- Returns:
- the value of the named property
- Throws:
java.lang.ClassCastException- if the property named does not have aStringvalue
-
isPropertyTrue
public boolean isPropertyTrue(java.lang.String propName)
Tests to see if the named property is set in the 'bag', returningfalseif it is not present at all. This is equivalent toisPropertyTrue(propName, false).- Parameters:
propName- the name of the property to check- Returns:
- true or false, depending on the value of the property
-
isPropertyTrue
public boolean isPropertyTrue(java.lang.String propName, boolean defaultVal)Test if a property is set to something we consider to be true in the 'bag'.- If not there then
defaultValis returned. - If there, then...
- if its a
Boolean, we'll return booleanValue() - if its an
Integer, we'll returnfalseif its0elsetrue - if its a
Stringwe'll returnfalseif its"false"" or"0"elsetrue - All other types return
true
- if its a
- Parameters:
propName- the name of the property to checkdefaultVal- the default value- Returns:
- true or false, depending on the value of the property
- If not there then
-
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.- Specified by:
setPropertyin interfaceMessageContext- Parameters:
name- Name of the propertyvalue- Value of the property
-
containsProperty
public boolean containsProperty(java.lang.String name)
Returns true if the MessageContext contains a property with the specified name.- Specified by:
containsPropertyin interfaceMessageContext- Parameters:
name- Name of the property whose presense is to be tested- Returns:
- Returns true if the MessageContext contains the property; otherwise false
-
getPropertyNames
public java.util.Iterator getPropertyNames()
Returns anIteratorview of the names of the properties in thisMessageContext.- Specified by:
getPropertyNamesin interfaceMessageContext- Returns:
- an
Iteratorover all property names
-
getAllPropertyNames
public java.util.Iterator getAllPropertyNames()
Returns an Iterator view of the names of the properties in this MessageContext and any parents of the LockableHashtable- Returns:
- Iterator for the property names
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
Returns the value associated with the named property - or null if not defined/set.- Specified by:
getPropertyin interfaceMessageContext- Parameters:
name- the property name- Returns:
- Object value of the property - or null
-
setPropertyParent
public void setPropertyParent(java.util.Hashtable parent)
Set the Hashtable that contains the default values for our properties.- Parameters:
parent-
-
setUsername
public void setUsername(java.lang.String username)
Set the username.- Parameters:
username- the new user name
-
getUsername
public java.lang.String getUsername()
Get the user name.- Returns:
- the user name as a
String
-
setPassword
public void setPassword(java.lang.String password)
Set the password.- Parameters:
password- aStringcontaining the new password
-
getPassword
public java.lang.String getPassword()
Get the password.- Returns:
- the current password
String
-
getOperationStyle
public Style getOperationStyle()
Get the operation style. This is either the style of the current operation or if that is not set, the style of the service handler, or if that is not set,Style.RPC.- Returns:
- the
Styleof this message
-
getOperationUse
public Use getOperationUse()
Get the operation use.- Returns:
- the operation
Use
-
setUseSOAPAction
public void setUseSOAPAction(boolean useSOAPAction)
Enable or dissable the use of soap action information. When enabled, the message context will attempt to use the soap action URI information during binding of soap messages to service methods. When dissabled, it will make no such attempt.- Parameters:
useSOAPAction-trueif soap action URI information should be used,falseotherwise
-
useSOAPAction
public boolean useSOAPAction()
Indicates wether the soap action URI is being used or not.- Returns:
trueif it is,falseotherwise
-
setSOAPActionURI
public void setSOAPActionURI(java.lang.String SOAPActionURI) throws java.lang.IllegalArgumentExceptionSet the soapAction URI.- Parameters:
SOAPActionURI- aStringgiving the new soap action URI- Throws:
java.lang.IllegalArgumentException- if the URI is not liked
-
getSOAPActionURI
public java.lang.String getSOAPActionURI()
Get the soapAction URI.- Returns:
- the URI of this soap action
-
setEncodingStyle
public void setEncodingStyle(java.lang.String namespaceURI)
Sets the encoding style to the URI 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
-
removeProperty
public void removeProperty(java.lang.String propName)
Description copied from interface:MessageContextRemoves a property (name-value pair) from theMessageContext.- Specified by:
removePropertyin interfaceMessageContext- Parameters:
propName- the name of the property to be removed
-
reset
public void reset()
Return this context to a clean state.
-
isHighFidelity
public boolean isHighFidelity()
Read the high fidelity property.Some behavior may be apropreate for high fidelity contexts that is not relevant for low fidelity ones or vica-versa.
- Returns:
trueif the context is high fidelity,falseotherwise
-
setHighFidelity
public void setHighFidelity(boolean highFidelity)
Set the high fidelity propert.Users of the context may be changing what they do based upon this flag.
- Parameters:
highFidelity- the new value of the highFidelity property
-
getRoles
public java.lang.String[] getRoles()
Gets the SOAP actor roles associated with an execution of theHandlerChainand its containedHandlerinstances.Not (yet) implemented method in the SOAPMessageContext interface.
Note: SOAP actor roles apply to the SOAP node and are managed using
HandlerChain.setRoles()andHandlerChain.getRoles(). Handler instances in theHandlerChainuse this information about the SOAP actor roles to process the SOAP header blocks. Note that the SOAP actor roles are invariant during the processing of SOAP message through theHandlerChain.- Specified by:
getRolesin interfaceSOAPMessageContext- Returns:
- an array of URIs for SOAP actor roles
- See Also:
HandlerChain.setRoles(java.lang.String[]),HandlerChain.getRoles()
-
setRoles
public void setRoles(java.lang.String[] roles)
Set the SOAP actor roles associated with an executioni ofCodeHandlerChainand its containedHandlerinstances.- Parameters:
roles- an array ofStringinstances, each representing the URI for a SOAP actor role
-
dispose
public void dispose()
if a message (or subclass) has any disposal needs, this method is where it goes. Subclasses *must* call super.dispose(), and be prepared to be called from the finalizer as well as earlier
-
-