@ComponentProfile(summary="Add a timestamp as metadata", tag="service,metadata,timestamp,datetime") public class AddTimestampMetadataService extends ServiceImp
In addition to supporting all the patterns allowed by SimpleDateFormat
, this service also supports the special
values SECONDS_SINCE_EPOCH
and MILLISECONDS_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.
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.
log
CONFIRMATION_ID_KEY
Constructor and 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,
java.lang.String offset) |
AddTimestampMetadataService(java.lang.String format,
java.lang.String metadataKey,
java.lang.Boolean alwaysReplace,
TimestampGenerator s) |
Modifier and Type | Method and Description |
---|---|
protected void |
closeService() |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
java.lang.Boolean |
getAlwaysReplace() |
java.lang.String |
getDateFormat()
Deprecated.
since 3.6.6 use
getDateFormatBuilder() instead |
DateFormatBuilder |
getDateFormatBuilder() |
java.lang.String |
getMetadataKey() |
java.lang.String |
getOffset()
Deprecated.
since 3.5.0 Use
OffsetTimestampGenerator instead. |
TimestampGenerator |
getTimestampGenerator() |
protected void |
initService() |
void |
prepare()
Prepare for initialisation.
|
void |
setAlwaysReplace(java.lang.Boolean b)
Specify whether to always replace the metadata.
|
void |
setDateFormat(java.lang.String dateFormat)
Deprecated.
since 3.6.6 use
setDateFormatBuilder(DateFormatBuilder) instead. |
void |
setDateFormatBuilder(DateFormatBuilder builder) |
void |
setMetadataKey(java.lang.String metadataKey) |
void |
setOffset(java.lang.String offset)
Deprecated.
since 3.5.0 Use
OffsetTimestampGenerator instead. |
void |
setTimestampGenerator(TimestampGenerator s) |
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsConfirmation, getIsTrackingEndpoint, getLookupName, getUniqueId, init, isBranching, isConfirmation, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, rethrowServiceException, retrieveComponentState, setContinueOnFail, setIsConfirmation, setIsTrackingEndpoint, setLookupName, setUniqueId, start, stop
public AddTimestampMetadataService()
public AddTimestampMetadataService(java.lang.String format, java.lang.String metadataKey)
public AddTimestampMetadataService(java.lang.String format, java.lang.String metadataKey, java.lang.Boolean alwaysReplace)
public AddTimestampMetadataService(java.lang.String format, java.lang.String metadataKey, java.lang.Boolean alwaysReplace, java.lang.String offset)
public AddTimestampMetadataService(java.lang.String format, java.lang.String metadataKey, java.lang.Boolean alwaysReplace, TimestampGenerator s)
public void doService(AdaptrisMessage msg) throws ServiceException
Service
Apply the service to the message.
msg
- the AdaptrisMessage
to processServiceException
- wrapping any underlying Exception
sService.doService(com.adaptris.core.AdaptrisMessage)
protected void initService() throws CoreException
initService
in class ServiceImp
CoreException
protected void closeService()
closeService
in class ServiceImp
public java.lang.String getMetadataKey()
public void setMetadataKey(java.lang.String metadataKey)
metadataKey
- the metadataKey to set@Deprecated @Removal(version="3.9.0", message="Use DateFormatBuilder") public java.lang.String getDateFormat()
getDateFormatBuilder()
instead@Deprecated @Removal(version="3.9.0", message="Use DateFormatBuilder") public void setDateFormat(java.lang.String dateFormat)
setDateFormatBuilder(DateFormatBuilder)
instead.dateFormat
- the dateFormat to setpublic java.lang.Boolean getAlwaysReplace()
public void setAlwaysReplace(java.lang.Boolean b)
b
- the alwaysReplace to set, default is false.@Deprecated @Removal(version="3.9.0", message="Use TimestampGenerator") public java.lang.String getOffset()
OffsetTimestampGenerator
instead.@Deprecated @Removal(version="3.9.0", message="Use TimestampGenerator") public void setOffset(java.lang.String offset)
OffsetTimestampGenerator
instead.The offset follows the ISO8601 convention for durations. The format is [+-]P[n]Y[n]M[n]DT[n]H[n]M[n]S. In these representations, the [n] is replaced by the value for each of the date and time elements that follow the [n]. Leading zeros are not required. The capital letters 'P', 'Y', 'M', 'W', 'D', 'T', 'H', 'M', and 'S' are designators for each of the date and time elements and are not replaced.
For example, P3Y6M4DT12H30M5S
represents a duration of three
years, six months, four days, twelve hours, thirty minutes, and five
seconds . Date and time elements including their designator may be omitted
if their value is zero, and lower order elements may also be omitted for
reduced precision. For example, "P23DT23H" and "P4Y" are both acceptable
duration representations.
To resolve ambiguity, "P1M" is a one-month duration and "PT1M" is a one-minute duration (note the time designator, T, that precedes the time value). The seconds value used may also have a decimal fraction, as in "PT0.5S" to indicate half a second."PT36H" could be used as well as "P1DT12H" for representing the same duration.
A negative period will become some date in the past; a positive or
unspecified period will resolve to some time in the future. For example
-P30D
will resolve to 30 days ago, whereas P30D
will resolve to 30 days in the future.
offset
- the offset.public void prepare() throws CoreException
ComponentLifecycleExtension
CoreException
public TimestampGenerator getTimestampGenerator()
public void setTimestampGenerator(TimestampGenerator s)
s
- the timestampGenerator to setpublic DateFormatBuilder getDateFormatBuilder()
public void setDateFormatBuilder(DateFormatBuilder builder)