Class ExceptionHandlingServiceWrapper
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,ConfigComment
,EventHandlerAware
,MessageEventGenerator
,Service
,ServiceWrapper
,StateManagedComponent
This Service wraps a Service
; if this wrapped Service throws a ServiceException the configured exceptionHandlingService
is applied. Normal message error handling is not triggered unless an exception is thrown from the service handling the exception.
This Service is intended for use where an exception processing a message should generate a synchronous reply e.g. when processing web service requests. It could be used where detailed information about the error is required to be sent as part of the reply. This can be acheived by configuring services as part of the exceptionHandlingService.
Note that the exception handling service will process the message IN THE STATE AT WHICH IT FAILED (i.e. the payload of the
message may have been modified). It might not be possible to recover any meaningful data from this if say, an exception is
triggered after encrypting the data with a remote party's public key. If you wish to use process the original message then you
should configure a StandardProcessingExceptionHandler
at the workflow level.
StandardProcessingExceptionHandler
allows you to configure arbitrary services to perform operations on
messages that have failed.
In the adapter configuration file this class is aliased as exception-handling-service-wrapper 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.Returns the Service to call if an exception is encountered calling the wrapped Service.Returns the metadata key to store the exception message against.Returns the Service to wrap.protected void
void
prepare()
Prepare for initialisation.void
Register the current event handler against this component.void
Sets the Service to call if an exception is encountered calling the wrapped Service.void
Sets the metadata key to store the exception message against.void
Sets the Service to wrap.void
start()
Starts the component.void
stop()
Stop the componentService[]
Return all the services that are wrapped by this service.Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getComments, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setComments, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
Methods inherited from interface com.adaptris.core.ConfigComment
getComments, setComments
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, isBranching, setUniqueId
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
Field Details
-
DEFAULT_EXCEPTION_MESSAGE_METADATA_KEY
- See Also:
-
-
Constructor Details
-
ExceptionHandlingServiceWrapper
public ExceptionHandlingServiceWrapper()Creates a new instance.
-
-
Method Details
-
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.
-
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- See Also:
-
initService
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
closeService
protected void closeService()- Specified by:
closeService
in classServiceImp
-
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
- See Also:
-
getService
Returns the Service to wrap.- Returns:
- the Service to wrap
-
setService
Sets the Service to wrap.- Parameters:
s
- the Service to wrap
-
getExceptionHandlingService
Returns the Service to call if an exception is encountered calling the wrapped Service.- Returns:
- the Service to call if an exception is encountered calling the wrapped Service
-
setExceptionHandlingService
Sets the Service to call if an exception is encountered calling the wrapped Service.- Parameters:
s
- the Service to call if an exception is encountered calling the wrapped Service
-
getExceptionMessageMetadataKey
Returns the metadata key to store the exception message against. Default isadp.exception.wrapper.message
.- Returns:
- the metadata key to store the exception message against
-
setExceptionMessageMetadataKey
Sets the metadata key to store the exception message against.- Parameters:
s
- the metadata key to store the exception message against
-
prepare
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
wrappedServices
Description copied from interface:ServiceWrapper
Return all the services that are wrapped by this service.- Specified by:
wrappedServices
in interfaceServiceWrapper
- Returns:
- an array of wrapped services.
-