|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mule.service.AbstractService
public abstract class AbstractService
A base implementation for all Services in Mule
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)
Sets the Model name that this descriptor is registered within. |
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 |
---|
protected transient Log logger
protected ServiceStatistics stats
protected edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean stopped
protected WaitableBoolean stopping
protected edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean initialised
protected Model model
protected WaitableBoolean paused
protected MuleContext muleContext
public static final String INITIAL_STATE_STOPPED
public static final String INITIAL_STATE_STARTED
public static final String INITIAL_STATE_PAUSED
protected ExceptionListener exceptionListener
protected String name
protected InboundRouterCollection inboundRouter
protected OutboundRouterCollection outboundRouter
protected ResponseRouterCollection responseRouter
protected String initialState
protected Component component
Constructor Detail |
---|
public AbstractService()
Method Detail |
---|
public final void initialise() throws InitialisationException
initialise
in interface Initialisable
InitialisationException
- if the service fails
to initialise
RecoverableException
- if an error occurs that can be recovered fromprotected ServiceStatistics createStatistics()
protected void fireServiceNotification(int action)
public void forceStop() throws MuleException
MuleException
public void stop() throws MuleException
stop
in interface Stoppable
MuleException
public void start() throws MuleException
start
in interface Startable
MuleException
protected void start(boolean startPaused) throws MuleException
startPaused
- - Start service in a "paused" state (messages are
received but not processed).
MuleException
public final void pause() throws MuleException
pause
in interface Service
MuleException
public final void resume() throws MuleException
resume
in interface Service
MuleException
public boolean isPaused()
isPaused
in interface Service
protected void doPause() throws MuleException
MuleException
protected void doResume() throws MuleException
MuleException
public final void dispose()
Disposable
dispose
in interface Disposable
public ServiceStatistics getStatistics()
Service
getStatistics
in interface Service
public void dispatchEvent(MuleEvent event) throws MuleException
Service
dispatchEvent
in interface Service
event
- the event to consume
MuleException
- if the event fails to be processedpublic MuleMessage sendEvent(MuleEvent event) throws MuleException
Service
sendEvent
in interface Service
event
- the event to consume
MuleException
- if the event fails to be processedprotected void waitIfPaused(MuleEvent event) throws InterruptedException
event
- the current event being passed to the service
InterruptedException
- if the thread is interruptedpublic String getName()
NamedObject
getName
in interface NamedObject
public String toString()
toString
in class Object
public boolean isStopped()
public boolean isStopping()
protected void handleException(Exception e)
protected void doForceStop() throws MuleException
MuleException
protected void doStop() throws MuleException
MuleException
protected void doStart() throws MuleException
MuleException
protected void doDispose()
protected void doInitialise() throws InitialisationException
InitialisationException
public boolean isStarted()
Service
isStarted
in interface Service
protected abstract MuleMessage doSend(MuleEvent event) throws MuleException
MuleException
protected abstract void doDispatch(MuleEvent event) throws MuleException
MuleException
protected void registerListeners() throws MuleException
MuleException
protected void unregisterListeners() throws MuleException
MuleException
protected void startListeners() throws MuleException
MuleException
protected void stopListeners() throws MuleException
MuleException
protected void connectListeners() throws MuleException
MuleException
protected void disconnectListeners() throws MuleException
MuleException
protected List getIncomingEndpoints()
public void setMuleContext(MuleContext context)
setMuleContext
in interface MuleContextAware
public Model getModel()
Service
getModel
in interface Service
public void setModel(Model model)
Service
setModel
in interface Service
public ExceptionListener getExceptionListener()
Service
getExceptionListener
in interface Service
public void setExceptionListener(ExceptionListener exceptionListener)
Service
setExceptionListener
in interface Service
exceptionListener
- the exception strategy to use. If none has been set or
argument is null a defaultpublic InboundRouterCollection getInboundRouter()
Service
getInboundRouter
in interface Service
InboundRouterCollection
public void setInboundRouter(InboundRouterCollection inboundRouter)
Service
setInboundRouter
in interface Service
inboundRouter
- the inbound router for this serviceInboundRouterCollection
public OutboundRouterCollection getOutboundRouter()
Service
getOutboundRouter
in interface Service
OutboundRouterCollection
public void setOutboundRouter(OutboundRouterCollection outboundRouter)
Service
setOutboundRouter
in interface Service
outboundRouter
- the outbound router for this serviceOutboundRouterCollection
public ResponseRouterCollection getResponseRouter()
Service
getResponseRouter
in interface Service
ResponseRouterCollection
public void setResponseRouter(ResponseRouterCollection responseRouter)
Service
setResponseRouter
in interface Service
responseRouter
- the response router for this serviceResponseRouterCollection
public String getInitialState()
Service
getInitialState
in interface Service
public void setInitialState(String initialState)
Service
setInitialState
in interface Service
initialState
- the initial state of this serviceorg.mule.ImmutableMuleDescriptor#INITIAL_STATE_STARTED
,
org.mule.ImmutableMuleDescriptor#INITIAL_STATE_STOPPED
,
org.mule.ImmutableMuleDescriptor#INITIAL_STATE_PAUSED
public void setName(String name)
NamedObject
setName
in interface NamedObject
name
- the name of the objectpublic Component getComponent()
Service
Service
for each incoming
MuleEvent
routed on by the InboundRouterCollection
.
getComponent
in interface Service
public void setComponent(Component component)
Service
Service
for each incoming
MuleEvent
routed on by the InboundRouterCollection
.
setComponent
in interface Service
protected void processReplyTo(MuleEvent event, MuleMessage result, ReplyToHandler replyToHandler, Object replyTo) throws MuleException
MuleException
protected ReplyToHandler getReplyToHandler(MuleMessage message, InboundEndpoint endpoint)
protected void dispatchToOutboundRouter(MuleEvent event, MuleMessage result) throws MessagingException
MessagingException
protected MuleMessage sendToOutboundRouter(MuleEvent event, MuleMessage result) throws MessagingException
MessagingException
protected MuleMessage processAsyncReplyRouter(MuleMessage result) throws MuleException
MuleException
protected MuleMessage invokeComponent(MuleEvent event) throws MuleException
MuleException
public MuleContext getMuleContext()
getMuleContext
in interface Service
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |