org.apache.synapse.mediators
Class AbstractMediator

java.lang.Object
  extended by org.apache.synapse.mediators.AbstractMediator
All Implemented Interfaces:
Mediator
Direct Known Subclasses:
AbstractDBMediator, AbstractListMediator, AggregateMediator, CacheMediator, CalloutMediator, ClassMediator, CloneMediator, DiscountQuoteMediator, DropMediator, FaultMediator, HeaderMediator, IterateMediator, LogMediator, POJOCommandMediator, PropertyMediator, RMSequenceMediator, ScriptMediator, SendMediator, SpringMediator, SwitchMediator, ThrottleMediator, XQueryMediator, XSLTMediator

public abstract class AbstractMediator
extends Object
implements Mediator

This is the superclass 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)
          Perform an audit log message to all logs @ INFO.
protected  void auditWarn(String msg, MessageContext msgContext)
          Write an audit entry at WARN and trace and standard logs @WARN
 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.
protected  boolean isTraceOn(MessageContext msgCtx)
          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  boolean isTraceOrDebugOn(boolean isTraceOn)
          Is tracing or debug logging on?
 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)
          Perform Trace and Debug logging of a message @INFO (trace) and DEBUG (log)
protected  void traceOrDebugWarn(boolean traceOn, String msg)
          Perform Trace and Debug logging of a message @WARN
 
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)

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

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

protected boolean isTraceOn(MessageContext msgCtx)
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

protected boolean isTraceOrDebugOn(boolean isTraceOn)
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

protected void traceOrDebug(boolean traceOn,
                            String msg)
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

protected void traceOrDebugWarn(boolean traceOn,
                                String msg)
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

protected void auditLog(String msg,
                        MessageContext msgContext)
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

protected void auditWarn(String msg,
                         MessageContext msgContext)
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


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