Class AdaptrisMessageFactory
- Direct Known Subclasses:
DefaultMessageFactory
,MultiPayloadMessageFactory
A static
factory which returns implementations of
AdaptrisMessage
.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
If set as an env var then the fully qualified classname is used as the default message factory.static final String
If set as as system property then the fully qualified classname is used as the default message factory.static final String
If set as an env var then the fully qualified classname is used as the default ID Generatorstatic final String
If set as as system property then the fully qualified classname is used as the default ID generator. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static AdaptrisMessageFactory
protected static IdGenerator
static AdaptrisMessageFactory
Convenience method for null protection.abstract String
Return the default character encoding for the message.static AdaptrisMessageFactory
Get the default implementationion of AdaptrisMessageFactory.abstract AdaptrisMessage
Returns a newAdaptrisMessage
.abstract AdaptrisMessage
newMessage
(byte[] payload) Returns a newAdaptrisMessage
with the specified payload and metadata.abstract AdaptrisMessage
newMessage
(byte[] payload, Set metadata) Returns a newAdaptrisMessage
with the specified payload and metadata.abstract AdaptrisMessage
newMessage
(AdaptrisMessage source, Collection<String> metadataKeysToPreserve) Returns a newAdaptrisMessage
with an empty payload but with selected metadata from the source.abstract AdaptrisMessage
newMessage
(String payload) Returns a newAdaptrisMessage
with the specified payload and metadata.abstract AdaptrisMessage
newMessage
(String payload, String charEncoding) Returns a newAdaptrisMessage
with the specified payload and metadata.abstract AdaptrisMessage
newMessage
(String payload, String charEncoding, Set metadata) Returns a newAdaptrisMessage
with the specified payload and metadata.abstract AdaptrisMessage
newMessage
(String payload, Set metadata) Returns a newAdaptrisMessage
with the specified payload and metadata.protected static String
Resolve a value from an environment variable or system property.abstract void
Set the default character encoding to be applied to the message upon creation.void
Set the unique id generator used for messages.protected IdGenerator
-
Field Details
-
OVERRIDE_DEFAULT_MSG_FACTORY_PROP
If set as as system property then the fully qualified classname is used as the default message factory.- See Also:
-
OVERRIDE_DEFAULT_MSG_FACTORY_ENV
If set as an env var then the fully qualified classname is used as the default message factory.This will take precedence over the system property
-
OVERRIDE_DEFAULT_MSGID_GEN_PROP
If set as as system property then the fully qualified classname is used as the default ID generator.- See Also:
-
OVERRIDE_DEFAULT_MSGID_GEN_KEY
If set as an env var then the fully qualified classname is used as the default ID GeneratorThis will take precedence over the system property
-
-
Constructor Details
-
AdaptrisMessageFactory
public AdaptrisMessageFactory()
-
-
Method Details
-
getDefaultInstance
Get the default implementationion of AdaptrisMessageFactory.Generally speaking, the appropriate message factory should be already be configured explicitly and available to be used. This method is simply here for those instances where no AdaptrisMessageFactory is available.
- Returns:
- a AdaptrisMessageFactory implementation
- See Also:
-
defaultIfNull
Convenience method for null protection.- Parameters:
f
- the configured message factory.- Returns:
- the configured message factory or the default instance if it is null.
-
newMessage
Returns a new
AdaptrisMessage
with the specified payload and metadata.- Parameters:
payload
- thebyte[]
payloadmetadata
- aSet
ofMetadataElement
s- Returns:
- a new
AdaptrisMessage
-
newMessage
Returns a new
AdaptrisMessage
with the specified payload and metadata.- Parameters:
payload
- thebyte[]
payload- Returns:
- a new
AdaptrisMessage
-
newMessage
Returns a new
AdaptrisMessage
with the specified payload and metadata. Uses default platform character encoding.- Parameters:
payload
- theString
payloadmetadata
- aSet
ofMetadataElement
s- Returns:
- a new
AdaptrisMessage
-
newMessage
Returns a new
AdaptrisMessage
with the specified payload and metadata. Uses default platform character encoding.- Parameters:
payload
- theString
payload- Returns:
- a new
AdaptrisMessage
-
newMessage
public abstract AdaptrisMessage newMessage(String payload, String charEncoding, Set metadata) throws UnsupportedEncodingException Returns a new
AdaptrisMessage
with the specified payload and metadata. Uses default platform character encoding.- Parameters:
payload
- theString
payloadmetadata
- aSet
ofMetadataElement
scharEncoding
- theString
's character encoding- Returns:
- a new
AdaptrisMessage
- Throws:
UnsupportedEncodingException
- if the passed character encoding is not supported
-
newMessage
public abstract AdaptrisMessage newMessage(String payload, String charEncoding) throws UnsupportedEncodingException Returns a new
AdaptrisMessage
with the specified payload and metadata. Uses default platform character encoding.- Parameters:
payload
- theString
payloadcharEncoding
- theString
's character encoding- Returns:
- a new
AdaptrisMessage
- Throws:
UnsupportedEncodingException
- if the passed character encoding is not supported
-
newMessage
public abstract AdaptrisMessage newMessage(AdaptrisMessage source, Collection<String> metadataKeysToPreserve) throws CloneNotSupportedException Returns a newAdaptrisMessage
with an empty payload but with selected metadata from the source.The new AdaptrisMessage will have the same message id and MessageLifecycleEvent will be cloned from the original. Object metadata will also be preserved.
- Parameters:
source
- the original AdaptrisMessagemetadataKeysToPreserve
- a list of keys to transfer to the new Message; if null, then all keys.- Returns:
- a new
AdaptrisMessage
- Throws:
CloneNotSupportedException
- if the MleMarkers could not be cloned.
-
getDefaultCharEncoding
Return the default character encoding for the message.- Returns:
- the defaultCharEncoding
-
setDefaultCharEncoding
Set the default character encoding to be applied to the message upon creation.If not explicitly configured, then the platform default character encoding should be used.
- Parameters:
s
- the defaultCharEncoding to set- See Also:
-
newMessage
Returns a new
AdaptrisMessage
. Payload and metadata are null.- Returns:
- a new
AdaptrisMessage
with the specified payload and metadata
-
getUniqueIdGenerator
- Returns:
- the uniqueIdGenerator
-
setUniqueIdGenerator
Set the unique id generator used for messages.In some situations you may not want to use the default
GuidGenerator
instance when assigning unique ids to messages. This allows you to change theIdGenerator
used both for message ids unique ids associated withMessageLifecycleEvent
.- Parameters:
s
- the uniqueIdGenerator to set
-
uniqueIdGenerator
-
createDefaultIdGenerator
-
createDefaultFactory
-
resolve
Resolve a value from an environment variable or system property.- Parameters:
envKey
- the environment variable, this takes precedence over system properties.sysPropKey
- the system property.defaultValue
- the default value if neither keys exist.- Returns:
- the resolved value.
-