Class IfElse
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.conditional.IfElse
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,Service
,StateManagedComponent
@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.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description IfElse()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
-
-
-
Method Detail
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:Service
Apply the service to the message.
- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
initService
protected void initService() throws CoreException
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeService
in classServiceImp
-
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
-
getCondition
public Condition getCondition()
-
setCondition
public void setCondition(Condition condition)
Set the conditions to apply.- Parameters:
condition
-
-
condition
protected Condition condition()
-
getThen
public ThenService getThen()
-
setThen
public void setThen(ThenService thenService)
-
getOtherwise
public ElseService getOtherwise()
-
setOtherwise
public void setOtherwise(ElseService elseService)
-
-