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 EventHandlerAwareImplementation ofServicewhich dynamically obtains and applies aServiceto anAdaptrisMessagebased 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
Servicethat 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 voidcloseService()voiddoService(AdaptrisMessage msg)Apply the service to the message.AdaptrisMarshallergetMarshaller()ServiceExtractorgetServiceExtractor()java.lang.BooleangetTreatNotFoundAsError()protected voidinitService()voidprepare()Prepare for initialisation.voidregisterEventHandler(EventHandler eh)Register the current event handler against this component.voidsetMarshaller(AdaptrisMarshaller m)Set the marshaller to use to unmarshal the service.voidsetServiceExtractor(ServiceExtractor s)Set theServiceExtractorimplementation used to extract the service from the message.voidsetTreatNotFoundAsError(java.lang.Boolean b)Specify whether a failure to find a dynamic service is treated as an exception.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
-
-
-
-
Constructor Detail
-
DynamicServiceExecutor
public DynamicServiceExecutor()
-
DynamicServiceExecutor
public DynamicServiceExecutor(ServiceExtractor se)
-
-
Method Detail
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:ServiceApply the service to the message.
- Specified by:
doServicein interfaceService- Parameters:
msg- theAdaptrisMessageto process- Throws:
ServiceException- wrapping any underlyingExceptions
-
initService
protected void initService() throws CoreException- Specified by:
initServicein classServiceImp- Throws:
CoreException
-
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
-
closeService
protected void closeService()
- Specified by:
closeServicein classServiceImp
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Specified by:
preparein interfaceComponentLifecycleExtension- Throws:
CoreException
-
registerEventHandler
public void registerEventHandler(EventHandler eh)
Description copied from interface:EventHandlerAwareRegister the current event handler against this component.- Specified by:
registerEventHandlerin interfaceEventHandlerAware- Parameters:
eh- the event handler currently in use.
-
getServiceExtractor
public ServiceExtractor getServiceExtractor()
-
setServiceExtractor
public void setServiceExtractor(ServiceExtractor s)
Set theServiceExtractorimplementation 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
-
-