@ComponentProfile(summary="Runs the configured service/list \'IF\' the configured condition is met, otherwise will run the \'else\' service/list.", tag="service, conditional", since="3.7.3") public class IfElse extends ServiceImp
This Service
allows you to test boolean (true or false) Condition
's, which if evaluate to "true" will run a configured set of services, otherwise run a different set of services.
Note, that although you must specify a service or list of services should the configured conditions pass, you do not have to configure services to run should the conditions fail.
Typically your Condition
will test for equality, in-line expressions or whether values exist or not. The values to test will generally come from the payload or message metadata.
Also note that some conditions can be nested, such that you can test that a value is equal to another AND / OR a value is equal/not to another value.
log
Constructor and Description |
---|
IfElse() |
Modifier and Type | Method and Description |
---|---|
protected void |
closeService() |
protected Condition |
condition() |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
Condition |
getCondition() |
ElseService |
getOtherwise() |
ThenService |
getThen() |
protected void |
initService() |
void |
prepare()
Prepare for initialisation.
|
void |
setCondition(Condition condition)
Set the conditions to apply.
|
void |
setOtherwise(ElseService elseService) |
void |
setThen(ThenService thenService) |
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
public void doService(AdaptrisMessage msg) throws ServiceException
Service
Apply the service to the message.
msg
- the AdaptrisMessage
to processServiceException
- wrapping any underlying Exception
spublic void prepare() throws CoreException
ComponentLifecycleExtension
CoreException
protected void initService() throws CoreException
initService
in class ServiceImp
CoreException
protected void closeService()
closeService
in class ServiceImp
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
public Condition getCondition()
public void setCondition(Condition condition)
condition
- protected Condition condition()
public ThenService getThen()
public void setThen(ThenService thenService)
public ElseService getOtherwise()
public void setOtherwise(ElseService elseService)