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 ServiceImpThis
Serviceallows 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
Conditionwill 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 voidcloseService()protected Conditioncondition()voiddoService(AdaptrisMessage msg)Apply the service to the message.ConditiongetCondition()ElseServicegetOtherwise()ThenServicegetThen()protected voidinitService()voidprepare()Prepare for initialisation.voidsetCondition(Condition condition)Set the conditions to apply.voidsetOtherwise(ElseService elseService)voidsetThen(ThenService thenService)voidstart()Starts the component.voidstop()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:ServiceApply the service to the message.
- Parameters:
msg- theAdaptrisMessageto process- Throws:
ServiceException- wrapping any underlyingExceptions
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Throws:
CoreException
-
initService
protected void initService() throws CoreException- Specified by:
initServicein classServiceImp- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeServicein classServiceImp
-
start
public void start() throws CoreExceptionDescription copied from interface:ComponentLifecycleStarts 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:
startin interfaceComponentLifecycle- Overrides:
startin classServiceImp- Throws:
CoreException- wrapping any underlyingExceptions
-
stop
public void stop()
Description copied from interface:ComponentLifecycleStop 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 aRuntimeExceptionmay cause unintended consequences- Specified by:
stopin interfaceComponentLifecycle- Overrides:
stopin 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)
-
-