Class AddMetadataService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.metadata.MetadataServiceImpl
-
- com.adaptris.core.services.metadata.AddMetadataService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Add Static Metadata to a Message", tag="service,metadata") public class AddMetadataService extends MetadataServiceImpl
Implementation of
Service
that adds static metadata to be added to a message.Each metadata-element is added in sequence to the message, overwriting any existing metadata.
Additional behaviour is possible based on the value portion of the metadata-element.
- $UNIQUE_ID$ - add the messages unique id as metadata
- $MSG_SIZE$ - add the messages current size as metadata
In the adapter configuration file this class is aliased as add-metadata-service which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adaptris.core.services.metadata.MetadataServiceImpl
MetadataServiceImpl.LogWrapper
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.services.metadata.MetadataServiceImpl
DEBUG, ERROR, INFO, TRACE, WARN
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description AddMetadataService()
Creates a new instance.AddMetadataService(MetadataElement... elements)
AddMetadataService(java.util.Collection<MetadataElement> elements)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMetadataElement(MetadataElement element)
Adds aMetadataElement
s to theSet
that will be added to theAdaptrisMessage
.void
addMetadataElement(java.lang.String key, java.lang.String value)
Adds aMetadataElement
s made up of the passed key and value to theSet
that will be added to theAdaptrisMessage
.protected static MetadataElement
build(MetadataElement e, AdaptrisMessage msg)
void
doService(AdaptrisMessage msg)
Adds the configured metadata to the message.java.util.Set<MetadataElement>
getMetadataElements()
Returns theMetadataElement
s that will be added to theAdaptrisMessage
.java.lang.Boolean
getOverwrite()
protected boolean
overwrite(AdaptrisMessage msg, java.lang.String key)
void
setMetadataElements(java.util.Set<MetadataElement> s)
Sets theMetadataElement
s that will be added to theAdaptrisMessage
.void
setOverwrite(java.lang.Boolean b)
Whether or not to always overwrite metadata with the values configured.-
Methods inherited from class com.adaptris.core.services.metadata.MetadataServiceImpl
closeService, getMetadataLogger, initService, logMetadata, logMetadata, logMetadata, logMetadata, prepare, setMetadataLogger, withMetadataLogger
-
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
-
AddMetadataService
public AddMetadataService()
Creates a new instance.
-
AddMetadataService
public AddMetadataService(java.util.Collection<MetadataElement> elements)
-
AddMetadataService
public AddMetadataService(MetadataElement... elements)
-
-
Method Detail
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Adds the configured metadata to the message.
- Parameters:
msg
- the message to process- Throws:
ServiceException
- wrapping any underlyingException
s
-
getMetadataElements
public java.util.Set<MetadataElement> getMetadataElements()
Returns the
MetadataElement
s that will be added to theAdaptrisMessage
.- Returns:
- the
MetadataElement
s that will be added to theAdaptrisMessage
-
setMetadataElements
public void setMetadataElements(java.util.Set<MetadataElement> s)
Sets the
MetadataElement
s that will be added to theAdaptrisMessage
.- Parameters:
s
- theMetadataElement
s that will be added to theAdaptrisMessage
-
addMetadataElement
public void addMetadataElement(MetadataElement element)
Adds a
MetadataElement
s to theSet
that will be added to theAdaptrisMessage
.- Parameters:
element
- aMetadataElement
s to add to theAdaptrisMessage
-
addMetadataElement
public void addMetadataElement(java.lang.String key, java.lang.String value)
Adds a
MetadataElement
s made up of the passed key and value to theSet
that will be added to theAdaptrisMessage
.- Parameters:
key
- the metadata key, may not be null or emptyvalue
- the metadata value
-
getOverwrite
public java.lang.Boolean getOverwrite()
- Returns:
- the overwrite
-
setOverwrite
public void setOverwrite(java.lang.Boolean b)
Whether or not to always overwrite metadata with the values configured.- Parameters:
b
- the overwrite to set, default is true.
-
overwrite
protected boolean overwrite(AdaptrisMessage msg, java.lang.String key)
-
build
protected static MetadataElement build(MetadataElement e, AdaptrisMessage msg) throws ServiceException
- Throws:
ServiceException
-
-