Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mule.service
Class AbstractService

    java.lang.Object
      org.mule.service.AbstractService

All Implemented Interfaces:
  Serializable, MuleContextAware, Disposable, Initialisable, Lifecycle, Startable, Stoppable, NamedObject, Service

Direct Known Subclasses:
  DirectService, JcaService, SedaService

    public abstract class AbstractService

extends Object
implements Service

A base implementation for all Services in Mule

See Also:
  Serialized Form

Field Summary
`protected Component` | `component`
`protected ExceptionListener` | `exceptionListener` The exception strategy used by the service.
`protected InboundRouterCollection` | `inboundRouter`
`static String` | `INITIAL_STATE_PAUSED`
`static String` | `INITIAL_STATE_STARTED`
`static String` | `INITIAL_STATE_STOPPED` The initial states that the service can be started in
`protected edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean` | `initialised` Determines if the service has been initilised
`protected String` | `initialState` Determines the initial state of this service when the model starts.
`protected Log` | `logger` logger used by this class
`protected Model` | `model` The model in which this service is registered
`protected MuleContext` | `muleContext`
`protected String` | `name` The service's name
`protected OutboundRouterCollection` | `outboundRouter`
`protected WaitableBoolean` | `paused` Determines if the service has been paused
`protected ResponseRouterCollection` | `responseRouter`
`protected ServiceStatistics` | `stats`
`protected edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean` | `stopped` Determines if the service has been stopped
`protected WaitableBoolean` | `stopping` Determines whether stop has been called and is still in progress

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
`AbstractService()` For Spring only

Method Summary
`protected void` | `connectListeners()`
`protected ServiceStatistics` | `createStatistics()`
`protected void` | `disconnectListeners()`
`void` | `dispatchEvent(MuleEvent event)` Makes an asynchronous event call to the service.
`protected void` | `dispatchToOutboundRouter(MuleEvent event, MuleMessage result)`
`void` | `dispose()` A lifecycle method where implementor should free up any resources.
`protected abstract void` | `doDispatch(MuleEvent event)`
`protected void` | `doDispose()`
`protected void` | `doForceStop()`
`protected void` | `doInitialise()`
`protected void` | `doPause()` Custom components can execute code necessary to put the service in a paused state here.
`protected void` | `doResume()` Custom components can execute code necessary to resume a service once it has been paused If a developer overloads this method the doPause() method MUST also be overloaded to avoid inconsistent state in the service
`protected abstract MuleMessage` | `doSend(MuleEvent event)`
`protected void` | `doStart()`
`protected void` | `doStop()`
`protected void` | `fireServiceNotification(int action)`
`void` | `forceStop()`
`Component` | `getComponent()` Returns the Component that is a invoked by a `Service` for each incoming `MuleEvent` routed on by the `InboundRouterCollection`.
`ExceptionListener` | `getExceptionListener()` The exception strategy to use to handle exceptions in the Mule component.
`InboundRouterCollection` | `getInboundRouter()` Inbound Routers control how events are received by a service.
`protected List` | `getIncomingEndpoints()` Returns a list of all incoming endpoints on a service.
`String` | `getInitialState()` Returns the initial state of this service
`Model` | `getModel()` Returns the name of the model that this descriptor is registered with.
`MuleContext` | `getMuleContext()`
`String` | `getName()` Gets the name of the object
`OutboundRouterCollection` | `getOutboundRouter()` Outbound Routers control how events are published by a service once.
`protected ReplyToHandler` | `getReplyToHandler(MuleMessage message, InboundEndpoint endpoint)`
`ResponseRouterCollection` | `getResponseRouter()` Response Routers control how events are returned in a request/response call.
`ServiceStatistics` | `getStatistics()` Returns the Service statistics.
`protected void` | `handleException(Exception e)`
`void` | `initialise()` Initialise the service.
`protected MuleMessage` | `invokeComponent(MuleEvent event)`
`boolean` | `isPaused()` Determines if the service is in a paused state
`boolean` | `isStarted()` Determines whether this service has been started
`boolean` | `isStopped()`
`boolean` | `isStopping()`
`void` | `pause()` Pauses event processing for a single Mule Service.
`protected MuleMessage` | `processAsyncReplyRouter(MuleMessage result)`
`protected void` | `processReplyTo(MuleEvent event, MuleMessage result, ReplyToHandler replyToHandler, Object replyTo)`
`protected void` | `registerListeners()`
`void` | `resume()` Resumes a single Mule Service that has been paused.
`MuleMessage` | `sendEvent(MuleEvent event)` Makes a synchronous event call to the service.
`protected MuleMessage` | `sendToOutboundRouter(MuleEvent event, MuleMessage result)`
`void` | `setComponent(Component component)` Sets the Component that is a invoked by a `Service` for each incoming `MuleEvent` routed on by the `InboundRouterCollection`.
`void` | `setExceptionListener(ExceptionListener exceptionListener)` The exception strategy to use to handle exceptions in the Mule component.
`void` | `setInboundRouter(InboundRouterCollection inboundRouter)` Inbound Routers control how events are received by a service.
`void` | `setInitialState(String initialState)` Sets the initial state of this service
`void` | `setModel(Model model)`
`void` | `setMuleContext(MuleContext context)`
`void` | `setName(String name)` Sets the name of the object
`void` | `setOutboundRouter(OutboundRouterCollection outboundRouter)` Outbound Routers control how events are published by a service once.
`void` | `setResponseRouter(ResponseRouterCollection responseRouter)` Response Routers control how events are returned in a request/response call.
`void` | `start()`
`protected void` | `start(boolean startPaused)` Starts a Mule Service.
`protected void` | `startListeners()`
`void` | `stop()`
`protected void` | `stopListeners()`
`String` | `toString()`
`protected void` | `unregisterListeners()`
`protected void` | `waitIfPaused(MuleEvent event)` Called before an event is sent or dispatched to a service, 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

### stats

    protected ServiceStatistics stats

### stopped

    protected edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean stopped

  Determines if the service has been stopped

### stopping

    protected WaitableBoolean stopping

  Determines whether stop has been called and is still in progress

### initialised

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

  Determines if the service has been initilised

### model

    protected Model model

  The model in which this service is registered

### paused

    protected WaitableBoolean paused

  Determines if the service has been paused

### muleContext

    protected MuleContext muleContext

### INITIAL_STATE_STOPPED

    public static final String INITIAL_STATE_STOPPED

  The initial states that the service can be started in

  See Also:
    Constant Field Values

### INITIAL_STATE_STARTED

    public static final String INITIAL_STATE_STARTED

See Also:
  Constant Field Values

### INITIAL_STATE_PAUSED

    public static final String INITIAL_STATE_PAUSED

See Also:
  Constant Field Values

### exceptionListener

    protected ExceptionListener exceptionListener

  The exception strategy used by the service.

### name

    protected String name

  The service's name

### inboundRouter

    protected InboundRouterCollection inboundRouter

### outboundRouter

    protected OutboundRouterCollection outboundRouter

### responseRouter

    protected ResponseRouterCollection responseRouter

### initialState

    protected String initialState

  Determines the initial state of this service when the model starts. Can be 'stopped' or 'started' (default)

### component

    protected Component component

Constructor Detail

### AbstractService

    public AbstractService()

  For Spring only

Method Detail

### initialise

    public final void initialise()
                          throws InitialisationException

  Initialise the service. The service will first create a component from the ServiceDescriptor and then initialise a pool based on the attributes in the ServiceDescriptor .

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

### createStatistics

    protected ServiceStatistics createStatistics()

### fireServiceNotification

    protected void fireServiceNotification(int action)

### forceStop

    public void forceStop()
                   throws MuleException

  Throws:
    `MuleException`

### stop

    public void stop()
              throws MuleException

  Specified by:
    `stop` in interface `Stoppable`
  Throws:
    `MuleException`

### start

    public void start()
               throws MuleException

  Specified by:
    `start` in interface `Startable`
  Throws:
    `MuleException`

### start

    protected void start(boolean startPaused)
                  throws MuleException

  Starts a Mule Service.

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

### pause

    public final void pause()
                     throws MuleException

  Pauses event processing for a single Mule Service. Unlike stop(), a paused service will still consume messages from the underlying transport, but those messages will be queued until the service is resumed.

  Specified by:
    `pause` in interface `Service`
  Throws:
    `MuleException`

### resume

    public final void resume()
                      throws MuleException

  Resumes a single Mule Service that has been paused. If the service is not paused nothing is executed.

  Specified by:
    `resume` in interface `Service`
  Throws:
    `MuleException`

### isPaused

    public boolean isPaused()

  Determines if the service is in a paused state

  Specified by:
    `isPaused` in interface `Service`
  Returns:
    True if the service is in a paused state, false otherwise

### doPause

    protected void doPause()
                    throws MuleException

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

  Throws:
    `MuleException`

### doResume

    protected void doResume()
                     throws MuleException

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

  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`

### getStatistics

    public ServiceStatistics getStatistics()

  Description copied from interface: `Service`
  Returns the Service statistics. This provides Service router and component statistics.

  Specified by:
    `getStatistics` in interface `Service`

### dispatchEvent

    public void dispatchEvent(MuleEvent event)
                       throws MuleException

  Description copied from interface: `Service`
  Makes an asynchronous event call to the service.

  Specified by:
    `dispatchEvent` in interface `Service`
  Parameters:
    `event` - the event to consume
  Throws:
    `MuleException` - if the event fails to be processed

### sendEvent

    public MuleMessage sendEvent(MuleEvent event)
                          throws MuleException

  Description copied from interface: `Service`
  Makes a synchronous event call to the service. This event will be consumed by the service and a result returned.

  Specified by:
    `sendEvent` in interface `Service`
  Parameters:
    `event` - the event to consume
  Returns:
    a MuleMessage containing the resulting message and properties
  Throws:
    `MuleException` - if the event fails to be processed

### waitIfPaused

    protected void waitIfPaused(MuleEvent event)
                         throws InterruptedException

  Called before an event is sent or dispatched to a service, 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 service
  Throws:
    `InterruptedException` - if the thread is interrupted

### getName

    public String getName()

  Description copied from interface: `NamedObject`
  Gets the name of the object

  Specified by:
    `getName` in interface `NamedObject`
  Returns:
    the Mule descriptor name which is associated with the service

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### isStopped

    public boolean isStopped()

  Specified by:
    `isStopped` in interface `Service`

### isStopping

    public boolean isStopping()

### handleException

    protected void handleException(Exception e)

### doForceStop

    protected void doForceStop()
                        throws MuleException

  Throws:
    `MuleException`

### doStop

    protected void doStop()
                   throws MuleException

  Throws:
    `MuleException`

### doStart

    protected void doStart()
                    throws MuleException

  Throws:
    `MuleException`

### doDispose

    protected void doDispose()

### doInitialise

    protected void doInitialise()
                         throws InitialisationException

  Throws:
    `InitialisationException`

### isStarted

    public boolean isStarted()

  Description copied from interface: `Service`
  Determines whether this service has been started

  Specified by:
    `isStarted` in interface `Service`
  Returns:
    true is the service is started and ready to receive events

### doSend

    protected abstract MuleMessage doSend(MuleEvent event)
                                   throws MuleException

  Throws:
    `MuleException`

### doDispatch

    protected abstract void doDispatch(MuleEvent event)
                                throws MuleException

  Throws:
    `MuleException`

### registerListeners

    protected void registerListeners()
                              throws MuleException

  Throws:
    `MuleException`

### unregisterListeners

    protected void unregisterListeners()
                                throws MuleException

  Throws:
    `MuleException`

### startListeners

    protected void startListeners()
                           throws MuleException

  Throws:
    `MuleException`

### stopListeners

    protected void stopListeners()
                          throws MuleException

  Throws:
    `MuleException`

### connectListeners

    protected void connectListeners()
                             throws MuleException

  Throws:
    `MuleException`

### disconnectListeners

    protected void disconnectListeners()
                                throws MuleException

  Throws:
    `MuleException`

### getIncomingEndpoints

    protected List getIncomingEndpoints()

  Returns a list of all incoming endpoints on a service.

### setMuleContext

    public void setMuleContext(MuleContext context)

  Specified by:
    `setMuleContext` in interface `MuleContextAware`

### getModel

    public Model getModel()

  Description copied from interface: `Service`
  Returns the name of the model that this descriptor is registered with.

  Specified by:
    `getModel` in interface `Service`
  Returns:
    the name of the model that this descriptor is registered with or null if this descriptor has not been registered with a model yet

### setModel

    public void setModel(Model model)

  Specified by:
    `setModel` in interface `Service`

### getExceptionListener

    public ExceptionListener getExceptionListener()

  Description copied from interface: `Service`
  The exception strategy to use to handle exceptions in the Mule component.

  Specified by:
    `getExceptionListener` in interface `Service`
  Returns:
    the exception strategy to use. If none has been set a default will be used.

### setExceptionListener

    public void setExceptionListener(ExceptionListener exceptionListener)

  Description copied from interface: `Service`
  The exception strategy to use to handle exceptions in the Mule component.

  Specified by:
    `setExceptionListener` in interface `Service`
  Parameters:
    `exceptionListener` - the exception strategy to use. If none has been set or argument is null a default

### getInboundRouter

    public InboundRouterCollection getInboundRouter()

  Description copied from interface: `Service`
  Inbound Routers control how events are received by a service. If no router is set. A default will be used that uses the inboundProvider set on his descriptor.

  Specified by:
    `getInboundRouter` in interface `Service`
  Returns:
    the inbound router for this service. This will always return a valid router.
  See Also:
    `InboundRouterCollection`

### setInboundRouter

    public void setInboundRouter(InboundRouterCollection inboundRouter)

  Description copied from interface: `Service`
  Inbound Routers control how events are received by a service. If no router is set. A default will be used that uses the inboundProvider set on his descriptor.

  Specified by:
    `setInboundRouter` in interface `Service`
  Parameters:
    `inboundRouter` - the inbound router for this service
  See Also:
    `InboundRouterCollection`

### getOutboundRouter

    public OutboundRouterCollection getOutboundRouter()

  Description copied from interface: `Service`
  Outbound Routers control how events are published by a service once. the event has been processed. If no router is set. A default will be used that uses the outboundProvider set on his descriptor to route the event.

  Specified by:
    `getOutboundRouter` in interface `Service`
  Returns:
    the outbound router for this service
  See Also:
    `OutboundRouterCollection`

### setOutboundRouter

    public void setOutboundRouter(OutboundRouterCollection outboundRouter)

  Description copied from interface: `Service`
  Outbound Routers control how events are published by a service once. the event has been processed. If no router is set. A default will be used that uses the outboundProvider set on his descriptor to route the event.

  Specified by:
    `setOutboundRouter` in interface `Service`
  Parameters:
    `outboundRouter` - the outbound router for this service
  See Also:
    `OutboundRouterCollection`

### getResponseRouter

    public ResponseRouterCollection getResponseRouter()

  Description copied from interface: `Service`
  Response Routers control how events are returned in a request/response call. It can be use to aggregate response events before returning, thus acting as a Join in a forked process. This can be used to make request/response calls a lot more efficient as independent tasks can be forked, execute concurrently and then join before the request completes

  Specified by:
    `getResponseRouter` in interface `Service`
  Returns:
    the response router for this service
  See Also:
    `ResponseRouterCollection`

### setResponseRouter

    public void setResponseRouter(ResponseRouterCollection responseRouter)

  Description copied from interface: `Service`
  Response Routers control how events are returned in a request/response call. It can be use to aggregate response events before returning, thus acting as a Join in a forked process. This can be used to make request/response calls a lot more efficient as independent tasks can be forked, execute concurrently and then join before the request completes

  Specified by:
    `setResponseRouter` in interface `Service`
  Parameters:
    `responseRouter` - the response router for this service
  See Also:
    `ResponseRouterCollection`

### getInitialState

    public String getInitialState()

  Description copied from interface: `Service`
  Returns the initial state of this service

  Specified by:
    `getInitialState` in interface `Service`
  Returns:
    the initial state of this service

### setInitialState

    public void setInitialState(String initialState)

  Description copied from interface: `Service`
  Sets the initial state of this service

  Specified by:
    `setInitialState` in interface `Service`
  Parameters:
    `initialState` - the initial state of this service

### setName

    public void setName(String name)

  Description copied from interface: `NamedObject`
  Sets the name of the object

  Specified by:
    `setName` in interface `NamedObject`
  Parameters:
    `name` - the name of the object

### getComponent

    public Component getComponent()

  Description copied from interface: `Service`
  Returns the Component that is a invoked by a `Service` for each incoming `MuleEvent` routed on by the `InboundRouterCollection`.

  Specified by:
    `getComponent` in interface `Service`

### setComponent

    public void setComponent(Component component)

  Description copied from interface: `Service`
  Sets the Component that is a invoked by a `Service` for each incoming `MuleEvent` routed on by the `InboundRouterCollection`.

  Specified by:
    `setComponent` in interface `Service`

### processReplyTo

    protected void processReplyTo(MuleEvent event,
                                  MuleMessage result,
                                  ReplyToHandler replyToHandler,
                                  Object replyTo)
                           throws MuleException

  Throws:
    `MuleException`

### getReplyToHandler

    protected ReplyToHandler getReplyToHandler(MuleMessage message,
                                               InboundEndpoint endpoint)

### dispatchToOutboundRouter

    protected void dispatchToOutboundRouter(MuleEvent event,
                                            MuleMessage result)
                                     throws MessagingException

  Throws:
    `MessagingException`

### sendToOutboundRouter

    protected MuleMessage sendToOutboundRouter(MuleEvent event,
                                               MuleMessage result)
                                        throws MessagingException

  Throws:
    `MessagingException`

### processAsyncReplyRouter

    protected MuleMessage processAsyncReplyRouter(MuleMessage result)
                                           throws MuleException

  Throws:
    `MuleException`

### invokeComponent

    protected MuleMessage invokeComponent(MuleEvent event)
                                   throws MuleException

  Throws:
    `MuleException`

### getMuleContext

    public MuleContext getMuleContext()

  Specified by:
    `getMuleContext` in interface `Service`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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