@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
This is somewhat analogous to ExceptionHandlingServiceWrapper
but fits a more
generalised use case. In the event of an Exception; getFailureId()
is always set as the
AdaptrisMessage.setNextServiceId(String)
. In the event of a successfull execution then if the wrapped service is already
branching then AdaptrisMessage.setNextServiceId(String)
is untouched; otherwise getSuccessId()
is used.
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.
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
BranchingServiceEnabler() |
BranchingServiceEnabler(Service s) |
Modifier and Type | Method and 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 component
|
Service[] |
wrappedServices()
Return all the services that are wrapped by this service.
|
isBranching
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getLookupName, getUniqueId, init, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setLookupName, setUniqueId
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
continueOnFailure, isBranching, setUniqueId
createName, createQualifier, isTrackingEndpoint
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
getUniqueId
close, init
getLookupName
public BranchingServiceEnabler()
public BranchingServiceEnabler(Service s)
protected void initService() throws CoreException
initService
in class ServiceImp
CoreException
public void start() throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer
, calling start
will begin message delivery.
start
in interface ComponentLifecycle
start
in class ServiceImp
CoreException
- wrapping any underlying Exception
spublic void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer
, calling stop
will pause message delivery. Throwing a RuntimeException
may cause unintended consequences
stop
in interface ComponentLifecycle
stop
in class ServiceImp
protected void closeService()
closeService
in class ServiceImp
public void prepare() throws CoreException
ComponentLifecycleExtension
prepare
in interface ComponentLifecycleExtension
CoreException
public void doService(AdaptrisMessage msg) throws ServiceException
Service
Apply the service to the message.
doService
in interface Service
msg
- the AdaptrisMessage
to processServiceException
- wrapping any underlying Exception
spublic Service getService()
public void setService(Service s)
s
- the wrappedService to setpublic java.lang.String getFailureId()
public void setFailureId(java.lang.String s)
s
- the failId to setpublic java.lang.String getSuccessId()
public void setSuccessId(java.lang.String s)
s
- the successId to setpublic void registerEventHandler(EventHandler eh)
EventHandlerAware
registerEventHandler
in interface EventHandlerAware
eh
- the event handler currently in use.public Service[] wrappedServices()
ServiceWrapper
wrappedServices
in interface ServiceWrapper