Package org.apache.synapse.mediators
Class AbstractMediator
- java.lang.Object
-
- org.apache.synapse.mediators.AbstractMediator
-
- All Implemented Interfaces:
AspectConfigurable
,Mediator
,SynapseArtifact
- Direct Known Subclasses:
AbstractDBMediator
,AbstractListMediator
,AggregateMediator
,BeanMediator
,CallMediator
,CalloutMediator
,ClassMediator
,CloneMediator
,CommentMediator
,ConditionalRouterMediator
,DropMediator
,EJBMediator
,EnqueueMediator
,EnrichMediator
,EventPublisherMediator
,FaultMediator
,ForEachMediator
,HeaderMediator
,InvokeMediator
,IterateMediator
,JSONTransformMediator
,LogMediator
,LoopBackMediator
,MessageStoreMediator
,NTLMMediator
,PayloadFactoryMediator
,POJOCommandMediator
,PropertyGroupMediator
,PropertyMediator
,RespondMediator
,SamplingThrottleMediator
,SendMediator
,SwitchMediator
,TransactionMediator
,URLRewriteMediator
,XSLTMediator
public abstract class AbstractMediator extends Object implements Mediator, AspectConfigurable
This is the super class of all mediators, and defines common logging, tracing other aspects for all mediators who extend from this. elements of a mediator class.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.logging.Log
log
the standard log for mediators, will assign the logger for the actual subclassprotected static org.apache.commons.logging.Log
trace
The runtime trace log for mediatorsprotected int
traceState
State of tracing for this mediator
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractMediator()
A constructor that makes subclasses pick up the correct logger
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
auditLog(String msg, MessageContext msgContext)
Deprecated.This method will be removed in a future version of Synapse.protected void
auditWarn(String msg, MessageContext msgContext)
Deprecated.This method will be removed in a future version of Synapse.void
configure(AspectConfiguration aspectConfiguration)
Configure aspects according to the given configurationvoid
disableStatistics()
void
disableTracing()
boolean
divertMediationRoute(MessageContext synCtx)
This method is invoked when mediation happens in debug mode, branches execution to the Debug Manager, further behavior is governed by the Debug Manager.void
enableStatistics()
void
enableTracing()
AspectConfiguration
getAspectConfiguration()
Get the aspects configurationList<String>
getCommentsList()
Returns Comment ListString
getDescription()
Gives the description of the mediatorString
getInputType()
protected MediatorFaultHandler
getLastSequenceFaultHandler(MessageContext synCtx)
protected SynapseLog
getLog(MessageContext synCtx)
Get a SynapseLog instance appropriate for the given context.String
getMediatorName()
Returns the name of the class of respective mediator.int
getMediatorPosition()
Get the position of the mediator in sequence flow.String
getOutputType()
SynapseMediationFlowPoint
getRegisteredMediationFlowPoint()
String
getShortDescription()
Gives the short description of the mediatorint
getTraceState()
Returns the tracing stateString
getType()
Returns the class name of the mediatorprotected void
handleException(String msg, Exception e, MessageContext msgContext)
Perform an error log message to all logs @ ERROR.protected void
handleException(String msg, MessageContext msgContext)
Perform an error log message to all logs @ ERROR.boolean
isBreakPoint()
boolean
isContentAltering()
This is used to indicate whether message payload get modified during mediationboolean
isContentAware()
boolean
isSkipEnabled()
boolean
isStatisticsEnable()
protected boolean
isTraceOn(MessageContext msgCtx)
Deprecated.This method will be removed in a future version of Synapse.protected boolean
isTraceOrDebugOn(boolean isTraceOn)
Deprecated.This method will be removed in a future version of Synapse.boolean
isTracingEnabled()
void
registerMediationFlowPoint(SynapseMediationFlowPoint flowPoint)
void
reportCloseStatistics(MessageContext messageContext, Integer currentIndex)
Report Close Statistic Event for the MediatorInteger
reportOpenStatistics(MessageContext messageContext, boolean isContentAltering)
Report Open Statistic Event for the Mediatorvoid
setBreakPoint(boolean isBreakPoint)
void
setCommentsList(List<String> commentsList)
Sets comment list for the mediatorvoid
setComponentStatisticsId(ArtifactHolder holder)
void
setDescription(String description)
Set the description of the mediatorvoid
setEffectiveTraceState(MessageContext synCtx)
This method is used to save previous tracing state and set next the tracing state for a child mediatorvoid
setMediatorPosition(int position)
Set the position of the mediator in the sequencevoid
setShortDescription(String shortDescription)
Set the short description of the mediatorvoid
setSkipEnabled(boolean isSkipEnabled)
void
setTraceState(int traceState)
Set the tracing state variableprotected boolean
shouldCaptureTracing(MessageContext synCtx)
boolean
shouldTrace(int parentTraceState)
Should this mediator perform tracing? True if its explicitly asked to trace, or its parent has been asked to trace and it does not reject itboolean
shouldTrace(MessageContext msgCtx)
protected void
traceOrDebug(boolean traceOn, String msg)
Deprecated.This method will be removed in a future version of Synapse.protected void
traceOrDebugWarn(boolean traceOn, String msg)
Deprecated.This method will be removed in a future version of Synapse.void
unregisterMediationFlowPoint()
-
-
-
Field Detail
-
log
protected org.apache.commons.logging.Log log
the standard log for mediators, will assign the logger for the actual subclass
-
trace
protected static final org.apache.commons.logging.Log trace
The runtime trace log for mediators
-
traceState
protected int traceState
State of tracing for this mediator
-
-
Method Detail
-
divertMediationRoute
public boolean divertMediationRoute(MessageContext synCtx)
This method is invoked when mediation happens in debug mode, branches execution to the Debug Manager, further behavior is governed by the Debug Manager.- Returns:
- false if the mediation should be continued after this method call, true if mediation of current child mediator position should be skipped
-
getType
public String getType()
Returns the class name of the mediator
-
getTraceState
public int getTraceState()
Returns the tracing state- Specified by:
getTraceState
in interfaceMediator
- Returns:
- the tracing state for this mediator (see SynapseConstants)
-
setTraceState
public void setTraceState(int traceState)
Set the tracing state variable- Specified by:
setTraceState
in interfaceMediator
- Parameters:
traceState
- the new tracing state for this mediator (see SynapseConstants)
-
setDescription
public void setDescription(String description)
Set the description of the mediator- Specified by:
setDescription
in interfaceSynapseArtifact
- Parameters:
description
- tobe set to the mediator
-
getDescription
public String getDescription()
Gives the description of the mediator- Specified by:
getDescription
in interfaceSynapseArtifact
- Returns:
- description of the mediator
-
setShortDescription
public void setShortDescription(String shortDescription)
Set the short description of the mediator- Specified by:
setShortDescription
in interfaceMediator
- Parameters:
shortDescription
- to be set to the mediator
-
getShortDescription
public String getShortDescription()
Gives the short description of the mediator- Specified by:
getShortDescription
in interfaceMediator
- Returns:
- short description of the mediator
-
setEffectiveTraceState
public void setEffectiveTraceState(MessageContext synCtx)
This method is used to save previous tracing state and set next the tracing state for a child mediator- Parameters:
synCtx
- current message
-
getLog
protected SynapseLog getLog(MessageContext synCtx)
Get a SynapseLog instance appropriate for the given context.- Parameters:
synCtx
- the current message context- Returns:
- MediatorLog instance - an implementation of the SynapseLog
-
shouldTrace
public boolean shouldTrace(int parentTraceState)
Should this mediator perform tracing? True if its explicitly asked to trace, or its parent has been asked to trace and it does not reject it- Parameters:
parentTraceState
- parents trace state- Returns:
- true if tracing should be performed
-
shouldTrace
public boolean shouldTrace(MessageContext msgCtx)
-
isTraceOn
@Deprecated protected boolean isTraceOn(MessageContext msgCtx)
Deprecated.This method will be removed in a future version of Synapse. Please use theSynapseLog
instance returned bygetLog(MessageContext)
for all logging inside a mediator.Should this mediator perform tracing? True if its explicitly asked to trace, or its parent has been asked to trace and it does not reject it- Parameters:
msgCtx
- the current message- Returns:
- true if tracing should be performed
-
isTraceOrDebugOn
@Deprecated protected boolean isTraceOrDebugOn(boolean isTraceOn)
Deprecated.This method will be removed in a future version of Synapse. Please use theSynapseLog
instance returned bygetLog(MessageContext)
for all logging inside a mediator.Is tracing or debug logging on?- Parameters:
isTraceOn
- is tracing known to be on?- Returns:
- true, if either tracing or debug logging is on
-
traceOrDebug
@Deprecated protected void traceOrDebug(boolean traceOn, String msg)
Deprecated.This method will be removed in a future version of Synapse. Please use theSynapseLog
instance returned bygetLog(MessageContext)
for all logging inside a mediator.Perform Trace and Debug logging of a message @INFO (trace) and DEBUG (log)- Parameters:
traceOn
- is runtime trace on for this message?msg
- the message to log/trace
-
traceOrDebugWarn
@Deprecated protected void traceOrDebugWarn(boolean traceOn, String msg)
Deprecated.This method will be removed in a future version of Synapse. Please use theSynapseLog
instance returned bygetLog(MessageContext)
for all logging inside a mediator.Perform Trace and Debug logging of a message @WARN- Parameters:
traceOn
- is runtime trace on for this message?msg
- the message to log/trace
-
auditLog
@Deprecated protected void auditLog(String msg, MessageContext msgContext)
Deprecated.This method will be removed in a future version of Synapse. Please use theSynapseLog
instance returned bygetLog(MessageContext)
for all logging inside a mediator.Perform an audit log message to all logs @ INFO. Writes to the general log, the service log and the trace log (of trace is on)- Parameters:
msg
- the log messagemsgContext
- the message context
-
handleException
protected void handleException(String msg, MessageContext msgContext)
Perform an error log message to all logs @ ERROR. Writes to the general log, the service log and the trace log (of trace is on) and throws a SynapseException- Parameters:
msg
- the log messagemsgContext
- the message context
-
auditWarn
@Deprecated protected void auditWarn(String msg, MessageContext msgContext)
Deprecated.This method will be removed in a future version of Synapse. Please use theSynapseLog
instance returned bygetLog(MessageContext)
for all logging inside a mediator.Write an audit entry at WARN and trace and standard logs @WARN- Parameters:
msg
- the message to logmsgContext
- message context
-
handleException
protected void handleException(String msg, Exception e, MessageContext msgContext)
Perform an error log message to all logs @ ERROR. Writes to the general log, the service log and the trace log (of trace is on) and throws a SynapseException- Parameters:
msg
- the log messagee
- an Exception encounteredmsgContext
- the message context
-
isStatisticsEnable
public boolean isStatisticsEnable()
-
disableStatistics
public void disableStatistics()
-
enableStatistics
public void enableStatistics()
-
isTracingEnabled
public boolean isTracingEnabled()
-
disableTracing
public void disableTracing()
-
enableTracing
public void enableTracing()
-
configure
public void configure(AspectConfiguration aspectConfiguration)
Configure aspects according to the given configuration- Specified by:
configure
in interfaceAspectConfigurable
- Parameters:
aspectConfiguration
- AspectConfiguration instance
-
getAspectConfiguration
public AspectConfiguration getAspectConfiguration()
Get the aspects configuration- Specified by:
getAspectConfiguration
in interfaceAspectConfigurable
- Returns:
- AspectConfiguration instance
-
isContentAware
public boolean isContentAware()
- Specified by:
isContentAware
in interfaceMediator
-
isContentAltering
public boolean isContentAltering()
Description copied from interface:Mediator
This is used to indicate whether message payload get modified during mediation- Specified by:
isContentAltering
in interfaceMediator
- Returns:
- whether mediator modify the payload
-
getMediatorPosition
public int getMediatorPosition()
Description copied from interface:Mediator
Get the position of the mediator in sequence flow.- Specified by:
getMediatorPosition
in interfaceMediator
- Returns:
- position of the mediator in sequence
-
setMediatorPosition
public void setMediatorPosition(int position)
Description copied from interface:Mediator
Set the position of the mediator in the sequence- Specified by:
setMediatorPosition
in interfaceMediator
- Parameters:
position
- position
-
getInputType
public String getInputType()
-
getOutputType
public String getOutputType()
-
getCommentsList
public List<String> getCommentsList()
Returns Comment List- Returns:
- String List of comments
-
setCommentsList
public void setCommentsList(List<String> commentsList)
Sets comment list for the mediator- Parameters:
commentsList
- String List of comments
-
getMediatorName
public String getMediatorName()
Returns the name of the class of respective mediator. This was introduced to provide a unique way to get the mediator name because getType is implemented in different ways in different mediators (e.g. PayloadFactoryMediator)- Specified by:
getMediatorName
in interfaceMediator
- Returns:
-
reportOpenStatistics
public Integer reportOpenStatistics(MessageContext messageContext, boolean isContentAltering)
Description copied from interface:Mediator
Report Open Statistic Event for the Mediator- Specified by:
reportOpenStatistics
in interfaceMediator
-
reportCloseStatistics
public void reportCloseStatistics(MessageContext messageContext, Integer currentIndex)
Description copied from interface:Mediator
Report Close Statistic Event for the Mediator- Specified by:
reportCloseStatistics
in interfaceMediator
-
registerMediationFlowPoint
public void registerMediationFlowPoint(SynapseMediationFlowPoint flowPoint)
-
unregisterMediationFlowPoint
public void unregisterMediationFlowPoint()
-
getRegisteredMediationFlowPoint
public SynapseMediationFlowPoint getRegisteredMediationFlowPoint()
-
isBreakPoint
public boolean isBreakPoint()
-
isSkipEnabled
public boolean isSkipEnabled()
-
setBreakPoint
public void setBreakPoint(boolean isBreakPoint)
-
setSkipEnabled
public void setSkipEnabled(boolean isSkipEnabled)
-
shouldCaptureTracing
protected boolean shouldCaptureTracing(MessageContext synCtx)
-
setComponentStatisticsId
public void setComponentStatisticsId(ArtifactHolder holder)
- Specified by:
setComponentStatisticsId
in interfaceMediator
-
getLastSequenceFaultHandler
protected MediatorFaultHandler getLastSequenceFaultHandler(MessageContext synCtx)
-
-