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.Loglogthe standard log for mediators, will assign the logger for the actual subclassprotected static org.apache.commons.logging.LogtraceThe runtime trace log for mediatorsprotected inttraceStateState of tracing for this mediator
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMediator()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 voidauditLog(String msg, MessageContext msgContext)Deprecated.This method will be removed in a future version of Synapse.protected voidauditWarn(String msg, MessageContext msgContext)Deprecated.This method will be removed in a future version of Synapse.voidconfigure(AspectConfiguration aspectConfiguration)Configure aspects according to the given configurationvoiddisableStatistics()voiddisableTracing()booleandivertMediationRoute(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.voidenableStatistics()voidenableTracing()AspectConfigurationgetAspectConfiguration()Get the aspects configurationList<String>getCommentsList()Returns Comment ListStringgetDescription()Gives the description of the mediatorStringgetInputType()protected MediatorFaultHandlergetLastSequenceFaultHandler(MessageContext synCtx)protected SynapseLoggetLog(MessageContext synCtx)Get a SynapseLog instance appropriate for the given context.StringgetMediatorName()Returns the name of the class of respective mediator.intgetMediatorPosition()Get the position of the mediator in sequence flow.StringgetOutputType()SynapseMediationFlowPointgetRegisteredMediationFlowPoint()StringgetShortDescription()Gives the short description of the mediatorintgetTraceState()Returns the tracing stateStringgetType()Returns the class name of the mediatorprotected voidhandleException(String msg, Exception e, MessageContext msgContext)Perform an error log message to all logs @ ERROR.protected voidhandleException(String msg, MessageContext msgContext)Perform an error log message to all logs @ ERROR.booleanisBreakPoint()booleanisContentAltering()This is used to indicate whether message payload get modified during mediationbooleanisContentAware()booleanisSkipEnabled()booleanisStatisticsEnable()protected booleanisTraceOn(MessageContext msgCtx)Deprecated.This method will be removed in a future version of Synapse.protected booleanisTraceOrDebugOn(boolean isTraceOn)Deprecated.This method will be removed in a future version of Synapse.booleanisTracingEnabled()voidregisterMediationFlowPoint(SynapseMediationFlowPoint flowPoint)voidreportCloseStatistics(MessageContext messageContext, Integer currentIndex)Report Close Statistic Event for the MediatorIntegerreportOpenStatistics(MessageContext messageContext, boolean isContentAltering)Report Open Statistic Event for the MediatorvoidsetBreakPoint(boolean isBreakPoint)voidsetCommentsList(List<String> commentsList)Sets comment list for the mediatorvoidsetComponentStatisticsId(ArtifactHolder holder)voidsetDescription(String description)Set the description of the mediatorvoidsetEffectiveTraceState(MessageContext synCtx)This method is used to save previous tracing state and set next the tracing state for a child mediatorvoidsetMediatorPosition(int position)Set the position of the mediator in the sequencevoidsetShortDescription(String shortDescription)Set the short description of the mediatorvoidsetSkipEnabled(boolean isSkipEnabled)voidsetTraceState(int traceState)Set the tracing state variableprotected booleanshouldCaptureTracing(MessageContext synCtx)booleanshouldTrace(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 itbooleanshouldTrace(MessageContext msgCtx)protected voidtraceOrDebug(boolean traceOn, String msg)Deprecated.This method will be removed in a future version of Synapse.protected voidtraceOrDebugWarn(boolean traceOn, String msg)Deprecated.This method will be removed in a future version of Synapse.voidunregisterMediationFlowPoint()
-
-
-
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:
getTraceStatein interfaceMediator- Returns:
- the tracing state for this mediator (see SynapseConstants)
-
setTraceState
public void setTraceState(int traceState)
Set the tracing state variable- Specified by:
setTraceStatein 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:
setDescriptionin interfaceSynapseArtifact- Parameters:
description- tobe set to the mediator
-
getDescription
public String getDescription()
Gives the description of the mediator- Specified by:
getDescriptionin interfaceSynapseArtifact- Returns:
- description of the mediator
-
setShortDescription
public void setShortDescription(String shortDescription)
Set the short description of the mediator- Specified by:
setShortDescriptionin interfaceMediator- Parameters:
shortDescription- to be set to the mediator
-
getShortDescription
public String getShortDescription()
Gives the short description of the mediator- Specified by:
getShortDescriptionin 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 theSynapseLoginstance 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 theSynapseLoginstance 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 theSynapseLoginstance 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 theSynapseLoginstance 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 theSynapseLoginstance 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 theSynapseLoginstance 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:
configurein interfaceAspectConfigurable- Parameters:
aspectConfiguration- AspectConfiguration instance
-
getAspectConfiguration
public AspectConfiguration getAspectConfiguration()
Get the aspects configuration- Specified by:
getAspectConfigurationin interfaceAspectConfigurable- Returns:
- AspectConfiguration instance
-
isContentAware
public boolean isContentAware()
- Specified by:
isContentAwarein interfaceMediator
-
isContentAltering
public boolean isContentAltering()
Description copied from interface:MediatorThis is used to indicate whether message payload get modified during mediation- Specified by:
isContentAlteringin interfaceMediator- Returns:
- whether mediator modify the payload
-
getMediatorPosition
public int getMediatorPosition()
Description copied from interface:MediatorGet the position of the mediator in sequence flow.- Specified by:
getMediatorPositionin interfaceMediator- Returns:
- position of the mediator in sequence
-
setMediatorPosition
public void setMediatorPosition(int position)
Description copied from interface:MediatorSet the position of the mediator in the sequence- Specified by:
setMediatorPositionin 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:
getMediatorNamein interfaceMediator- Returns:
-
reportOpenStatistics
public Integer reportOpenStatistics(MessageContext messageContext, boolean isContentAltering)
Description copied from interface:MediatorReport Open Statistic Event for the Mediator- Specified by:
reportOpenStatisticsin interfaceMediator
-
reportCloseStatistics
public void reportCloseStatistics(MessageContext messageContext, Integer currentIndex)
Description copied from interface:MediatorReport Close Statistic Event for the Mediator- Specified by:
reportCloseStatisticsin 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:
setComponentStatisticsIdin interfaceMediator
-
getLastSequenceFaultHandler
protected MediatorFaultHandler getLastSequenceFaultHandler(MessageContext synCtx)
-
-