Package org.apache.axis
Class MessageContext
java.lang.Object
org.apache.axis.MessageContext
- All Implemented Interfaces:
MessageContext
,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
FieldsModifier and TypeFieldDescriptionstatic final String
A boolean param, to control whether we accept missing parameters as nulls or refuse to acknowledge them.static final String
The directory where in coming attachments are created.static final String
Place to store an AuthenticatedUser.static final String
If on the client - this is the Call object.static final String
Contains an instance of Handler, which is the ServiceContext and the entrypoint of this service.static final String
The value of the property is used by service WSDL generation (aka ?WSDL).static final String
Are we doing Msg vs RPC? - For Java Binding.protected static org.apache.commons.logging.Log
TheLog
used for logging all messages.static final String
Has a quit been requested? Hackish...static final String
The security provider.protected static String
Temporary directory to store attachments.static final String
This String is the URL that the message came to.static final String
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.static final String
The value of the property is used by service WSDL generation (aka ?WSDL). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsProperty
(String name) Returns true if the MessageContext contains a property with the specified name.void
dispose()
if a message (or subclass) has any disposal needs, this method is where it goes.protected void
finalize()
during finalization, the dispose() method is called.Returns an Iterator view of the names of the properties in this MessageContext and any parents of the LockableHashtableGet the axis engine.Get the classloader, implicitly binding to the thread context classloader if an override has not been supplied.static MessageContext
Get the active message context.Return the current (i.e.Returns the encoding style as a URI that should be used for the SOAP message.boolean
Discover if we are maintaining session state.Gets the SOAPMessage from this message context.The current operation.getOperationByQName
(QName qname) get the first possible operation that could match a body containing an element of the given QName.Get the operation style.Get the operation use.Get the password.boolean
Determine when we've passed the pivot.Returns a list of operation descriptors that could may possibly match a body containing an element of the given QName.getProperty
(String name) Returns the value associated with the named property - or null if not defined/set.Returns anIterator
view of the names of the properties in thisMessageContext
.Get the request message.Get the response message.String[]
getRoles()
Gets the SOAP actor roles associated with an execution of theHandlerChain
and its containedHandler
instances.Get the XML schema version information.Get theSOAPService
used to handle services in this context.Get the current session.Get the soapAction URI.Get theSOAPConstants
used by this message context.getStrProp
(String propName) Get aString
property by name.Get the name of the targed service for this message.int
Get timeout from our MessageContext.The name of the transport for this context.Return the type mapping currently in scope for our encoding style.Get the currently in-scope type mapping registry.Get the user name.boolean
isClient()
Let us know whether this is the client or the server.boolean
Indicates if the opration is encoded.boolean
Read the high fidelity property.boolean
isPropertyTrue
(String propName) Tests to see if the named property is set in the 'bag', returningfalse
if it is not present at all.boolean
isPropertyTrue
(String propName, boolean defaultVal) Test if a property is set to something we consider to be true in the 'bag'.void
removeProperty
(String propName) Removes a property (name-value pair) from theMessageContext
.void
reset()
Return this context to a clean state.void
Set a new classloader.void
setCurrentMessage
(Message curMsg) Set the current message.void
setEncodingStyle
(String namespaceURI) Sets the encoding style to the URI passed in.void
setHighFidelity
(boolean highFidelity) Set the high fidelity propert.void
setMaintainSession
(boolean yesno) Set whether we are maintaining session state.void
setMessage
(SOAPMessage message) Sets the SOAPMessage for this message context.void
setOperation
(OperationDesc operation) Set the current operation.void
setPassword
(String password) Set the password.void
setPastPivot
(boolean pastPivot) Indicate when we've passed the pivot.void
setProperty
(String name, Object value) Allows you to set a named property to the passed in value.void
setPropertyParent
(Hashtable parent) Set the Hashtable that contains the default values for our properties.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
Set the SOAP actor roles associated with an executioni ofCodeHandlerChain
and its containedHandler
instances.void
setSchemaVersion
(SchemaVersion schemaVersion) Set the XML schema version this message context will use.void
Set theSOAPService
used to handle services in this context.void
setSession
(Session session) Set the current session.void
setSOAPActionURI
(String SOAPActionURI) Set the soapAction URI.void
setSOAPConstants
(SOAPConstants soapConstants) Set theSOAPConstants
used by this message context.void
setTargetService
(String tServ) Set the target service for this message.void
setTimeout
(int value) Set timeout in our MessageContext.void
setTransportName
(String transportName) Set the transport name for this context.void
Replace the engine's type mapping registry with a local one.void
setUsername
(String username) Set the username.void
setUseSOAPAction
(boolean useSOAPAction) Enable or dissable the use of soap action information.boolean
Indicates wether the soap action URI is being used or not.
-
Field Details
-
log
protected static org.apache.commons.logging.Log logTheLog
used for logging all messages. -
systemTempDir
Temporary directory to store attachments. -
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:
-
TRANS_URL
This String is the URL that the message came to.- See Also:
-
QUIT_REQUESTED
Has a quit been requested? Hackish... but useful... -- RobJ- See Also:
-
AUTHUSER
Place to store an AuthenticatedUser.- See Also:
-
CALL
If on the client - this is the Call object.- See Also:
-
IS_MSG
Are we doing Msg vs RPC? - For Java Binding.- See Also:
-
ATTACHMENTS_DIR
The directory where in coming attachments are created.- See Also:
-
ACCEPTMISSINGPARAMS
A boolean param, to control whether we accept missing parameters as nulls or refuse to acknowledge them.- See Also:
-
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:
-
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:
-
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:
-
SECURITY_PROVIDER
The security provider.- See Also:
-
-
Constructor Details
-
MessageContext
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 Details
-
getOperation
The current operation.- Returns:
- the current operation; may be
null
-
setOperation
Set the current operation.- Parameters:
operation
- theOperation
this context is executing
-
getPossibleOperationsByQName
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
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
Get the active message context.- Returns:
- the current active message context
-
finalize
protected void finalize()during finalization, the dispose() method is called. -
setTypeMappingRegistry
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
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
Return the type mapping currently in scope for our encoding style.- Returns:
- the type mapping
-
getTransportName
The name of the transport for this context.- Returns:
- the transport name
-
setTransportName
Set the transport name for this context.- Parameters:
transportName
- the name of the transport
-
getSOAPConstants
Get theSOAPConstants
used by this message context.- Returns:
- the soap constants
-
setSOAPConstants
Set theSOAPConstants
used by this message context. This may also affect the encoding style.- Parameters:
soapConstants
- the new soap constants to use
-
getSchemaVersion
Get the XML schema version information.- Returns:
- the
SchemaVersion
in use
-
setSchemaVersion
Set the XML schema version this message context will use.- Parameters:
schemaVersion
- the newSchemaVersion
-
getSession
Get the current session.- Returns:
- the
Session
this message context is within
-
setSession
Set the current session.- Parameters:
session
- the newSession
-
isEncoded
public boolean isEncoded()Indicates if the opration is encoded.- Returns:
true
if it is encoded,false
otherwise
-
setMaintainSession
public void setMaintainSession(boolean yesno) Set whether we are maintaining session state.- Parameters:
yesno
- flag to set totrue
to maintain sessions
-
getMaintainSession
public boolean getMaintainSession()Discover if we are maintaining session state.- Returns:
true
if we are maintaining state,false
otherwise
-
getRequestMessage
Get the request message.- Returns:
- the request message (may be null).
-
setRequestMessage
Set the request message, and make sure that message is associated with this MessageContext.- Parameters:
reqMsg
- the new request Message.
-
getResponseMessage
Get the response message.- Returns:
- the response message (may be null).
-
setResponseMessage
Set the response message, and make sure that message is associated with this MessageContext.- Parameters:
respMsg
- the new response Message.
-
getCurrentMessage
Return the current (i.e. request before the pivot, response after) message.- Returns:
- the current
Message
-
getMessage
Gets the SOAPMessage from this message context.- Specified by:
getMessage
in interfaceSOAPMessageContext
- Returns:
- the
SOAPMessage
,null
if no requestSOAPMessage
is present in thisSOAPMessageContext
-
setCurrentMessage
Set the current message. This will set the request before the pivot, and the response afterwards, as guaged by the passedPivod property.- Parameters:
curMsg
- theMessage
to assign
-
setMessage
Sets the SOAPMessage for this message context. This is equivalent to castingmessage
toMessage
and then passing it on tosetCurrentMessage()
.- Specified by:
setMessage
in interfaceSOAPMessageContext
- Parameters:
message
- theSOAPMessage
this context is for
-
getPastPivot
public boolean getPastPivot()Determine when we've passed the pivot.- Returns:
true
if we have,false
otherwise
-
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
Get the classloader, implicitly binding to the thread context classloader if an override has not been supplied.- Returns:
- the class loader
-
setClassLoader
Set a new classloader. Setting to null will result in getClassLoader() binding back to the thread context class loader.- Parameters:
cl
- the newClassLoader
ornull
-
getTargetService
Get the name of the targed service for this message.- Returns:
- the target service
-
getAxisEngine
Get the axis engine. This will benull
if the message was created outside an engine- Returns:
- the current axis engine
-
setTargetService
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- Throws:
AxisFault
- if anything goes wrong in resolving or setting the service
-
getService
Get theSOAPService
used to handle services in this context.- Returns:
- the service handler
-
setService
Set theSOAPService
used to handle services in this context. This method configures a wide range ofMessageContext
properties 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
Get aString
property by name.- Parameters:
propName
- the name of the property to fetch- Returns:
- the value of the named property
- Throws:
ClassCastException
- if the property named does not have aString
value
-
isPropertyTrue
Tests to see if the named property is set in the 'bag', returningfalse
if 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
Test if a property is set to something we consider to be true in the 'bag'.- If not there then
defaultVal
is returned. - If there, then...
- if its a
Boolean
, we'll return booleanValue() - if its an
Integer
, we'll returnfalse
if its0
elsetrue
- if its a
String
we'll returnfalse
if 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
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:
setProperty
in interfaceMessageContext
- Parameters:
name
- Name of the propertyvalue
- Value of the property
-
containsProperty
Returns true if the MessageContext contains a property with the specified name.- Specified by:
containsProperty
in 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
Returns anIterator
view of the names of the properties in thisMessageContext
.- Specified by:
getPropertyNames
in interfaceMessageContext
- Returns:
- an
Iterator
over all property names
-
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
Returns the value associated with the named property - or null if not defined/set.- Specified by:
getProperty
in interfaceMessageContext
- Parameters:
name
- the property name- Returns:
- Object value of the property - or null
-
setPropertyParent
Set the Hashtable that contains the default values for our properties.- Parameters:
parent
-
-
setUsername
Set the username.- Parameters:
username
- the new user name
-
getUsername
Get the user name.- Returns:
- the user name as a
String
-
setPassword
Set the password.- Parameters:
password
- aString
containing the new password
-
getPassword
Get the password.- Returns:
- the current password
String
-
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
Style
of this message
-
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
-true
if soap action URI information should be used,false
otherwise
-
useSOAPAction
public boolean useSOAPAction()Indicates wether the soap action URI is being used or not.- Returns:
true
if it is,false
otherwise
-
setSOAPActionURI
Set the soapAction URI.- Parameters:
SOAPActionURI
- aString
giving the new soap action URI- Throws:
IllegalArgumentException
- if the URI is not liked
-
getSOAPActionURI
Get the soapAction URI.- Returns:
- the URI of this soap action
-
setEncodingStyle
Sets the encoding style to the URI passed in.- Parameters:
namespaceURI
- URI of the encoding to use.
-
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
Description copied from interface:MessageContext
Removes a property (name-value pair) from theMessageContext
.- Specified by:
removeProperty
in 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:
true
if the context is high fidelity,false
otherwise
-
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
Gets the SOAP actor roles associated with an execution of theHandlerChain
and its containedHandler
instances.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 theHandlerChain
use 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:
getRoles
in interfaceSOAPMessageContext
- Returns:
- an array of URIs for SOAP actor roles
- See Also:
-
setRoles
Set the SOAP actor roles associated with an executioni ofCodeHandlerChain
and its containedHandler
instances.- Parameters:
roles
- an array ofString
instances, 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
-