Class BranchingServiceEnabler
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.BranchingServiceImp
-
- com.adaptris.core.services.BranchingServiceEnabler
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,EventHandlerAware
,MessageEventGenerator
,Service
,ServiceWrapper
,StateManagedComponent
@ComponentProfile(summary="Wraps another service, performing a branch based on its success", tag="service, branching", branchSelector=true) public class BranchingServiceEnabler extends BranchingServiceImp implements EventHandlerAware, ServiceWrapper
Service that wraps other services allowing them to be branching.This is somewhat analogous to
ExceptionHandlingServiceWrapper
but fits a more generalised use case. In the event of an Exception;getFailureId()
is always set as theAdaptrisMessage.setNextServiceId(String)
. In the event of a successfull execution then if the wrapped service is already branching thenAdaptrisMessage.setNextServiceId(String)
is untouched; otherwisegetSuccessId()
is used.- Since:
- 3.4.1
In the adapter configuration file this class is aliased as branching-service-enabler which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description BranchingServiceEnabler()
BranchingServiceEnabler(Service s)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeService()
void
doService(AdaptrisMessage msg)
Apply the service to the message.java.lang.String
getFailureId()
Service
getService()
java.lang.String
getSuccessId()
protected void
initService()
void
prepare()
Prepare for initialisation.void
registerEventHandler(EventHandler eh)
Register the current event handler against this component.void
setFailureId(java.lang.String s)
void
setService(Service s)
void
setSuccessId(java.lang.String s)
void
start()
Starts the component.void
stop()
Stop the componentService[]
wrappedServices()
Return all the services that are wrapped by this service.-
Methods inherited from class com.adaptris.core.BranchingServiceImp
isBranching
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, isBranching, setUniqueId
-
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
-
-
-
Constructor Detail
-
BranchingServiceEnabler
public BranchingServiceEnabler()
-
BranchingServiceEnabler
public BranchingServiceEnabler(Service s)
-
-
Method Detail
-
initService
protected void initService() throws CoreException
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.- Specified by:
start
in interfaceComponentLifecycle
- Overrides:
start
in classServiceImp
- Throws:
CoreException
- wrapping any underlyingException
s
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing aRuntimeException
may cause unintended consequences- Specified by:
stop
in interfaceComponentLifecycle
- Overrides:
stop
in classServiceImp
-
closeService
protected void closeService()
- Specified by:
closeService
in classServiceImp
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:Service
Apply the service to the message.
- Specified by:
doService
in interfaceService
- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s
-
getService
public Service getService()
- Returns:
- the wrappedService
-
setService
public void setService(Service s)
- Parameters:
s
- the wrappedService to set
-
getFailureId
public java.lang.String getFailureId()
- Returns:
- the failId
-
setFailureId
public void setFailureId(java.lang.String s)
- Parameters:
s
- the failId to set
-
getSuccessId
public java.lang.String getSuccessId()
- Returns:
- the successId
-
setSuccessId
public void setSuccessId(java.lang.String s)
- Parameters:
s
- the successId to set
-
registerEventHandler
public void registerEventHandler(EventHandler eh)
Description copied from interface:EventHandlerAware
Register the current event handler against this component.- Specified by:
registerEventHandler
in interfaceEventHandlerAware
- Parameters:
eh
- the event handler currently in use.
-
wrappedServices
public Service[] wrappedServices()
Description copied from interface:ServiceWrapper
Return all the services that are wrapped by this service.- Specified by:
wrappedServices
in interfaceServiceWrapper
- Returns:
- an array of wrapped services.
-
-