Class MetadataToPayloadService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.metadata.MetadataToPayloadService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Takes a metadata value and sets that as the payload", tag="service,metadata") public class MetadataToPayloadService extends ServiceImp
Takes a metadata value and sets that as the payload.This can be treated as a simplified form of
PayloadFromTemplateService
which does not have a template and just uses the actual metadata value as the payload. It is also designed as the reverse form ofPayloadToMetadataService
and allows you to take a piece of object metadata containingbyte[]
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 isMetadataToPayloadService.MetadataSource.Standard
then an additionalInterlokMessage.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MetadataToPayloadService.MetadataSource
Enumeration of where the two types of metadata.
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description MetadataToPayloadService()
MetadataToPayloadService(java.lang.String metadataKey, MetadataToPayloadService.MetadataSource 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()
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)
-
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
-
MetadataToPayloadService
public MetadataToPayloadService()
-
MetadataToPayloadService
public MetadataToPayloadService(java.lang.String metadataKey, MetadataToPayloadService.MetadataSource 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
-
getMetadataSource
public MetadataToPayloadService.MetadataSource getMetadataSource()
-
setMetadataSource
public void setMetadataSource(MetadataToPayloadService.MetadataSource t)
-
getKey
public java.lang.String getKey()
-
setKey
public void setKey(java.lang.String key)
Set the metadata key to which will form the payload.- Parameters:
key
- the key.
-
getEncoding
public EncodingHelper.Encoding getEncoding()
-
setEncoding
public void setEncoding(EncodingHelper.Encoding enc)
Specify the encoding of the metadata.- Parameters:
enc
- the encoding, defaults toEncodingHelper.Encoding.None
.
-
-