Class ConfigurationContext
- java.lang.Object
-
- org.apache.axis2.context.AbstractContext
-
- org.apache.axis2.context.ConfigurationContext
-
public class ConfigurationContext extends AbstractContext
Axis2 states are held in two information models, called description hierarchy and context hierarchy. Description hierarchy hold deployment configuration and it's values does not change unless deployment configuration change occurs where Context hierarchy hold run time information. Both hierarchies consists four levels, Global, Service Group, Operation and Message. Please look at "Information Model" section of "Axis2 Architecture Guide" for more information.
Configuration Context hold Global level run-time information. This allows same configurations to be used by two Axis2 instances and most Axis2 wide configurations can changed by setting name value pairs of the configurationContext. This hold all OperationContexts, ServiceGroups, Sessions, and ListenerManager.
-
-
Field Summary
Fields Modifier and Type Field Description protected List<ContextListener>
contextListeners
-
Fields inherited from class org.apache.axis2.context.AbstractContext
COPY_PROPERTIES, lastTouchedTime, parent, properties
-
-
Constructor Summary
Constructors Constructor Description ConfigurationContext(AxisConfiguration axisConfiguration)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addContextListener(ContextListener contextListener)
Register aContextListener
to be notified of all sub-context events.void
addServiceGroupContextIntoApplicationScopeTable(ServiceGroupContext serviceGroupContext)
Adds the given ServiceGroupContext into the Application Scope tablevoid
addServiceGroupContextIntoSoapSessionTable(ServiceGroupContext serviceGroupContext)
Adds the given ServiceGroupContext into the SOAP session tablevoid
cleanupContexts()
Called during shutdown to clean up all ContextsMessageContext
createMessageContext()
Create a MessageContext, and notify any registered ContextListener.ServiceGroupContext
createServiceGroupContext(AxisServiceGroup serviceGroup)
Create a ServiceGroupContext for the specified service group, and notify any registered ContextListener.void
deployService(AxisService service)
Deploy a service to the embedded AxisConfiguration, and initialize it.void
fillServiceContextAndServiceGroupContext(MessageContext messageContext)
Searches for a ServiceGroupContext in the map with given id as the key.OperationContext
findOperationContext(String operationName, String serviceName, String serviceGroupName)
Finds the OperationContext given the Operation name, Service Name, and ServiceGroupNameAxisConfiguration
getAxisConfiguration()
Returns the AxisConfigurationString
getContextRoot()
Retrieves the ContextRootListenerManager
getListenerManager()
Retrieve the ListenerManagerOperationContext
getOperationContext(String messageID)
Gets a OperationContext given a Message ID.File
getRealPath(String path)
Allows users to resolve the path relative to the root directory.ConfigurationContext
getRootContext()
String
getServiceContextPath()
Retrieves the ServiceContext pathServiceGroupContext
getServiceGroupContext(String serviceGroupCtxId)
Returns a ServiceGroupContext object associated with the specified ID from the internal table.ServiceGroupContext
getServiceGroupContextFromSoapSessionTable(String serviceGroupContextId, MessageContext msgContext)
Retrieve the ServiceGroupContext from the SOAP session tableString[]
getServiceGroupContextIDs()
Gets all service groups in the system.long
getServiceGroupContextTimeoutInterval()
This will be used to fetch the serviceGroupContextTimoutInterval from any place available.String
getServicePath()
Retrieves the ServicePathThreadFactory
getThreadPool()
Returns the thread factory.void
initCluster()
Initializes the ClusterManager for this ConfigurationContextboolean
isAnyOperationContextRegistered()
boolean
registerOperationContext(String messageID, OperationContext operationContext)
Registers a OperationContext with a given message ID.boolean
registerOperationContext(String messageID, OperationContext mepContext, boolean override)
Registers a OperationContext with a given message ID.void
removeContextListener(ContextListener contextListener)
Remove an already registeredContextListener
void
removeServiceGroupContext(String serviceGroupContextId)
Remove a ServiceGroupContextvoid
removeServiceGroupContext(AxisServiceGroup serviceGroup)
Removes the given ServiceGroup from the ServiceGroup contextvoid
setAxisConfiguration(AxisConfiguration configuration)
Set the AxisConfiguration to the specified configurationvoid
setContextRoot(String contextRoot)
Sets the context root to the given stringvoid
setServicePath(String servicePath)
Sets the ServicePath to the given stringvoid
setThreadPool(ThreadFactory pool)
Sets the thread factory.void
setTransportManager(ListenerManager listenerManager)
Set the TransportManager to the given ListenerManagervoid
shutdownModulesAndServices()
Called during shutdown to clean up all Contextsvoid
terminate()
Invoked during shutdown to stop the ListenerManager and perform configuration cleanupvoid
unregisterOperationContext(String messageID)
Unregisters the operation context associated with the given messageID-
Methods inherited from class org.apache.axis2.context.AbstractContext
clearPropertyDifferences, flush, getLastTouchedTime, getLocalProperty, getParent, getProperties, getProperty, getPropertyDifferences, getPropertyNames, getPropertyNonReplicable, isAncestor, mergeProperties, removeProperty, removePropertyNonReplicable, setLastTouchedTime, setNonReplicableProperty, setParent, setProperties, setProperty, touch
-
-
-
-
Field Detail
-
contextListeners
protected List<ContextListener> contextListeners
-
-
Constructor Detail
-
ConfigurationContext
public ConfigurationContext(AxisConfiguration axisConfiguration)
Constructor- Parameters:
axisConfiguration
- - AxisConfiguration for which to create a context
-
-
Method Detail
-
initCluster
public void initCluster() throws AxisFault
Initializes the ClusterManager for this ConfigurationContext- Throws:
AxisFault
-
addContextListener
public void addContextListener(ContextListener contextListener)
Register aContextListener
to be notified of all sub-context events.- Parameters:
contextListener
- A ContextListener- See Also:
removeContextListener(org.apache.axis2.context.ContextListener)
-
removeContextListener
public void removeContextListener(ContextListener contextListener)
Remove an already registeredContextListener
- Parameters:
contextListener
- A ContextListener- See Also:
addContextListener(org.apache.axis2.context.ContextListener)
-
fillServiceContextAndServiceGroupContext
public void fillServiceContextAndServiceGroupContext(MessageContext messageContext) throws AxisFault
Searches for a ServiceGroupContext in the map with given id as the key.If(key != null && found) check for a service context for the intended service. if (!found) create one and hook up to ServiceGroupContext else create new ServiceGroupContext with the given key or if key is null with a new key create a new service context for the service
- Parameters:
messageContext
- : MessageContext- Throws:
AxisFault
- : If something goes wrong
-
registerOperationContext
public boolean registerOperationContext(String messageID, OperationContext operationContext)
Registers a OperationContext with a given message ID. If the given message id already has a registered operation context, no change is made and the method returns false.- Parameters:
messageID
- the message ID of the request message in the MEPoperationContext
- the OperationContext- Returns:
- true if we registered this context, false if there was already one for that ID
-
registerOperationContext
public boolean registerOperationContext(String messageID, OperationContext mepContext, boolean override)
Registers a OperationContext with a given message ID. If the given message id already has a registered operation context, no change is made unless the override flag is set.- Parameters:
messageID
- the message ID of the request message in the MEPmepContext
- the OperationContextoverride
- true if we should overwrite any existing OperationContext- Returns:
- true if we registered the passed OperationContext, false if not
-
unregisterOperationContext
public void unregisterOperationContext(String messageID)
Unregisters the operation context associated with the given messageID- Parameters:
messageID
- the messageID to remove
-
isAnyOperationContextRegistered
public boolean isAnyOperationContextRegistered()
-
addServiceGroupContextIntoSoapSessionTable
public void addServiceGroupContextIntoSoapSessionTable(ServiceGroupContext serviceGroupContext)
Adds the given ServiceGroupContext into the SOAP session table- Parameters:
serviceGroupContext
- ServiceGroup Context to add
-
addServiceGroupContextIntoApplicationScopeTable
public void addServiceGroupContextIntoApplicationScopeTable(ServiceGroupContext serviceGroupContext)
Adds the given ServiceGroupContext into the Application Scope table- Parameters:
serviceGroupContext
- The Service Group Context to add
-
deployService
public void deployService(AxisService service) throws AxisFault
Deploy a service to the embedded AxisConfiguration, and initialize it.- Parameters:
service
- service to deploy- Throws:
AxisFault
- if there's a problem
-
getAxisConfiguration
public AxisConfiguration getAxisConfiguration()
Returns the AxisConfiguration- Returns:
- Returns AxisConfiguration
-
getOperationContext
public OperationContext getOperationContext(String messageID)
Gets a OperationContext given a Message ID.- Parameters:
messageID
- the message ID of an active OperationContext- Returns:
- an active OperationContext, or null
-
findOperationContext
public OperationContext findOperationContext(String operationName, String serviceName, String serviceGroupName)
Finds the OperationContext given the Operation name, Service Name, and ServiceGroupName- Parameters:
operationName
- - OperationName to findserviceName
- - ServiceName to findserviceGroupName
- - ServiceGroupName to find- Returns:
- Returns OperationContext
OperationContext
-
createMessageContext
public MessageContext createMessageContext()
Create a MessageContext, and notify any registered ContextListener.- Returns:
- a new MessageContext
-
createServiceGroupContext
public ServiceGroupContext createServiceGroupContext(AxisServiceGroup serviceGroup)
Create a ServiceGroupContext for the specified service group, and notify any registered ContextListener.- Parameters:
serviceGroup
- an AxisServiceGroup- Returns:
- a new ServiceGroupContext
-
getRealPath
public File getRealPath(String path)
Allows users to resolve the path relative to the root directory.- Parameters:
path
- a relative path- Returns:
- a File for the given path relative to the current repository, or null if no repo
-
getServiceGroupContextFromSoapSessionTable
public ServiceGroupContext getServiceGroupContextFromSoapSessionTable(String serviceGroupContextId, MessageContext msgContext) throws AxisFault
Retrieve the ServiceGroupContext from the SOAP session table- Parameters:
serviceGroupContextId
- Service Group Context ID to search onmsgContext
- Message Context to search on- Returns:
- Returns a ServiceGroupContext
- Throws:
AxisFault
- if ServiceGroupContext cannot be found
-
getServiceGroupContext
public ServiceGroupContext getServiceGroupContext(String serviceGroupCtxId)
Returns a ServiceGroupContext object associated with the specified ID from the internal table.- Parameters:
serviceGroupCtxId
- The ID string associated with the ServiceGroupContext object- Returns:
- The ServiceGroupContext object, or null if not found
-
getServiceGroupContextIDs
public String[] getServiceGroupContextIDs()
Gets all service groups in the system.- Returns:
- Returns hashmap of ServiceGroupContexts.
-
getThreadPool
public ThreadFactory getThreadPool()
Returns the thread factory.- Returns:
- Returns configuration specific thread pool
-
setAxisConfiguration
public void setAxisConfiguration(AxisConfiguration configuration)
Set the AxisConfiguration to the specified configuration- Parameters:
configuration
- an AxisConfiguration
-
setThreadPool
public void setThreadPool(ThreadFactory pool) throws AxisFault
Sets the thread factory.- Parameters:
pool
- The thread pool- Throws:
AxisFault
- If a thread pool has already been set
-
removeServiceGroupContext
public void removeServiceGroupContext(String serviceGroupContextId)
Remove a ServiceGroupContext- Parameters:
serviceGroupContextId
- The ID of the ServiceGroupContext
-
getListenerManager
public ListenerManager getListenerManager()
Retrieve the ListenerManager- Returns:
- Returns the ListenerManager
-
setTransportManager
public void setTransportManager(ListenerManager listenerManager)
Set the TransportManager to the given ListenerManager- Parameters:
listenerManager
- The ListenerManager for which to set the TransportManager
-
cleanupContexts
public void cleanupContexts()
Called during shutdown to clean up all Contexts
-
shutdownModulesAndServices
public void shutdownModulesAndServices() throws AxisFault
Called during shutdown to clean up all Contexts- Throws:
AxisFault
-
terminate
public void terminate() throws AxisFault
Invoked during shutdown to stop the ListenerManager and perform configuration cleanup- Throws:
AxisFault
-
getServiceContextPath
public String getServiceContextPath()
Retrieves the ServiceContext path- Returns:
- path to the ServiceContext
-
getServicePath
public String getServicePath()
Retrieves the ServicePath- Returns:
- The path to the Service
-
setServicePath
public void setServicePath(String servicePath)
Sets the ServicePath to the given string- Parameters:
servicePath
- The service path for which to set
-
getContextRoot
public String getContextRoot()
Retrieves the ContextRoot- Returns:
- The ContextRoot
-
setContextRoot
public void setContextRoot(String contextRoot)
Sets the context root to the given string- Parameters:
contextRoot
- The context root for which to set
-
getServiceGroupContextTimeoutInterval
public long getServiceGroupContextTimeoutInterval()
This will be used to fetch the serviceGroupContextTimoutInterval from any place available.- Returns:
- the service group context timeout interval (in milliseconds)
-
removeServiceGroupContext
public void removeServiceGroupContext(AxisServiceGroup serviceGroup)
Removes the given ServiceGroup from the ServiceGroup context- Parameters:
serviceGroup
- the AxisServiceGroup to remove
-
getRootContext
public ConfigurationContext getRootContext()
- Specified by:
getRootContext
in classAbstractContext
-
-