Class AddTimestampMetadataService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.metadata.AddTimestampMetadataService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Add a timestamp as metadata", tag="service,metadata,timestamp,datetime") public class AddTimestampMetadataService extends ServiceImp
Adds timestamp information as metadata.In addition to supporting all the patterns allowed by
SimpleDateFormat
, this service also supports the special valuesSECONDS_SINCE_EPOCH
andMILLISECONDS_SINCE_EPOCH
which describe the number of seconds and milliseconds since midnight Jan 1, 1970 UTC respectively. If specified as the format, then the long value associated will be emitted.- See Also:
DateFormatUtil.CustomDateFormat
In the adapter configuration file this class is aliased as add-timestamp-metadata-service which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description AddTimestampMetadataService()
AddTimestampMetadataService(java.lang.String format, java.lang.String metadataKey)
AddTimestampMetadataService(java.lang.String format, java.lang.String metadataKey, java.lang.Boolean alwaysReplace)
AddTimestampMetadataService(java.lang.String format, java.lang.String metadataKey, java.lang.Boolean alwaysReplace, TimestampGenerator s)
AddTimestampMetadataService(java.lang.String format, java.lang.String metadataKey, java.lang.Boolean alwaysReplace, java.lang.String offset)
-
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.java.lang.Boolean
getAlwaysReplace()
DateFormatBuilder
getDateFormatBuilder()
java.lang.String
getMetadataKey()
TimestampGenerator
getTimestampGenerator()
protected void
initService()
void
prepare()
Prepare for initialisation.void
setAlwaysReplace(java.lang.Boolean b)
Specify whether to always replace the metadata.void
setDateFormatBuilder(DateFormatBuilder builder)
void
setMetadataKey(java.lang.String metadataKey)
void
setTimestampGenerator(TimestampGenerator s)
-
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
-
AddTimestampMetadataService
public AddTimestampMetadataService()
-
AddTimestampMetadataService
public AddTimestampMetadataService(java.lang.String format, java.lang.String metadataKey)
-
AddTimestampMetadataService
public AddTimestampMetadataService(java.lang.String format, java.lang.String metadataKey, java.lang.Boolean alwaysReplace)
-
AddTimestampMetadataService
public AddTimestampMetadataService(java.lang.String format, java.lang.String metadataKey, java.lang.Boolean alwaysReplace, java.lang.String offset)
-
AddTimestampMetadataService
public AddTimestampMetadataService(java.lang.String format, java.lang.String metadataKey, java.lang.Boolean alwaysReplace, TimestampGenerator s)
-
-
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- See Also:
Service.doService(com.adaptris.core.AdaptrisMessage)
-
initService
protected void initService() throws CoreException
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeService
in classServiceImp
-
getMetadataKey
public java.lang.String getMetadataKey()
- Returns:
- the metadataKey
-
setMetadataKey
public void setMetadataKey(java.lang.String metadataKey)
- Parameters:
metadataKey
- the metadataKey to set
-
getAlwaysReplace
public java.lang.Boolean getAlwaysReplace()
- Returns:
- the alwaysReplace
-
setAlwaysReplace
public void setAlwaysReplace(java.lang.Boolean b)
Specify whether to always replace the metadata.- Parameters:
b
- the alwaysReplace to set, default is false.
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
getTimestampGenerator
public TimestampGenerator getTimestampGenerator()
- Returns:
- the timestampGenerator
-
setTimestampGenerator
public void setTimestampGenerator(TimestampGenerator s)
- Parameters:
s
- the timestampGenerator to set
-
getDateFormatBuilder
public DateFormatBuilder getDateFormatBuilder()
-
setDateFormatBuilder
public void setDateFormatBuilder(DateFormatBuilder builder)
-
-