Class DynamicServiceExecutor
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,EventHandlerAware
,MessageEventGenerator
,Service
,StateManagedComponent
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.
- See Also:
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
doService
(AdaptrisMessage msg) Apply the service to the message.protected void
void
prepare()
Prepare for initialisation.void
Register the current event handler against this component.void
Set the marshaller to use to unmarshal the service.void
Set theServiceExtractor
implementation used to extract the service from the message.void
Specify whether a failure to find a dynamic service is treated as an exception.void
start()
Starts the component.void
stop()
Stop the componentMethods 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 Details
-
DynamicServiceExecutor
public DynamicServiceExecutor() -
DynamicServiceExecutor
-
-
Method Details
-
doService
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
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
start
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
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
registerEventHandler
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
-
setServiceExtractor
Set theServiceExtractor
implementation used to extract the service from the message.- Parameters:
s
- the service extractor implementation, the default isDefaultServiceExtractor
-
getMarshaller
-
setMarshaller
Set the marshaller to use to unmarshal the service.- Parameters:
m
- the marshaller, if not configured will default toDefaultMarshaller.getDefaultMarshaller()
-
getTreatNotFoundAsError
-
setTreatNotFoundAsError
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
-