Class DynamicServiceExecutor
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.dynamic.DynamicServiceExecutor
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,EventHandlerAware
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Lookup and execute a dynamic service", tag="service,dynamic") public class DynamicServiceExecutor extends ServiceImp implements EventHandlerAware
Implementation ofService
which dynamically obtains and applies aService
to anAdaptrisMessage
based on the contents of the message.This class will attempt to extract a marshalled service from the specified location (which might be the current message), unmarshal that service, and then execute that service against the current message. The use of this type of service is discouraged from a supportability perspective; however there will be use cases where it is appropriate. No checks are performed on the
Service
that is unmarshalled; any exceptions thrown by unmarshalled service are simply rethrown back to the workflow for standard message error handling.- See Also:
ServiceExtractor
In the adapter configuration file this class is aliased as dynamic-service-executor 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 DynamicServiceExecutor()
DynamicServiceExecutor(ServiceExtractor se)
-
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.AdaptrisMarshaller
getMarshaller()
ServiceExtractor
getServiceExtractor()
java.lang.Boolean
getTreatNotFoundAsError()
protected void
initService()
void
prepare()
Prepare for initialisation.void
registerEventHandler(EventHandler eh)
Register the current event handler against this component.void
setMarshaller(AdaptrisMarshaller m)
Set the marshaller to use to unmarshal the service.void
setServiceExtractor(ServiceExtractor s)
Set theServiceExtractor
implementation used to extract the service from the message.void
setTreatNotFoundAsError(java.lang.Boolean b)
Specify whether a failure to find a dynamic service is treated as an exception.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
-
-
-
-
Constructor Detail
-
DynamicServiceExecutor
public DynamicServiceExecutor()
-
DynamicServiceExecutor
public DynamicServiceExecutor(ServiceExtractor se)
-
-
Method Detail
-
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
-
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
-
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.
-
getServiceExtractor
public ServiceExtractor getServiceExtractor()
-
setServiceExtractor
public void setServiceExtractor(ServiceExtractor s)
Set theServiceExtractor
implementation used to extract the service from the message.- Parameters:
s
- the service extractor implementation, the default isDefaultServiceExtractor
-
getMarshaller
public AdaptrisMarshaller getMarshaller()
-
setMarshaller
public void setMarshaller(AdaptrisMarshaller m)
Set the marshaller to use to unmarshal the service.- Parameters:
m
- the marshaller, if not configured will default toDefaultMarshaller.getDefaultMarshaller()
-
getTreatNotFoundAsError
public java.lang.Boolean getTreatNotFoundAsError()
-
setTreatNotFoundAsError
public void setTreatNotFoundAsError(java.lang.Boolean b)
Specify whether a failure to find a dynamic service is treated as an exception.- Parameters:
b
- true to treat failures to unmarshal / find the service as an exception; default is true if not specified
-
-