org.mule.component
Class AbstractComponent

java.lang.Object
  extended by org.mule.component.AbstractComponent
All Implemented Interfaces:
Component, MuleContextAware, Interceptor, Disposable, Initialisable, Lifecycle, Startable, Stoppable
Direct Known Subclasses:
AbstractJavaComponent, AbstractWebServiceWrapperComponent, PassThroughComponent, ProcessComponent, RestServiceWrapper, ScriptComponent

public abstract class AbstractComponent
extends Object
implements Component, Interceptor, MuleContextAware

Abstract Component to be used by all Component implementations.


Field Summary
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean disposed
           
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean disposing
           
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean initialised
           
protected  List interceptors
           
protected  Log logger
          logger used by this class
protected  MuleContext muleContext
           
protected  ServerNotificationHandler notificationHandler
           
protected  Service service
           
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean started
           
protected  ComponentStatistics statistics
           
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean stopping
           
 
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
AbstractComponent()
           
 
Method Summary
protected  void checkDisposed()
           
protected  MuleMessage createResultMessage(MuleEvent event, Object result)
           
 void dispose()
          A lifecycle method where implementor should free up any resources.
protected  void doDispose()
           
protected  void doInitialise()
           
protected abstract  Object doInvoke(MuleEvent event)
           
protected  void doStart()
           
protected  void doStop()
           
protected  void fireComponentNotification(MuleMessage message, int action)
           
 List getInterceptors()
           
 Service getService()
           
 ComponentStatistics getStatistics()
          Component statistics are used to gather component statistics such as sync/async invocation counts and total and average execution time.
 void initialise()
          Method used to perform any initialisation work.
 MuleMessage intercept(Invocation invocation)
          Invoked when the component should be called.
 MuleMessage invoke(MuleEvent event)
          Invokes the component
 void release()
           
 void setInterceptors(List interceptors)
           
 void setMuleContext(MuleContext context)
           
 void setService(Service service)
           
 void start()
           
 void stop()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected final Log logger
logger used by this class


service

protected Service service

statistics

protected ComponentStatistics statistics

started

protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean started

stopping

protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean stopping

initialised

protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean initialised

disposing

protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean disposing

disposed

protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean disposed

notificationHandler

protected ServerNotificationHandler notificationHandler

interceptors

protected List interceptors

muleContext

protected MuleContext muleContext
Constructor Detail

AbstractComponent

public AbstractComponent()
Method Detail

setMuleContext

public void setMuleContext(MuleContext context)
Specified by:
setMuleContext in interface MuleContextAware

getInterceptors

public List getInterceptors()

setInterceptors

public void setInterceptors(List interceptors)

intercept

public MuleMessage intercept(Invocation invocation)
                      throws MuleException
Description copied from interface: Interceptor
Invoked when the component should be called. The implementation can call Invocation#execute() to call the component.

Specified by:
intercept in interface Interceptor
Parameters:
invocation - the invocation containing info about the current message and service
Returns:
A result message that may have been altered by this invocation
Throws:
MuleException - if the invocation fails

invoke

public MuleMessage invoke(MuleEvent event)
                   throws MuleException
Description copied from interface: Component
Invokes the component

Specified by:
invoke in interface Component
Parameters:
event - the event used to invoke the component
Returns:
the return event from the component
Throws:
MuleException - if the call fails

createResultMessage

protected MuleMessage createResultMessage(MuleEvent event,
                                          Object result)
                                   throws TransformerException
Throws:
TransformerException

doInvoke

protected abstract Object doInvoke(MuleEvent event)
                            throws Exception
Throws:
Exception

toString

public String toString()
Overrides:
toString in class Object

release

public void release()

getStatistics

public ComponentStatistics getStatistics()
Description copied from interface: Component
Component statistics are used to gather component statistics such as sync/async invocation counts and total and average execution time.

Specified by:
getStatistics in interface Component
Returns:

setService

public void setService(Service service)
Specified by:
setService in interface Component

getService

public Service getService()
Specified by:
getService in interface Component
Returns:

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

doInitialise

protected void doInitialise()
                     throws InitialisationException
Throws:
InitialisationException

dispose

public 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

doDispose

protected void doDispose()

stop

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

doStart

protected void doStart()
                throws MuleException
Throws:
MuleException

start

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

doStop

protected void doStop()
               throws MuleException
Throws:
MuleException

checkDisposed

protected void checkDisposed()
                      throws DisposeException
Throws:
DisposeException

fireComponentNotification

protected void fireComponentNotification(MuleMessage message,
                                         int action)


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