org.mule.construct
Class AbstractFlowConstruct

java.lang.Object
  extended by org.mule.construct.AbstractFlowConstruct
All Implemented Interfaces:
FlowConstruct, Disposable, Initialisable, Lifecycle, LifecycleStateEnabled, Startable, Stoppable
Direct Known Subclasses:
Bridge, SimpleFlowConstruct, SimpleService, Validator, WSProxy

public abstract class AbstractFlowConstruct
extends Object
implements FlowConstruct, Lifecycle

Abstract implementation of FlowConstruct that:

Implementations of AbstractFlowConstuct should implement configureMessageProcessors(org.mule.api.processor.MessageProcessorChainBuilder) and validateConstruct() to construct the processing chain required and validate the resulting construct. Validation may include validation of the type of attributes of the MessageSource.

Implementations may also implement doInitialise(), doStart(), doStop() and doDispose() if they need to perform any action on lifecycle transitions.


Nested Class Summary
 class AbstractFlowConstruct.ProcessIfPipelineStartedMessageProcessor
           
 
Field Summary
protected  MessagingExceptionHandler exceptionListener
           
static String INITIAL_STATE_STARTED
           
static String INITIAL_STATE_STOPPED
          The initial states that the flow can be started in
protected  String initialState
          Determines the initial state of this flow when the mule starts.
protected  FlowConstructLifecycleManager lifecycleManager
           
protected  Log logger
           
protected  MessageInfoMapping messageInfoMapping
           
protected  MessageProcessorChain messageProcessorChain
           
protected  MessageSource messageSource
           
protected  MuleContext muleContext
           
protected  String name
           
protected  FlowConstructStatistics statistics
           
protected  ThreadingProfile threadingProfile
           
 
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
 
Constructor Summary
AbstractFlowConstruct(String name, MuleContext muleContext)
           
 
Method Summary
protected abstract  void configureMessageProcessors(MessageProcessorChainBuilder builder)
          Used to configure the processing chain for this FlowConstuctAbstractFlowConstruct.ProcessIfPipelineStartedMessageProcessors to the chain using the builder provided.
protected  void createMessageProcessor()
          Creates a AbstractFlowConstruct.ProcessIfPipelineStartedMessageProcessor that will process messages from the configured MessageSource.
 void dispose()
          A lifecycle method where implementor should free up any resources.
protected  void disposeIfDisposable(Object candidate)
           
protected  void doDispose()
           
protected  void doInitialise()
           
protected  void doStart()
           
protected  void doStop()
           
abstract  String getConstructType()
           
 MessagingExceptionHandler getExceptionListener()
           
 String getInitialState()
           
 LifecycleState getLifecycleState()
           
 MessageInfoMapping getMessageInfoMapping()
           
 MessageProcessorChain getMessageProcessorChain()
           
 MessageSource getMessageSource()
           
 MuleContext getMuleContext()
           
 String getName()
           
 FlowConstructStatistics getStatistics()
           
 ThreadingProfile getThreadingProfile()
           
 void initialise()
          Method used to perform any initialisation work.
protected  void initialiseIfInitialisable(Object candidate)
           
protected  void injectFlowConstructMuleContext(Object candidate)
           
 boolean isStarted()
           
 boolean isStopped()
           
 boolean isStopping()
           
 void setExceptionListener(MessagingExceptionHandler exceptionListener)
           
 void setInitialState(String initialState)
           
 void setMessageInfoMapping(MessageInfoMapping messageInfoMapping)
           
 void setMessageSource(MessageSource messageSource)
           
 void start()
           
protected  void startIfStartable(Object candidate)
           
 void stop()
           
protected  void stopIfStoppable(Object candidate)
           
 String toString()
           
protected  void validateConstruct()
          Validates configured flow construct
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected transient Log logger

name

protected String name

messageSource

protected MessageSource messageSource

messageProcessorChain

protected MessageProcessorChain messageProcessorChain

exceptionListener

protected MessagingExceptionHandler exceptionListener

lifecycleManager

protected final FlowConstructLifecycleManager lifecycleManager

muleContext

protected final MuleContext muleContext

statistics

protected FlowConstructStatistics statistics

messageInfoMapping

protected MessageInfoMapping messageInfoMapping

threadingProfile

protected ThreadingProfile threadingProfile

INITIAL_STATE_STOPPED

public static final String INITIAL_STATE_STOPPED
The initial states that the flow can be started in

See Also:
Constant Field Values

INITIAL_STATE_STARTED

public static final String INITIAL_STATE_STARTED
See Also:
Constant Field Values

initialState

protected String initialState
Determines the initial state of this flow when the mule starts. Can be 'stopped' or 'started' (default)

Constructor Detail

AbstractFlowConstruct

public AbstractFlowConstruct(String name,
                             MuleContext muleContext)
Method Detail

initialise

public final void initialise()
                      throws InitialisationException
Description copied from interface: Initialisable
Method used to perform any initialisation work. If a fatal error occurs during initialisation an InitialisationException should be thrown, causing the Mule instance to shutdown. If the error is recoverable, say by retrying to connect, a RecoverableException should be thrown. There is no guarantee that by throwing a Recoverable exception that the Mule instance will not shut down.

Specified by:
initialise in interface Initialisable
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

start

public final void start()
                 throws MuleException
Specified by:
start in interface Startable
Throws:
MuleException

stop

public final void stop()
                throws MuleException
Specified by:
stop in interface Stoppable
Throws:
MuleException

dispose

public final void dispose()
Description copied from interface: Disposable
A lifecycle method where implementor should free up any resources. If an exception is thrown it should just be logged and processing should continue. This method should not throw Runtime exceptions.

Specified by:
dispose in interface Disposable

getThreadingProfile

public ThreadingProfile getThreadingProfile()

isStarted

public boolean isStarted()

isStopped

public boolean isStopped()

isStopping

public boolean isStopping()

createMessageProcessor

protected void createMessageProcessor()
                               throws MuleException
Creates a AbstractFlowConstruct.ProcessIfPipelineStartedMessageProcessor that will process messages from the configured MessageSource.

The default implementation of this methods uses a DefaultMessageProcessorChainBuilder and allows a chain of AbstractFlowConstruct.ProcessIfPipelineStartedMessageProcessors to be configured using the configureMessageProcessors(org.mule.api.processor.MessageProcessorChainBuilder) method but if you wish to use another MessageProcessorBuilder or just a single AbstractFlowConstruct.ProcessIfPipelineStartedMessageProcessor then this method can be overridden and return a single AbstractFlowConstruct.ProcessIfPipelineStartedMessageProcessor instead.

Throws:
MuleException

configureMessageProcessors

protected abstract void configureMessageProcessors(MessageProcessorChainBuilder builder)
                                            throws MuleException
Used to configure the processing chain for this FlowConstuctAbstractFlowConstruct.ProcessIfPipelineStartedMessageProcessors to the chain using the builder provided.

To use a different builder of to construct a composite AbstractFlowConstruct.ProcessIfPipelineStartedMessageProcessor manually override createMessageProcessor() instead.

Parameters:
builder - instance of DefaultMessageProcessorChainBuilder
Throws:
MuleException

getName

public String getName()
Specified by:
getName in interface FlowConstruct
Returns:
The name which identifies this flow construct which is unique in MuleConext registry

getExceptionListener

public MessagingExceptionHandler getExceptionListener()
Specified by:
getExceptionListener in interface FlowConstruct
Returns:
The exception listener that will be used to handle exceptions that may be thrown at different points during the message flow defined by this construct.

setExceptionListener

public void setExceptionListener(MessagingExceptionHandler exceptionListener)

getInitialState

public String getInitialState()

setInitialState

public void setInitialState(String initialState)

getLifecycleState

public LifecycleState getLifecycleState()
Specified by:
getLifecycleState in interface LifecycleStateEnabled

getMuleContext

public MuleContext getMuleContext()

getMessageSource

public MessageSource getMessageSource()

setMessageSource

public void setMessageSource(MessageSource messageSource)

getStatistics

public FlowConstructStatistics getStatistics()
Specified by:
getStatistics in interface FlowConstruct
Returns:
The statistics holder used by this flow construct to keep track of its activity.

getMessageInfoMapping

public MessageInfoMapping getMessageInfoMapping()
Specified by:
getMessageInfoMapping in interface FlowConstruct
Returns:
This implementation of MessageInfoMapping used to control how Important message information is pulled from the current message.

setMessageInfoMapping

public void setMessageInfoMapping(MessageInfoMapping messageInfoMapping)

doInitialise

protected void doInitialise()
                     throws InitialisationException
Throws:
InitialisationException

doStart

protected void doStart()
                throws MuleException
Throws:
MuleException

doStop

protected void doStop()
               throws MuleException
Throws:
MuleException

doDispose

protected void doDispose()

validateConstruct

protected void validateConstruct()
                          throws FlowConstructInvalidException
Validates configured flow construct

Throws:
FlowConstructInvalidException - if the flow construct does not pass validation

injectFlowConstructMuleContext

protected void injectFlowConstructMuleContext(Object candidate)

toString

public String toString()
Overrides:
toString in class Object

initialiseIfInitialisable

protected void initialiseIfInitialisable(Object candidate)
                                  throws InitialisationException
Throws:
InitialisationException

startIfStartable

protected void startIfStartable(Object candidate)
                         throws MuleException
Throws:
MuleException

stopIfStoppable

protected void stopIfStoppable(Object candidate)
                        throws MuleException
Throws:
MuleException

disposeIfDisposable

protected void disposeIfDisposable(Object candidate)

getMessageProcessorChain

public MessageProcessorChain getMessageProcessorChain()
Specified by:
getMessageProcessorChain in interface FlowConstruct

getConstructType

public abstract String getConstructType()
Returns:
the type of construct being created, e.g. "Flow"


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