@ComponentProfile(summary="Lookup and execute a dynamic service", tag="service,dynamic") public class DynamicServiceExecutor extends ServiceImp implements EventHandlerAware
Service
which dynamically obtains and applies a
Service
to an AdaptrisMessage
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.
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.
log
Constructor and Description |
---|
DynamicServiceExecutor() |
DynamicServiceExecutor(ServiceExtractor se) |
Modifier and Type | Method and 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 the
ServiceExtractor 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
|
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
public DynamicServiceExecutor()
public DynamicServiceExecutor(ServiceExtractor se)
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
sprotected 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 registerEventHandler(EventHandler eh)
EventHandlerAware
registerEventHandler
in interface EventHandlerAware
eh
- the event handler currently in use.public ServiceExtractor getServiceExtractor()
public void setServiceExtractor(ServiceExtractor s)
ServiceExtractor
implementation used to extract the service from the message.s
- the service extractor implementation, the default is DefaultServiceExtractor
public AdaptrisMarshaller getMarshaller()
public void setMarshaller(AdaptrisMarshaller m)
m
- the marshaller, if not configured will default to
DefaultMarshaller.getDefaultMarshaller()
public java.lang.Boolean getTreatNotFoundAsError()
public void setTreatNotFoundAsError(java.lang.Boolean b)
b
- true to treat failures to unmarshal / find the service as an exception; default is
true if not specified