org.mule.exception
Class AbstractExceptionListener

java.lang.Object
  extended by org.mule.processor.AbstractMuleObjectOwner<MessageProcessor>
      extended by org.mule.processor.AbstractMessageProcessorOwner
          extended by org.mule.exception.AbstractExceptionListener
All Implemented Interfaces:
AnnotatedObject, FlowConstructAware, MuleContextAware, Disposable, Initialisable, Lifecycle, Startable, Stoppable
Direct Known Subclasses:
AbstractExceptionStrategy, AbstractMessagingExceptionStrategy, AbstractSystemExceptionStrategy, TemplateMessagingExceptionStrategy

public abstract class AbstractExceptionListener
extends AbstractMessageProcessorOwner

This is the base class for exception strategies which contains several helper methods. However, you should probably inherit from AbstractMessagingExceptionStrategy (if you are creating a Messaging Exception Strategy) or AbstractSystemExceptionStrategy (if you are creating a System Exception Strategy) rather than directly from this class.


Field Summary
protected  WildcardFilter commitTxFilter
           
protected  boolean enableNotifications
           
protected  AtomicBoolean initialised
           
protected  Log logger
           
protected  List<MessageProcessor> messageProcessors
           
protected  WildcardFilter rollbackTxFilter
           
 
Fields inherited from class org.mule.processor.AbstractMuleObjectOwner
flowConstruct, muleContext
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Startable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Stoppable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Fields inherited from interface org.mule.api.AnnotatedObject
PROPERTY_NAME
 
Constructor Summary
AbstractExceptionListener()
           
 
Method Summary
 void addEndpoint(MessageProcessor processor)
           
protected  void closeStream(MuleMessage message)
           
protected  void commit()
           
protected  void doInitialise(MuleContext muleContext)
           
protected  void fireNotification(Exception ex)
           
protected  void fireNotification(ServerNotification notification)
          Fires a server notification to all registered ExceptionNotificationListener eventManager.
 WildcardFilter getCommitTxFilter()
           
protected  Throwable getExceptionType(Throwable t, Class exceptionType)
           
 List<MessageProcessor> getMessageProcessors()
           
protected  List<MessageProcessor> getOwnedMessageProcessors()
           
 WildcardFilter getRollbackTxFilter()
           
protected  void handleTransaction(Throwable t)
          Deprecated. this method should not be used anymore. Transactions must be handled by provided ExceptionStrategy
 void initialise()
          The initialise method is call every time the Exception stategy is assigned to a service or connector.
 boolean isEnableNotifications()
           
 boolean isInitialised()
           
protected  boolean isRollback(Throwable t)
           
protected  void logException(Throwable t)
          Used to log the error passed into this Exception Listener
protected  void logFatal(MuleEvent event, Throwable t)
          Logs a fatal error message to the logging system.
 boolean removeMessageProcessor(MessageProcessor processor)
           
protected  void rollback(Exception ex)
           
protected  void rollback(RollbackSourceCallback rollbackMethod)
          Deprecated. use rollback(Exception) instead
protected  void rollbackTransaction()
          Deprecated. use rollback(Exception) instead. parameter should be null
protected  void routeException(MuleEvent event, MessageProcessor target, Throwable t)
          Deprecated. use routeException(org.mule.api.MuleEvent, Throwable) instead
protected  void routeException(MuleEvent event, Throwable t)
          Routes the current exception to an error endpoint such as a Dead Letter Queue (jms) This method is only invoked if there is a MuleMessage available to dispatch.
 void setCommitTxFilter(WildcardFilter commitTxFilter)
           
 void setEnableNotifications(boolean enableNotifications)
           
 void setMessageProcessors(List<MessageProcessor> processors)
           
 void setRollbackTxFilter(WildcardFilter rollbackTxFilter)
           
 
Methods inherited from class org.mule.processor.AbstractMessageProcessorOwner
getAnnotation, getAnnotations, getOwnedObjects, setAnnotations
 
Methods inherited from class org.mule.processor.AbstractMuleObjectOwner
dispose, getFlowConstruct, getMuleContext, setFlowConstruct, setMuleContext, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.api.lifecycle.Startable
start
 
Methods inherited from interface org.mule.api.lifecycle.Stoppable
stop
 
Methods inherited from interface org.mule.api.lifecycle.Disposable
dispose
 
Methods inherited from interface org.mule.api.context.MuleContextAware
setMuleContext
 
Methods inherited from interface org.mule.api.construct.FlowConstructAware
setFlowConstruct
 

Field Detail

logger

protected transient Log logger

messageProcessors

protected List<MessageProcessor> messageProcessors

initialised

protected AtomicBoolean initialised

rollbackTxFilter

protected WildcardFilter rollbackTxFilter

commitTxFilter

protected WildcardFilter commitTxFilter

enableNotifications

protected boolean enableNotifications
Constructor Detail

AbstractExceptionListener

public AbstractExceptionListener()
Method Detail

isRollback

protected boolean isRollback(Throwable t)

getMessageProcessors

public List<MessageProcessor> getMessageProcessors()

setMessageProcessors

public void setMessageProcessors(List<MessageProcessor> processors)

addEndpoint

public void addEndpoint(MessageProcessor processor)

removeMessageProcessor

public boolean removeMessageProcessor(MessageProcessor processor)

getExceptionType

protected Throwable getExceptionType(Throwable t,
                                     Class exceptionType)

initialise

public final void initialise()
                      throws InitialisationException
The initialise method is call every time the Exception stategy is assigned to a service or connector. This implementation ensures that initialise is called only once. The actual initialisation code is contained in the doInitialise() method.

Specified by:
initialise in interface Initialisable
Overrides:
initialise in class AbstractMuleObjectOwner<MessageProcessor>
Throws:
InitialisationException
RecoverableException - if an error occurs that can be recovered from

doInitialise

protected void doInitialise(MuleContext muleContext)
                     throws InitialisationException
Throws:
InitialisationException

fireNotification

protected void fireNotification(Exception ex)

routeException

protected void routeException(MuleEvent event,
                              Throwable t)
Routes the current exception to an error endpoint such as a Dead Letter Queue (jms) This method is only invoked if there is a MuleMessage available to dispatch. The message dispatched from this method will be an ExceptionMessage which contains the exception thrown the MuleMessage and any context information.

Parameters:
event - the MuleEvent being processed when the exception occurred
t - the exception thrown. This will be sent with the ExceptionMessage
See Also:
ExceptionMessage

routeException

@Deprecated
protected void routeException(MuleEvent event,
                                         MessageProcessor target,
                                         Throwable t)
Deprecated. use routeException(org.mule.api.MuleEvent, Throwable) instead


rollback

protected void rollback(RollbackSourceCallback rollbackMethod)
Deprecated. use rollback(Exception) instead


closeStream

protected void closeStream(MuleMessage message)

logException

protected void logException(Throwable t)
Used to log the error passed into this Exception Listener

Parameters:
t - the exception thrown

logFatal

protected void logFatal(MuleEvent event,
                        Throwable t)
Logs a fatal error message to the logging system. This should be used mostly if an error occurs in the exception listener itself. This implementation logs the the message itself to the logs if it is not null

Parameters:
event - The MuleEvent currently being processed
t - the fatal exception to log

isInitialised

public boolean isInitialised()

fireNotification

protected void fireNotification(ServerNotification notification)
Fires a server notification to all registered ExceptionNotificationListener eventManager.

Parameters:
notification - the notification to fire.

getCommitTxFilter

public WildcardFilter getCommitTxFilter()

setCommitTxFilter

public void setCommitTxFilter(WildcardFilter commitTxFilter)

isEnableNotifications

public boolean isEnableNotifications()

setEnableNotifications

public void setEnableNotifications(boolean enableNotifications)

getRollbackTxFilter

public WildcardFilter getRollbackTxFilter()

setRollbackTxFilter

public void setRollbackTxFilter(WildcardFilter rollbackTxFilter)

getOwnedMessageProcessors

protected List<MessageProcessor> getOwnedMessageProcessors()
Specified by:
getOwnedMessageProcessors in class AbstractMessageProcessorOwner

rollbackTransaction

@Deprecated
protected void rollbackTransaction()
Deprecated. use rollback(Exception) instead. parameter should be null


handleTransaction

@Deprecated
protected void handleTransaction(Throwable t)
Deprecated. this method should not be used anymore. Transactions must be handled by provided ExceptionStrategy

If there is a current transaction this method will mark it for rollback This method should not be called if an event is routed from this exception handler to an endpoint that should take part in the current transaction


commit

protected void commit()

rollback

protected void rollback(Exception ex)


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.