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 String
INTERMEDIATE_ORIGINAL_BODY
static String
IS_SOURCE_AVAILABLE
static String
IS_TARGET_AVAILABLE
static String
JSON_TYPE
static String
ORIGINAL_CONTENT_TYPE
static String
ORIGINAL_MESSAGE_TYPE
static String
ORIGINAL_TRANSPORT_HEADERS
static String
SOURCE_MESSAGE_TYPE
static String
TARGET_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 void
addUnavailableArtifactRef(String key)
Add an artifact reference not available in the environment.void
clearUnavailabilityOfArtifact(String key)
Clear unavailability of an artifact if it is previously marked as unavailable in the environmentMessageContext
createMessageContext()
This method will be used to create a new MessageContext in the Axis2 environment for Synapse.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.org.apache.axis2.context.ConfigurationContext
getAxis2ConfigurationContext()
Retrieves theConfigurationContext
associated with thisaxis2SynapseEnv
ExecutorService
getExecutorService()
This will give the access to the synapse thread pool for the advanced mediation tasks.long
getGlobalTimeout()
Get the global timeout interval for callbacksMessageDataStore
getMessageDataStore()
This method returns message data store which holds a queue of event holder objects.ServerContextInformation
getServerContextInformation()
Retrieve theServerContextInformation
from theenvironment.
SynapseConfiguration
getSynapseConfiguration()
Retrieves theSynapseConfiguration
from theenvironment
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 managerList<SynapseHandler>
getSynapseHandlers()
Get all synapse handlersorg.apache.synapse.task.SynapseTaskManager
getTaskManager()
Retrieve theSynapseTaskManager
from theenvironment
.TenantInfoConfigurator
getTenantInfoConfigurator()
org.apache.synapse.commons.util.ext.TenantInfoInitiator
getTenantInfoInitiator()
Map<String,SynapseXpathFunctionContextProvider>
getXpathFunctionExtensions()
Returns all declared xpath Function ExtensionsMap<QName,SynapseXpathVariableResolver>
getXpathVariableExtensions()
Returns all declared xpath Variable Extensionsvoid
injectAsync(MessageContext synCtx, SequenceMediator seq)
This method injects a new message into the Synapse engine for the mediation by the specified sequence.boolean
injectInbound(MessageContext synCtx, SequenceMediator seq, boolean sequential)
Used by inbound polling endpoints to inject the message to synapse engineboolean
injectMessage(MessageContext synCtx)
This method injects a new message into the Synapse engine.boolean
injectMessage(MessageContext smc, SequenceMediator seq)
Inject message to the sequence in synchronous mannerboolean
isContinuationEnabled()
Whether continuation is enabled in the environment.boolean
isDebuggerEnabled()
Whether debugging is enabled in the environment.boolean
isInitialized()
Has this environment properly initialized?boolean
isUnitTestEnabled()
Whether unit test is enabled in the environment.void
registerSynapseHandler(SynapseHandler handler)
Register a synapse handler to the synapse environmentvoid
removeUnavailableArtifactRef(String key)
Remove the artifact reference which is previously marked as unavailable in environment from the unavailable listvoid
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.void
setDebugEnabled(boolean isDebugEnabled)
set debugging enabled in the environment.void
setInitialized(boolean state)
Mark this environment as ready for processingvoid
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 initializesvoid
setSynapseDebugManager(SynapseDebugManager synapseDebugManager)
sets debug manager when synapse environment initializes if the server instance is started in debug modevoid
setTenantInfoConfigurator(TenantInfoConfigurator configurator)
void
setTenantInfoInitiator(org.apache.synapse.commons.util.ext.TenantInfoInitiator initiator)
void
setUnitTestEnabled(boolean isUnitTestEnabled)
set unit test mode enabled in the environment.void
setXpathFunctionExtensions(SynapseXpathFunctionContextProvider functionExt)
void
setXpathVariableExtensions(SynapseXpathVariableResolver variableExt)
void
updateCallMediatorCount(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:SynapseEnvironment
This 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:
injectMessage
in 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:SynapseEnvironment
This 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:
injectAsync
in 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:
injectInbound
in 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:
send
in 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:
createMessageContext
in 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:
createOverflowBlob
in 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:
getExecutorService
in 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:
isInitialized
in interfaceSynapseEnvironment
- Returns:
- true if ready for processing
-
setInitialized
public void setInitialized(boolean state)
Mark this environment as ready for processing- Specified by:
setInitialized
in interfaceSynapseEnvironment
- Parameters:
state
- true means ready for processing
-
getSynapseConfiguration
public SynapseConfiguration getSynapseConfiguration()
Retrieves theSynapseConfiguration
from theenvironment
- Specified by:
getSynapseConfiguration
in interfaceSynapseEnvironment
- Returns:
- synapseConfig associated with the environment
-
getMessageDataStore
public MessageDataStore getMessageDataStore()
Description copied from interface:SynapseEnvironment
This method returns message data store which holds a queue of event holder objects.- Specified by:
getMessageDataStore
in interfaceSynapseEnvironment
- Returns:
- messageDataStore
-
getTaskManager
public org.apache.synapse.task.SynapseTaskManager getTaskManager()
Retrieve theSynapseTaskManager
from theenvironment
.- Specified by:
getTaskManager
in interfaceSynapseEnvironment
- Returns:
- SynapseTaskManager of this synapse environment
-
getServerContextInformation
public ServerContextInformation getServerContextInformation()
Retrieve theServerContextInformation
from theenvironment.
- Specified by:
getServerContextInformation
in interfaceSynapseEnvironment
- Returns:
- ServerContextInformation of the environment
-
getAxis2ConfigurationContext
public org.apache.axis2.context.ConfigurationContext getAxis2ConfigurationContext()
Retrieves theConfigurationContext
associated with thisaxis2SynapseEnv
- Returns:
- configContext of the axis2 synapse environment
-
getXpathFunctionExtensions
public Map<String,SynapseXpathFunctionContextProvider> getXpathFunctionExtensions()
Returns all declared xpath Function Extensions- Specified by:
getXpathFunctionExtensions
in 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:
getXpathVariableExtensions
in interfaceSynapseEnvironment
- Returns:
- Hash Map Containing Variable Extensions with supported QName keys
-
getTenantInfoConfigurator
public TenantInfoConfigurator getTenantInfoConfigurator()
- Specified by:
getTenantInfoConfigurator
in 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:
updateCallMediatorCount
in 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:
isContinuationEnabled
in 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:
addUnavailableArtifactRef
in 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:
removeUnavailableArtifactRef
in 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:
clearUnavailabilityOfArtifact
in interfaceSynapseEnvironment
- Parameters:
key
- artifact reference key
-
getSynapseHandlers
public List<SynapseHandler> getSynapseHandlers()
Get all synapse handlers- Specified by:
getSynapseHandlers
in interfaceSynapseEnvironment
- Returns:
- list of synapse handlers
-
registerSynapseHandler
public void registerSynapseHandler(SynapseHandler handler)
Register a synapse handler to the synapse environment- Specified by:
registerSynapseHandler
in interfaceSynapseEnvironment
- Parameters:
handler
- synapse handler
-
getGlobalTimeout
public long getGlobalTimeout()
Description copied from interface:SynapseEnvironment
Get the global timeout interval for callbacks- Specified by:
getGlobalTimeout
in interfaceSynapseEnvironment
- Returns:
- global timeout interval
-
injectMessage
public boolean injectMessage(MessageContext smc, SequenceMediator seq)
Description copied from interface:SynapseEnvironment
Inject message to the sequence in synchronous manner- Specified by:
injectMessage
in 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:
getSynapseDebugManager
in 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:
isDebuggerEnabled
in 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
-
-