Class PayloadToMetadataService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.metadata.PayloadToMetadataService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Take the entire payload and store it against a metadata key", tag="service,metadata") public class PayloadToMetadataService extends ServiceImp
Takes the entire payload and writes it out to metadata (either object or normal metadata).If storing to
PayloadToMetadataService.MetadataTarget.Object
then the raw byte[] will be stored in object metadata against the specified key. If storing toPayloadToMetadataService.MetadataTarget.Standard
then the payload will be treated as a String (using the default character set encoding); if storing as standard metadata, then you are encouraged to apply an encoding such as base64 usingsetEncoding(com.adaptris.core.util.EncodingHelper.Encoding)
to make sure that the payload can be treated as a String. The reason for only using the default charset is to avoid complications when the data is actually XML and the encoding specification does not match the message's character set.In the adapter configuration file this class is aliased as payload-to-metadata which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PayloadToMetadataService.MetadataTarget
Enumeration of where the two types of metadata.
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description PayloadToMetadataService()
PayloadToMetadataService(java.lang.String metadataKey, PayloadToMetadataService.MetadataTarget target)
-
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.EncodingHelper.Encoding
getEncoding()
java.lang.String
getKey()
PayloadToMetadataService.MetadataTarget
getMetadataTarget()
protected void
initService()
void
prepare()
Prepare for initialisation.void
setEncoding(EncodingHelper.Encoding enc)
Specify any encoding that should be applied to the payload before setting as metadata.void
setKey(java.lang.String key)
Set the metadata key to store the current payload against.void
setMetadataTarget(PayloadToMetadataService.MetadataTarget t)
-
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, start, stop
-
-
-
-
Constructor Detail
-
PayloadToMetadataService
public PayloadToMetadataService()
-
PayloadToMetadataService
public PayloadToMetadataService(java.lang.String metadataKey, PayloadToMetadataService.MetadataTarget target)
-
-
Method Detail
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:Service
Apply the service to the message.
- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
initService
protected void initService() throws CoreException
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeService
in classServiceImp
-
getMetadataTarget
public PayloadToMetadataService.MetadataTarget getMetadataTarget()
-
setMetadataTarget
public void setMetadataTarget(PayloadToMetadataService.MetadataTarget t)
-
getKey
public java.lang.String getKey()
-
setKey
public void setKey(java.lang.String key)
Set the metadata key to store the current payload against.- Parameters:
key
- the key.
-
getEncoding
public EncodingHelper.Encoding getEncoding()
-
setEncoding
public void setEncoding(EncodingHelper.Encoding enc)
Specify any encoding that should be applied to the payload before setting as metadata.- Parameters:
enc
- the encoding, defaults toEncodingHelper.Encoding.None
.
-
-