@ComponentProfile(summary="Take the entire payload and store it against a metadata key", tag="service,metadata") public class PayloadToMetadataService extends ServiceImp
If storing to PayloadToMetadataService.MetadataTarget.Object
then the raw byte[] will be stored in object metadata against the specified key.
If storing to PayloadToMetadataService.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 using setEncoding(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.
Modifier and Type | Class and Description |
---|---|
static class |
PayloadToMetadataService.Encoding
The types of encoding supported.
|
static class |
PayloadToMetadataService.MetadataTarget
Enumeration of where the two types of metadata.
|
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
PayloadToMetadataService() |
PayloadToMetadataService(java.lang.String metadataKey,
PayloadToMetadataService.MetadataTarget target) |
Modifier and Type | Method and Description |
---|---|
protected void |
closeService() |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
PayloadToMetadataService.Encoding |
getEncoding() |
java.lang.String |
getKey() |
PayloadToMetadataService.MetadataTarget |
getMetadataTarget() |
protected void |
initService() |
void |
prepare()
Prepare for initialisation.
|
void |
setEncoding(PayloadToMetadataService.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) |
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getLookupName, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setLookupName, setUniqueId, start, stop
public PayloadToMetadataService()
public PayloadToMetadataService(java.lang.String metadataKey, PayloadToMetadataService.MetadataTarget target)
public void doService(AdaptrisMessage msg) throws ServiceException
Service
Apply the service to the message.
msg
- the AdaptrisMessage
to processServiceException
- wrapping any underlying Exception
spublic void prepare() throws CoreException
ComponentLifecycleExtension
CoreException
protected void initService() throws CoreException
initService
in class ServiceImp
CoreException
protected void closeService()
closeService
in class ServiceImp
public PayloadToMetadataService.MetadataTarget getMetadataTarget()
public void setMetadataTarget(PayloadToMetadataService.MetadataTarget t)
public java.lang.String getKey()
public void setKey(java.lang.String key)
key
- the key.public PayloadToMetadataService.Encoding getEncoding()
public void setEncoding(PayloadToMetadataService.Encoding enc)
enc
- the encoding, defaults to PayloadToMetadataService.Encoding.None
.