org.apache.synapse.mediators
Class AbstractMediator

java.lang.Object
  extended by org.apache.synapse.mediators.AbstractMediator
All Implemented Interfaces:
AspectConfigurable, Mediator, SynapseArtifact
Direct Known Subclasses:
AbstractDBMediator, AbstractListMediator, AggregateMediator, BinaryExtractMediator, CacheMediator, CalloutMediator, ClassMediator, CloneMediator, ConditionalRouterMediator, DetachMediator, DiscountQuoteMediator, DropMediator, EnqueueMediator, EnrichMediator, EventPublisherMediator, FaultMediator, HeaderMediator, InvokeMediator, IterateMediator, LogMediator, MessageStoreMediator, PayloadFactoryMediator, POJOCommandMediator, PropertyMediator, ReplaceMediator, RMSequenceMediator, SamplingThrottleMediator, ScriptMediator, SEDAMediator, SendMediator, SpringCustomLogger, SpringMediator, SwitchMediator, ThrottleMediator, TransactionMediator, URLRewriteMediator, XQueryMediator, 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
protected  org.apache.commons.logging.Log log
          the standard log for mediators, will assign the logger for the actual subclass
protected static org.apache.commons.logging.Log trace
          The runtime trace log for mediators
protected  int traceState
          State of tracing for this mediator
 
Constructor Summary
protected AbstractMediator()
          A constructor that makes subclasses pick up the correct logger
 
Method Summary
protected  void auditLog(String msg, MessageContext msgContext)
          Deprecated. This method will be removed in a future version of Synapse. Please use the SynapseLog instance returned by getLog(MessageContext) for all logging inside a mediator.
protected  void auditWarn(String msg, MessageContext msgContext)
          Deprecated. This method will be removed in a future version of Synapse. Please use the SynapseLog instance returned by getLog(MessageContext) for all logging inside a mediator.
 void configure(AspectConfiguration aspectConfiguration)
          Configure aspects according to the given configuration
 void disableStatistics()
           
 void enableStatistics()
           
 AspectConfiguration getAspectConfiguration()
          Get the aspects configuration
 String getDescription()
          Gives the description of the mediator
protected  SynapseLog getLog(MessageContext synCtx)
          Get a SynapseLog instance appropriate for the given context.
 int getTraceState()
          Returns the tracing state
 String getType()
          Returns the class name of the mediator
protected  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 isStatisticsEnable()
           
protected  boolean isTraceOn(MessageContext msgCtx)
          Deprecated. This method will be removed in a future version of Synapse. Please use the SynapseLog instance returned by getLog(MessageContext) for all logging inside a mediator.
protected  boolean isTraceOrDebugOn(boolean isTraceOn)
          Deprecated. This method will be removed in a future version of Synapse. Please use the SynapseLog instance returned by getLog(MessageContext) for all logging inside a mediator.
 void setDescription(String description)
          Set the description of the mediator
 void setEffectiveTraceState(MessageContext synCtx)
          This method is used to save previous tracing state and set next the tracing state for a child mediator
 void setTraceState(int traceState)
          Set the tracing state variable
 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
protected  void traceOrDebug(boolean traceOn, String msg)
          Deprecated. This method will be removed in a future version of Synapse. Please use the SynapseLog instance returned by getLog(MessageContext) for all logging inside a mediator.
protected  void traceOrDebugWarn(boolean traceOn, String msg)
          Deprecated. This method will be removed in a future version of Synapse. Please use the SynapseLog instance returned by getLog(MessageContext) for all logging inside a mediator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.synapse.Mediator
mediate
 

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

Constructor Detail

AbstractMediator

protected AbstractMediator()
A constructor that makes subclasses pick up the correct logger

Method Detail

getType

public String getType()
Returns the class name of the mediator

Specified by:
getType in interface Mediator
Returns:
the class name of the mediator

getTraceState

public int getTraceState()
Returns the tracing state

Specified by:
getTraceState in interface Mediator
Returns:
the tracing state for this mediator (see SynapseConstants)

setTraceState

public void setTraceState(int traceState)
Set the tracing state variable

Specified by:
setTraceState in interface Mediator
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 interface SynapseArtifact
Parameters:
description - tobe set to the mediator

getDescription

public String getDescription()
Gives the description of the mediator

Specified by:
getDescription in interface SynapseArtifact
Returns:
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

isTraceOn

@Deprecated
protected boolean isTraceOn(MessageContext msgCtx)
Deprecated. This method will be removed in a future version of Synapse. Please use the SynapseLog instance returned by getLog(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 the SynapseLog instance returned by getLog(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 the SynapseLog instance returned by getLog(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 the SynapseLog instance returned by getLog(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 the SynapseLog instance returned by getLog(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 message
msgContext - 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 message
msgContext - 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 the SynapseLog instance returned by getLog(MessageContext) for all logging inside a mediator.

Write an audit entry at WARN and trace and standard logs @WARN

Parameters:
msg - the message to log
msgContext - 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 message
e - an Exception encountered
msgContext - the message context

isStatisticsEnable

public boolean isStatisticsEnable()

disableStatistics

public void disableStatistics()

enableStatistics

public void enableStatistics()

configure

public void configure(AspectConfiguration aspectConfiguration)
Configure aspects according to the given configuration

Specified by:
configure in interface AspectConfigurable
Parameters:
aspectConfiguration - AspectConfiguration instance

getAspectConfiguration

public AspectConfiguration getAspectConfiguration()
Get the aspects configuration

Specified by:
getAspectConfiguration in interface AspectConfigurable
Returns:
AspectConfiguration instance


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.