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 ServiceImpTakes a metadata value and sets that as the payload.This can be treated as a simplified form of
PayloadFromTemplateServicewhich does not have a template and just uses the actual metadata value as the payload. It is also designed as the reverse form ofPayloadToMetadataServiceand 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.Standardthen 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 classMetadataToPayloadService.MetadataSourceEnumeration 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 voidcloseService()voiddoService(AdaptrisMessage msg)Apply the service to the message.EncodingHelper.EncodinggetEncoding()java.lang.StringgetKey()MetadataToPayloadService.MetadataSourcegetMetadataSource()protected voidinitService()voidprepare()Prepare for initialisation.voidsetEncoding(EncodingHelper.Encoding enc)Specify the encoding of the metadata.voidsetKey(java.lang.String key)Set the metadata key to which will form the payload.voidsetMetadataSource(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:ServiceApply the service to the message.
- Parameters:
msg- theAdaptrisMessageto process- Throws:
ServiceException- wrapping any underlyingExceptions
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Throws:
CoreException
-
initService
protected void initService() throws CoreException- Specified by:
initServicein classServiceImp- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeServicein 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.
-
-