org.mule.impl.model
Class AbstractComponent

java.lang.Object
  extended by org.mule.impl.model.AbstractComponent
All Implemented Interfaces:
Serializable, Disposable, Initialisable, Lifecycle, Startable, Stoppable, UMOComponent
Direct Known Subclasses:
DirectComponent, JcaComponent, SedaComponent, StreamingComponent

public abstract class AbstractComponent
extends Object
implements UMOComponent

A base implementation for all UMOComponents in Mule

See Also:
Serialized Form

Field Summary
protected  MuleDescriptor descriptor
          The Mule descriptor associated with the component
protected  ExceptionListener exceptionListener
          The exception strategy used by the component, this is provided by the UMODescriptor
protected  AtomicBoolean initialised
          Determines if the component has been initilised
protected  Log logger
          logger used by this class
protected  UMOModel model
          The model in which this component is registered
protected  WaitableBoolean paused
          Determines if the component has been paused
protected  AtomicBoolean poolInitialised
          determines if the proxy pool has been initialised
protected  ComponentStatistics stats
           
protected  AtomicBoolean stopped
          Determines if the component has been stopped
protected  WaitableBoolean stopping
          Determines whether stop has been called and is still in progress
 
Constructor Summary
AbstractComponent(MuleDescriptor descriptor, UMOModel model)
          Default constructor
 
Method Summary
protected  void connectListeners()
           
protected  ComponentStatistics createStatistics()
           
protected  void disconnectListeners()
           
 void dispatchEvent(UMOEvent event)
          Makes an asynhronous event call to the component.
 void dispose()
          A lifecycle method where implementor should free up any resources.
protected abstract  void doDispatch(UMOEvent event)
           
protected  void doDispose()
           
protected  void doForceStop()
           
protected  void doInitialise()
           
protected  void doPause()
          Custom components can execute code necessary to put the component in a paused state here.
protected  void doResume()
          Custom components can execute code necessary to resume a component once it has been paused If a developer overloads this method the doPause() method MUST also be overloaded to avoid inconsistent state in the component
protected abstract  UMOMessage doSend(UMOEvent event)
           
protected  void doStart()
           
protected  void doStop()
           
protected  void fireComponentNotification(int action)
           
 void forceStop()
           
 UMODescriptor getDescriptor()
           
protected  List getIncomingEndpoints()
          Returns a list of all incoming endpoints on a component.
 Object getInstance()
          Gets the underlying instance for this component.
 String getName()
           
 ComponentStatistics getStatistics()
           
protected  void handleException(Exception e)
           
 void initialise()
          Initialise the component.
 boolean isPaused()
          Determines if the component is in a paused state
 boolean isStarted()
          Determines whether this component has been started
 boolean isStopped()
           
 boolean isStopping()
           
protected  Object lookupComponent()
          Provides a consistent mechanism for custom models to create components.
 void pause()
          Pauses event processing for a single Mule Component.
protected  void registerListeners()
           
 void resume()
          Resumes a single Mule Component that has been paused.
 UMOMessage sendEvent(UMOEvent event)
          Makes a synhronous event call to the component.
 void start()
           
protected  void start(boolean startPaused)
          Starts a Mule Component.
protected  void startListeners()
           
 void stop()
           
protected  void stopListeners()
           
 String toString()
           
protected  void unregisterListeners()
           
protected  void waitIfPaused(UMOEvent event)
          Called before an event is sent or dispatched to a component, it will block until resume() is called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected transient Log logger
logger used by this class


descriptor

protected MuleDescriptor descriptor
The Mule descriptor associated with the component


stats

protected ComponentStatistics stats

stopped

protected AtomicBoolean stopped
Determines if the component has been stopped


stopping

protected WaitableBoolean stopping
Determines whether stop has been called and is still in progress


poolInitialised

protected AtomicBoolean poolInitialised
determines if the proxy pool has been initialised


exceptionListener

protected ExceptionListener exceptionListener
The exception strategy used by the component, this is provided by the UMODescriptor


initialised

protected AtomicBoolean initialised
Determines if the component has been initilised


model

protected UMOModel model
The model in which this component is registered


paused

protected WaitableBoolean paused
Determines if the component has been paused

Constructor Detail

AbstractComponent

public AbstractComponent(MuleDescriptor descriptor,
                         UMOModel model)
Default constructor

Method Detail

initialise

public final void initialise()
                      throws InitialisationException
Initialise the component. The component will first create a Mule UMO from the UMODescriptor and then initialise a pool based on the attributes in the UMODescriptor.

Specified by:
initialise in interface Initialisable
Throws:
InitialisationException - if the component fails to initialise
RecoverableException - if an error occurs that can be recovered from
See Also:
UMODescriptor

createStatistics

protected ComponentStatistics createStatistics()

fireComponentNotification

protected void fireComponentNotification(int action)

forceStop

public void forceStop()
               throws UMOException
Throws:
UMOException

stop

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

start

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

start

protected void start(boolean startPaused)
              throws UMOException
Starts a Mule Component.

Parameters:
startPaused - - Start component in a "paused" state (messages are received but not processed).
Throws:
UMOException

pause

public final void pause()
                 throws UMOException
Pauses event processing for a single Mule Component. Unlike stop(), a paused component will still consume messages from the underlying transport, but those messages will be queued until the component is resumed.

Specified by:
pause in interface UMOComponent
Throws:
UMOException

resume

public final void resume()
                  throws UMOException
Resumes a single Mule Component that has been paused. If the component is not paused nothing is executed.

Specified by:
resume in interface UMOComponent
Throws:
UMOException

isPaused

public boolean isPaused()
Determines if the component is in a paused state

Specified by:
isPaused in interface UMOComponent
Returns:
True if the component is in a paused state, false otherwise

doPause

protected void doPause()
                throws UMOException
Custom components can execute code necessary to put the component in a paused state here. If a developer overloads this method the doResume() method MUST also be overloaded to avoid inconsistent state in the component

Throws:
UMOException

doResume

protected void doResume()
                 throws UMOException
Custom components can execute code necessary to resume a component once it has been paused If a developer overloads this method the doPause() method MUST also be overloaded to avoid inconsistent state in the component

Throws:
UMOException

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

getStatistics

public ComponentStatistics getStatistics()

getDescriptor

public UMODescriptor getDescriptor()
Specified by:
getDescriptor in interface UMOComponent
Returns:
the UMODescriptor associated with the component
See Also:
UMODescriptor

dispatchEvent

public void dispatchEvent(UMOEvent event)
                   throws UMOException
Description copied from interface: UMOComponent
Makes an asynhronous event call to the component.

Specified by:
dispatchEvent in interface UMOComponent
Parameters:
event - the event to consume
Throws:
UMOException - if the event fails to be processed

sendEvent

public UMOMessage sendEvent(UMOEvent event)
                     throws UMOException
Description copied from interface: UMOComponent
Makes a synhronous event call to the component. This event will be consumed by the component and a result returned.

Specified by:
sendEvent in interface UMOComponent
Parameters:
event - the event to consume
Returns:
a UMOMessage containing the resulting message and properties
Throws:
UMOException - if the event fails to be processed

waitIfPaused

protected void waitIfPaused(UMOEvent event)
                     throws InterruptedException
Called before an event is sent or dispatched to a component, it will block until resume() is called. Users can override this method if they want to handle pausing differently e.g. implement a store and forward policy

Parameters:
event - the current event being passed to the component
Throws:
InterruptedException - if the thread is interrupted

getName

public String getName()
Returns:
the Mule descriptor name which is associated with the component

toString

public String toString()
Overrides:
toString in class Object

isStopped

public boolean isStopped()

isStopping

public boolean isStopping()

handleException

protected void handleException(Exception e)

lookupComponent

protected Object lookupComponent()
                          throws UMOException
Provides a consistent mechanism for custom models to create components.

Returns:
Throws:
UMOException

doForceStop

protected void doForceStop()
                    throws UMOException
Throws:
UMOException

doStop

protected void doStop()
               throws UMOException
Throws:
UMOException

doStart

protected void doStart()
                throws UMOException
Throws:
UMOException

doDispose

protected void doDispose()

doInitialise

protected void doInitialise()
                     throws InitialisationException
Throws:
InitialisationException

isStarted

public boolean isStarted()
Description copied from interface: UMOComponent
Determines whether this component has been started

Specified by:
isStarted in interface UMOComponent
Returns:
true is the component is started andready to receive events

doSend

protected abstract UMOMessage doSend(UMOEvent event)
                              throws UMOException
Throws:
UMOException

doDispatch

protected abstract void doDispatch(UMOEvent event)
                            throws UMOException
Throws:
UMOException

getInstance

public Object getInstance()
                   throws UMOException
Description copied from interface: UMOComponent
Gets the underlying instance for this component. When the component implementation provides pooling there is no 1:1 mapping between UMOComponent and instance, so this method would return an object in initial state. If the underlying component is managed in Spring or another IoC container, then the object instance from the corresponding container will be returned.

Specified by:
getInstance in interface UMOComponent
Returns:
the underlying instance for this component
Throws:
UMOException

registerListeners

protected void registerListeners()
                          throws UMOException
Throws:
UMOException

unregisterListeners

protected void unregisterListeners()
                            throws UMOException
Throws:
UMOException

startListeners

protected void startListeners()
                       throws UMOException
Throws:
UMOException

stopListeners

protected void stopListeners()
                      throws UMOException
Throws:
UMOException

connectListeners

protected void connectListeners()
                         throws UMOException
Throws:
UMOException

disconnectListeners

protected void disconnectListeners()
                            throws UMOException
Throws:
UMOException

getIncomingEndpoints

protected List getIncomingEndpoints()
Returns a list of all incoming endpoints on a component.



Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.