@ComponentProfile(summary="Takes a metadata value and sets that as the payload", tag="service,metadata") public class MetadataToPayloadService extends ServiceImp
This can be treated as a simplified form of PayloadFromMetadataService
which does not
have a template and just uses the actual metadata value as the payload. It is also designed as
the reverse form of PayloadToMetadataService
and allows you to take a piece of object
metadata containing byte[]
and make it the payload.
This service will throw an error if the target metadata item does not exist.
This service also supports a resolvable metadata key via
MetadataResolver
; and if the metadata source is
MetadataToPayloadService.MetadataSource.Standard
then an additional
InterlokMessage.resolve(String, boolean)
step is executed.
In the adapter configuration file this class is aliased as metadata-to-payload which is the preferred alternative to the fully qualified classname when building your configuration.
Modifier and Type | Class and Description |
---|---|
static class |
MetadataToPayloadService.MetadataSource
Enumeration of where the two types of metadata.
|
log
Constructor and Description |
---|
MetadataToPayloadService() |
MetadataToPayloadService(java.lang.String metadataKey,
MetadataToPayloadService.MetadataSource target) |
Modifier and Type | Method and Description |
---|---|
protected void |
closeService() |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
EncodingHelper.Encoding |
getEncoding() |
java.lang.String |
getKey() |
MetadataToPayloadService.MetadataSource |
getMetadataSource() |
protected void |
initService() |
void |
prepare()
Prepare for initialisation.
|
void |
setEncoding(EncodingHelper.Encoding enc)
Specify the encoding of the metadata.
|
void |
setKey(java.lang.String key)
Set the metadata key to which will form the payload.
|
void |
setMetadataSource(MetadataToPayloadService.MetadataSource t) |
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
public MetadataToPayloadService()
public MetadataToPayloadService(java.lang.String metadataKey, MetadataToPayloadService.MetadataSource 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 MetadataToPayloadService.MetadataSource getMetadataSource()
public void setMetadataSource(MetadataToPayloadService.MetadataSource t)
public java.lang.String getKey()
public void setKey(java.lang.String key)
key
- the key.public EncodingHelper.Encoding getEncoding()
public void setEncoding(EncodingHelper.Encoding enc)
enc
- the encoding, defaults to EncodingHelper.Encoding.None
.