org.mule.impl.model.seda
Class SedaComponent

java.lang.Object
  extended by org.mule.impl.model.AbstractComponent
      extended by org.mule.impl.model.seda.SedaComponent
All Implemented Interfaces:
Serializable, Runnable, EventListener, javax.resource.spi.work.Work, javax.resource.spi.work.WorkListener, Disposable, Initialisable, Lifecycle, Startable, Stoppable, UMOComponent
Direct Known Subclasses:
OptimisedSedaComponent

public class SedaComponent
extends AbstractComponent
implements javax.resource.spi.work.Work, javax.resource.spi.work.WorkListener

A Seda component runs inside a Seda Model and is responsible for managing a Seda Queue and thread pool for a Mule sevice component. In Seda terms this is equivilent to a stage.

See Also:
Serialized Form

Field Summary
protected  boolean componentPerRequest
          If this is set to true a new component will be created for every request.
protected  MuleProxy componentProxy
          Is created only if component pooling is turned off on the SEDAModel.
protected  String descriptorQueueName
           
protected  boolean enablePooling
          Whether component objects should be pooled or a single instance should be used.
static String POOLING_PROFILE_PROPERTY
           
protected  PoolingProfile poolingProfile
          The pooling configuration used when initialising the component described by this descriptor.
protected  ObjectPool proxyPool
          A pool of available Mule proxies.
static String QUEUE_PROFILE_PROPERTY
           
protected  QueueProfile queueProfile
          The queuing profile for events received for this component.
protected  int queueTimeout
          The time out used for taking from the Seda Queue.
protected  UMOWorkManager workManager
           
 
Fields inherited from class org.mule.impl.model.AbstractComponent
descriptor, exceptionListener, initialised, logger, model, paused, poolInitialised, stats, stopped, stopping
 
Constructor Summary
SedaComponent(MuleDescriptor descriptor, SedaModel model)
          Creates a new SEDA component.
 
Method Summary
protected  MuleProxy createComponentProxy()
           
protected  ObjectPool createPool()
           
protected  ComponentStatistics createStatistics()
           
protected  UMOEvent dequeue()
           
protected  void doDispatch(UMOEvent event)
           
protected  void doDispose()
           
 void doForceStop()
           
 void doInitialise()
          Initialise the component.
protected  void doReleaseProxy(MuleProxy proxy)
          This method is called once when a proxy has finished processing a request (regardless of success).
 UMOMessage doSend(UMOEvent event)
           
 void doStart()
           
 void doStop()
           
protected  void enqueue(UMOEvent event)
           
 PoolingProfile getPoolingProfile()
           
protected  MuleProxy getProxy()
          The proxy may be one of three types: 1.
 QueueProfile getQueueProfile()
           
 int getQueueSize()
           
protected  void handleWorkException(javax.resource.spi.work.WorkEvent event, String type)
           
protected  void initialisePool()
           
 void release()
           
 void run()
          While the component isn't stopped this runs a continuous loop checking for new events in the queue.
 void setPoolingProfile(PoolingProfile poolingProfile)
           
 void setQueueProfile(QueueProfile queueProfile)
           
 void workAccepted(javax.resource.spi.work.WorkEvent event)
           
 void workCompleted(javax.resource.spi.work.WorkEvent event)
          There are two units of work that call this method when they complete (regardless of whether or not they incurred an exception): 1) This component's queue listener that processes asynchronous events by scheduling a component proxy 2) Each scheduled component proxy
 void workRejected(javax.resource.spi.work.WorkEvent event)
          This method ensures that any component proxy associated with this rejected work is released.
 void workStarted(javax.resource.spi.work.WorkEvent event)
           
 
Methods inherited from class org.mule.impl.model.AbstractComponent
connectListeners, disconnectListeners, dispatchEvent, dispose, doPause, doResume, fireComponentNotification, forceStop, getDescriptor, getIncomingEndpoints, getInstance, getName, getStatistics, handleException, initialise, isPaused, isStarted, isStopped, isStopping, lookupComponent, pause, registerListeners, resume, sendEvent, start, start, startListeners, stop, stopListeners, toString, unregisterListeners, waitIfPaused
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

QUEUE_PROFILE_PROPERTY

public static final String QUEUE_PROFILE_PROPERTY
See Also:
Constant Field Values

POOLING_PROFILE_PROPERTY

public static final String POOLING_PROFILE_PROPERTY
See Also:
Constant Field Values

proxyPool

protected ObjectPool proxyPool
A pool of available Mule proxies. If component pooling has been disabled on the SEDAModel, this pool will be null and the 'componentProxy' will be used.


componentProxy

protected MuleProxy componentProxy
Is created only if component pooling is turned off on the SEDAModel. In this scenario all requests are serviced by this component, unless componentPerRequest flag is set on the model.


workManager

protected UMOWorkManager workManager

descriptorQueueName

protected String descriptorQueueName

queueTimeout

protected int queueTimeout
The time out used for taking from the Seda Queue.


enablePooling

protected boolean enablePooling
Whether component objects should be pooled or a single instance should be used.


componentPerRequest

protected boolean componentPerRequest
If this is set to true a new component will be created for every request.


poolingProfile

protected PoolingProfile poolingProfile
The pooling configuration used when initialising the component described by this descriptor.


queueProfile

protected QueueProfile queueProfile
The queuing profile for events received for this component.

Constructor Detail

SedaComponent

public SedaComponent(MuleDescriptor descriptor,
                     SedaModel model)
Creates a new SEDA component.

Parameters:
descriptor - The descriptor of the component to creat
model - the model in which the component is registered
Method Detail

doInitialise

public void doInitialise()
                  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.

Overrides:
doInitialise in class AbstractComponent
Throws:
InitialisationException - if the component fails to initialise
See Also:
UMODescriptor

createStatistics

protected ComponentStatistics createStatistics()
Overrides:
createStatistics in class AbstractComponent

createPool

protected ObjectPool createPool()
                         throws InitialisationException
Throws:
InitialisationException

initialisePool

protected void initialisePool()
                       throws InitialisationException
Throws:
InitialisationException

createComponentProxy

protected MuleProxy createComponentProxy()
                                  throws InitialisationException
Throws:
InitialisationException

doForceStop

public void doForceStop()
                 throws UMOException
Overrides:
doForceStop in class AbstractComponent
Throws:
UMOException

doStop

public void doStop()
            throws UMOException
Overrides:
doStop in class AbstractComponent
Throws:
UMOException

doStart

public void doStart()
             throws UMOException
Overrides:
doStart in class AbstractComponent
Throws:
UMOException

doDispose

protected void doDispose()
Overrides:
doDispose in class AbstractComponent

doDispatch

protected void doDispatch(UMOEvent event)
                   throws UMOException
Specified by:
doDispatch in class AbstractComponent
Throws:
UMOException

doSend

public UMOMessage doSend(UMOEvent event)
                  throws UMOException
Specified by:
doSend in class AbstractComponent
Throws:
UMOException

getQueueSize

public int getQueueSize()

run

public void run()
While the component isn't stopped this runs a continuous loop checking for new events in the queue.

Specified by:
run in interface Runnable

getProxy

protected MuleProxy getProxy()
                      throws Exception
The proxy may be one of three types: 1. pooled 2. not pooled 3. per-request

Throws:
Exception

release

public void release()
Specified by:
release in interface javax.resource.spi.work.Work

enqueue

protected void enqueue(UMOEvent event)
                throws Exception
Throws:
Exception

dequeue

protected UMOEvent dequeue()
                    throws Exception
Throws:
Exception

workAccepted

public void workAccepted(javax.resource.spi.work.WorkEvent event)
Specified by:
workAccepted in interface javax.resource.spi.work.WorkListener

workRejected

public void workRejected(javax.resource.spi.work.WorkEvent event)
This method ensures that any component proxy associated with this rejected work is released.

Specified by:
workRejected in interface javax.resource.spi.work.WorkListener
See Also:
workCompleted(WorkEvent)

workStarted

public void workStarted(javax.resource.spi.work.WorkEvent event)
Specified by:
workStarted in interface javax.resource.spi.work.WorkListener

workCompleted

public void workCompleted(javax.resource.spi.work.WorkEvent event)
There are two units of work that call this method when they complete (regardless of whether or not they incurred an exception): 1) This component's queue listener that processes asynchronous events by scheduling a component proxy 2) Each scheduled component proxy

Generally, #1 occurs each time the component stops and #2 occurs at the end of each asynchronous event.

This method is responsible for handling any exceptions that occur for both #1 and #2 and releasing the proxy from #2.

Specified by:
workCompleted in interface javax.resource.spi.work.WorkListener
See Also:
WorkListener.workCompleted(WorkEvent)

handleWorkException

protected void handleWorkException(javax.resource.spi.work.WorkEvent event,
                                   String type)

getPoolingProfile

public PoolingProfile getPoolingProfile()

setPoolingProfile

public void setPoolingProfile(PoolingProfile poolingProfile)

getQueueProfile

public QueueProfile getQueueProfile()

setQueueProfile

public void setQueueProfile(QueueProfile queueProfile)

doReleaseProxy

protected void doReleaseProxy(MuleProxy proxy)
                       throws Exception
This method is called once when a proxy has finished processing a request (regardless of success). For every call to {@link #getProxy()), there will be a corresponding call to this method. The default behavior is to return the proxy to the pool, dispose of it, or reuse it, depending on the configuration.

NOTE: The implementation of this method must be thread-safe.

Parameters:
proxy - - the proxy that has completed; must be non-null.
Throws:
Exception - - the proxy cannot be released.


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