Package org.apache.synapse.core.axis2
Class Axis2SynapseEnvironment
- java.lang.Object
-
- org.apache.synapse.core.axis2.Axis2SynapseEnvironment
-
- All Implemented Interfaces:
SynapseEnvironment
public class Axis2SynapseEnvironment extends Object implements SynapseEnvironment
This is the Axis2 implementation of the SynapseEnvironment
-
-
Field Summary
Fields Modifier and Type Field Description static StringINTERMEDIATE_ORIGINAL_BODYstatic StringIS_SOURCE_AVAILABLEstatic StringIS_TARGET_AVAILABLEstatic StringJSON_TYPEstatic StringORIGINAL_CONTENT_TYPEstatic StringORIGINAL_MESSAGE_TYPEstatic StringORIGINAL_TRANSPORT_HEADERSstatic StringSOURCE_MESSAGE_TYPEstatic StringTARGET_FOR_INBOUND_PAYLOAD
-
Constructor Summary
Constructors Constructor Description Axis2SynapseEnvironment(org.apache.axis2.context.ConfigurationContext cfgCtx, SynapseConfiguration synapseConfig)Axis2SynapseEnvironment(org.apache.axis2.context.ConfigurationContext cfgCtx, SynapseConfiguration synapseConfig, ServerContextInformation contextInformation)Axis2SynapseEnvironment(SynapseConfiguration synCfg)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddUnavailableArtifactRef(String key)Add an artifact reference not available in the environment.voidclearUnavailabilityOfArtifact(String key)Clear unavailability of an artifact if it is previously marked as unavailable in the environmentMessageContextcreateMessageContext()This method will be used to create a new MessageContext in the Axis2 environment for Synapse.org.apache.axiom.util.blob.OverflowBlobcreateOverflowBlob()Factory method to create the TemporaryData object as per on the parameters specified in the synapse.properties file, so that the TemporaryData parameters like threshold chunk size can be customized by using the properties file.org.apache.axis2.context.ConfigurationContextgetAxis2ConfigurationContext()Retrieves theConfigurationContextassociated with thisaxis2SynapseEnvExecutorServicegetExecutorService()This will give the access to the synapse thread pool for the advanced mediation tasks.longgetGlobalTimeout()Get the global timeout interval for callbacksMessageDataStoregetMessageDataStore()This method returns message data store which holds a queue of event holder objects.ServerContextInformationgetServerContextInformation()Retrieve theServerContextInformationfrom theenvironment.SynapseConfigurationgetSynapseConfiguration()Retrieves theSynapseConfigurationfrom theenvironmentSynapseDebugManagergetSynapseDebugManager()method to get the reference to debug manager instance which manages debug capabilities in synapse kept in environment level, made available who ever has access to message context will be able to get access to the debug managerList<SynapseHandler>getSynapseHandlers()Get all synapse handlersorg.apache.synapse.task.SynapseTaskManagergetTaskManager()Retrieve theSynapseTaskManagerfrom theenvironment.TenantInfoConfiguratorgetTenantInfoConfigurator()org.apache.synapse.commons.util.ext.TenantInfoInitiatorgetTenantInfoInitiator()Map<String,SynapseXpathFunctionContextProvider>getXpathFunctionExtensions()Returns all declared xpath Function ExtensionsMap<QName,SynapseXpathVariableResolver>getXpathVariableExtensions()Returns all declared xpath Variable ExtensionsvoidinjectAsync(MessageContext synCtx, SequenceMediator seq)This method injects a new message into the Synapse engine for the mediation by the specified sequence.booleaninjectInbound(MessageContext synCtx, SequenceMediator seq, boolean sequential)Used by inbound polling endpoints to inject the message to synapse enginebooleaninjectMessage(MessageContext synCtx)This method injects a new message into the Synapse engine.booleaninjectMessage(MessageContext smc, SequenceMediator seq)Inject message to the sequence in synchronous mannerbooleanisContinuationEnabled()Whether continuation is enabled in the environment.booleanisDebuggerEnabled()Whether debugging is enabled in the environment.booleanisInitialized()Has this environment properly initialized?booleanisUnitTestEnabled()Whether unit test is enabled in the environment.voidregisterSynapseHandler(SynapseHandler handler)Register a synapse handler to the synapse environmentvoidremoveUnavailableArtifactRef(String key)Remove the artifact reference which is previously marked as unavailable in environment from the unavailable listvoidsend(EndpointDefinition endpoint, MessageContext synCtx)This will be used for sending the message provided, to the endpoint specified by the EndpointDefinition using the axis2 environment.voidsetDebugEnabled(boolean isDebugEnabled)set debugging enabled in the environment.voidsetInitialized(boolean state)Mark this environment as ready for processingvoidsetSeverDebugMode(ServerContextInformation contextInformation)this method is to set the debug mode is enabled and initializes the debug manager debug mode is enabled is set for each time Synapse configuration is changed and Synapse environment initializesvoidsetSynapseDebugManager(SynapseDebugManager synapseDebugManager)sets debug manager when synapse environment initializes if the server instance is started in debug modevoidsetTenantInfoConfigurator(TenantInfoConfigurator configurator)voidsetTenantInfoInitiator(org.apache.synapse.commons.util.ext.TenantInfoInitiator initiator)voidsetUnitTestEnabled(boolean isUnitTestEnabled)set unit test mode enabled in the environment.voidsetXpathFunctionExtensions(SynapseXpathFunctionContextProvider functionExt)voidsetXpathVariableExtensions(SynapseXpathVariableResolver variableExt)voidupdateCallMediatorCount(boolean isIncrement)Increment/Decrement the Call mediator count in the environment by 1.
-
-
-
Field Detail
-
INTERMEDIATE_ORIGINAL_BODY
public static final String INTERMEDIATE_ORIGINAL_BODY
- See Also:
- Constant Field Values
-
TARGET_FOR_INBOUND_PAYLOAD
public static final String TARGET_FOR_INBOUND_PAYLOAD
- See Also:
- Constant Field Values
-
ORIGINAL_MESSAGE_TYPE
public static final String ORIGINAL_MESSAGE_TYPE
- See Also:
- Constant Field Values
-
SOURCE_MESSAGE_TYPE
public static final String SOURCE_MESSAGE_TYPE
- See Also:
- Constant Field Values
-
IS_SOURCE_AVAILABLE
public static final String IS_SOURCE_AVAILABLE
- See Also:
- Constant Field Values
-
IS_TARGET_AVAILABLE
public static final String IS_TARGET_AVAILABLE
- See Also:
- Constant Field Values
-
ORIGINAL_TRANSPORT_HEADERS
public static final String ORIGINAL_TRANSPORT_HEADERS
- See Also:
- Constant Field Values
-
ORIGINAL_CONTENT_TYPE
public static final String ORIGINAL_CONTENT_TYPE
- See Also:
- Constant Field Values
-
JSON_TYPE
public static final String JSON_TYPE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Axis2SynapseEnvironment
public Axis2SynapseEnvironment(SynapseConfiguration synCfg)
-
Axis2SynapseEnvironment
public Axis2SynapseEnvironment(org.apache.axis2.context.ConfigurationContext cfgCtx, SynapseConfiguration synapseConfig)
-
Axis2SynapseEnvironment
public Axis2SynapseEnvironment(org.apache.axis2.context.ConfigurationContext cfgCtx, SynapseConfiguration synapseConfig, ServerContextInformation contextInformation)
-
-
Method Detail
-
setSeverDebugMode
public void setSeverDebugMode(ServerContextInformation contextInformation)
this method is to set the debug mode is enabled and initializes the debug manager debug mode is enabled is set for each time Synapse configuration is changed and Synapse environment initializes
-
injectMessage
public boolean injectMessage(MessageContext synCtx)
Description copied from interface:SynapseEnvironmentThis method injects a new message into the Synapse engine. This is used by the underlying SOAP engine to inject messages into Synapse for mediation. e.g. The SynapseMessageReceiver used by Axis2 invokes this to inject new messages- Specified by:
injectMessagein interfaceSynapseEnvironment- Parameters:
synCtx- - Synapse MessageContext to be injected- Returns:
- boolean true if the message processing should be continued and false if it should be aborted
-
injectAsync
public void injectAsync(MessageContext synCtx, SequenceMediator seq)
Description copied from interface:SynapseEnvironmentThis method injects a new message into the Synapse engine for the mediation by the specified sequence. This is used by custom mediation tasks like splitting message in EIP mediation. This method will do the mediation asynchronously using a separate thread from the environment thread pool- Specified by:
injectAsyncin interfaceSynapseEnvironment- Parameters:
synCtx- - Synapse message context to be injectedseq- - Sequence to be used for mediation
-
injectInbound
public boolean injectInbound(MessageContext synCtx, SequenceMediator seq, boolean sequential) throws SynapseException
Used by inbound polling endpoints to inject the message to synapse engine- Specified by:
injectInboundin interfaceSynapseEnvironment- Parameters:
synCtx- message contextsequential- whether message should be injected in sequential manner without spawning new threadsseq- - Sequence to be used for mediation- Returns:
- Boolean - Indicate if were able to inject the message
- Throws:
SynapseException- - in case error occured during the mediation
-
send
public void send(EndpointDefinition endpoint, MessageContext synCtx)
This will be used for sending the message provided, to the endpoint specified by the EndpointDefinition using the axis2 environment.- Specified by:
sendin interfaceSynapseEnvironment- Parameters:
endpoint- - EndpointDefinition to be used to find the endpoint information and the properties of the sending processsynCtx- - Synapse MessageContext to be sent
-
createMessageContext
public MessageContext createMessageContext()
This method will be used to create a new MessageContext in the Axis2 environment for Synapse. This will set all the relevant parts to the MessageContext, but for this message context to be useful creator has to fill in the data like envelope and operation context and so on. This will set a default envelope of type soap12 and a new messageID for the created message along with the ConfigurationContext is being set in to the message correctly.- Specified by:
createMessageContextin interfaceSynapseEnvironment- Returns:
- Synapse MessageContext with the underlying axis2 message context set
-
createOverflowBlob
public org.apache.axiom.util.blob.OverflowBlob createOverflowBlob()
Factory method to create the TemporaryData object as per on the parameters specified in the synapse.properties file, so that the TemporaryData parameters like threshold chunk size can be customized by using the properties file. This can be extended to enforce further policies if required in the future.- Specified by:
createOverflowBlobin interfaceSynapseEnvironment- Returns:
- created TemporaryData object as per in the synapse.properties file
-
getExecutorService
public ExecutorService getExecutorService()
This will give the access to the synapse thread pool for the advanced mediation tasks.- Specified by:
getExecutorServicein interfaceSynapseEnvironment- Returns:
- an ExecutorService to execute the tasks in a new thread from the pool
-
isInitialized
public boolean isInitialized()
Has this environment properly initialized?- Specified by:
isInitializedin interfaceSynapseEnvironment- Returns:
- true if ready for processing
-
setInitialized
public void setInitialized(boolean state)
Mark this environment as ready for processing- Specified by:
setInitializedin interfaceSynapseEnvironment- Parameters:
state- true means ready for processing
-
getSynapseConfiguration
public SynapseConfiguration getSynapseConfiguration()
Retrieves theSynapseConfigurationfrom theenvironment- Specified by:
getSynapseConfigurationin interfaceSynapseEnvironment- Returns:
- synapseConfig associated with the environment
-
getMessageDataStore
public MessageDataStore getMessageDataStore()
Description copied from interface:SynapseEnvironmentThis method returns message data store which holds a queue of event holder objects.- Specified by:
getMessageDataStorein interfaceSynapseEnvironment- Returns:
- messageDataStore
-
getTaskManager
public org.apache.synapse.task.SynapseTaskManager getTaskManager()
Retrieve theSynapseTaskManagerfrom theenvironment.- Specified by:
getTaskManagerin interfaceSynapseEnvironment- Returns:
- SynapseTaskManager of this synapse environment
-
getServerContextInformation
public ServerContextInformation getServerContextInformation()
Retrieve theServerContextInformationfrom theenvironment.- Specified by:
getServerContextInformationin interfaceSynapseEnvironment- Returns:
- ServerContextInformation of the environment
-
getAxis2ConfigurationContext
public org.apache.axis2.context.ConfigurationContext getAxis2ConfigurationContext()
Retrieves theConfigurationContextassociated with thisaxis2SynapseEnv- Returns:
- configContext of the axis2 synapse environment
-
getXpathFunctionExtensions
public Map<String,SynapseXpathFunctionContextProvider> getXpathFunctionExtensions()
Returns all declared xpath Function Extensions- Specified by:
getXpathFunctionExtensionsin interfaceSynapseEnvironment- Returns:
- Hash Map Containing Function Extensions with supported QName keys
-
getXpathVariableExtensions
public Map<QName,SynapseXpathVariableResolver> getXpathVariableExtensions()
Returns all declared xpath Variable Extensions- Specified by:
getXpathVariableExtensionsin interfaceSynapseEnvironment- Returns:
- Hash Map Containing Variable Extensions with supported QName keys
-
getTenantInfoConfigurator
public TenantInfoConfigurator getTenantInfoConfigurator()
- Specified by:
getTenantInfoConfiguratorin interfaceSynapseEnvironment- Returns:
-
getTenantInfoInitiator
public org.apache.synapse.commons.util.ext.TenantInfoInitiator getTenantInfoInitiator()
-
setXpathFunctionExtensions
public void setXpathFunctionExtensions(SynapseXpathFunctionContextProvider functionExt)
-
setXpathVariableExtensions
public void setXpathVariableExtensions(SynapseXpathVariableResolver variableExt)
-
setTenantInfoConfigurator
public void setTenantInfoConfigurator(TenantInfoConfigurator configurator)
-
setTenantInfoInitiator
public void setTenantInfoInitiator(org.apache.synapse.commons.util.ext.TenantInfoInitiator initiator)
-
updateCallMediatorCount
public void updateCallMediatorCount(boolean isIncrement)
Increment/Decrement the Call mediator count in the environment by 1. While Call Mediator count is updated, continuation is enabled/disabled based on the count. If Call Mediator count becomes 0 continuation is disabled. count cannot get negative values.- Specified by:
updateCallMediatorCountin interfaceSynapseEnvironment- Parameters:
isIncrement- whether to increment the count
-
isContinuationEnabled
public boolean isContinuationEnabled()
Whether continuation is enabled in the environment. ContinuationState stack operations are done only if continuation is enabled for the environment.- Specified by:
isContinuationEnabledin interfaceSynapseEnvironment- Returns:
- whether continuation is enabled in the environment
-
addUnavailableArtifactRef
public void addUnavailableArtifactRef(String key)
Add an artifact reference not available in the environment. This stored reference will get cleared when artifact becomes available- Specified by:
addUnavailableArtifactRefin interfaceSynapseEnvironment- Parameters:
key- artifact reference key
-
removeUnavailableArtifactRef
public void removeUnavailableArtifactRef(String key)
Remove the artifact reference which is previously marked as unavailable in environment from the unavailable list- Specified by:
removeUnavailableArtifactRefin interfaceSynapseEnvironment- Parameters:
key- artifact reference key
-
clearUnavailabilityOfArtifact
public void clearUnavailabilityOfArtifact(String key)
Clear unavailability of an artifact if it is previously marked as unavailable in the environment- Specified by:
clearUnavailabilityOfArtifactin interfaceSynapseEnvironment- Parameters:
key- artifact reference key
-
getSynapseHandlers
public List<SynapseHandler> getSynapseHandlers()
Get all synapse handlers- Specified by:
getSynapseHandlersin interfaceSynapseEnvironment- Returns:
- list of synapse handlers
-
registerSynapseHandler
public void registerSynapseHandler(SynapseHandler handler)
Register a synapse handler to the synapse environment- Specified by:
registerSynapseHandlerin interfaceSynapseEnvironment- Parameters:
handler- synapse handler
-
getGlobalTimeout
public long getGlobalTimeout()
Description copied from interface:SynapseEnvironmentGet the global timeout interval for callbacks- Specified by:
getGlobalTimeoutin interfaceSynapseEnvironment- Returns:
- global timeout interval
-
injectMessage
public boolean injectMessage(MessageContext smc, SequenceMediator seq)
Description copied from interface:SynapseEnvironmentInject message to the sequence in synchronous manner- Specified by:
injectMessagein interfaceSynapseEnvironment- Parameters:
smc- - Synapse message context to be injectedseq- - Sequence to be used for mediation- Returns:
- boolean true if the message processing should be continued and false if it should be aborted
-
getSynapseDebugManager
public SynapseDebugManager getSynapseDebugManager()
method to get the reference to debug manager instance which manages debug capabilities in synapse kept in environment level, made available who ever has access to message context will be able to get access to the debug manager- Specified by:
getSynapseDebugManagerin interfaceSynapseEnvironment- Returns:
- debug manager instance
-
setSynapseDebugManager
public void setSynapseDebugManager(SynapseDebugManager synapseDebugManager)
sets debug manager when synapse environment initializes if the server instance is started in debug mode
-
isDebuggerEnabled
public boolean isDebuggerEnabled()
Whether debugging is enabled in the environment.- Specified by:
isDebuggerEnabledin interfaceSynapseEnvironment- Returns:
- whether debugging is enabled in the environment
-
isUnitTestEnabled
public boolean isUnitTestEnabled()
Whether unit test is enabled in the environment.- Returns:
- whether debugging is enabled in the environment
-
setDebugEnabled
public void setDebugEnabled(boolean isDebugEnabled)
set debugging enabled in the environment. * when this is enabled mediation flow can be debugged through a external client when this is disabled mediation flow happens normally
-
setUnitTestEnabled
public void setUnitTestEnabled(boolean isUnitTestEnabled)
set unit test mode enabled in the environment.- Parameters:
isUnitTestEnabled- boolean value of unit test mode
-
-