Class AdaptrisMessageFactory
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageFactory
-
- Direct Known Subclasses:
DefaultMessageFactory,MultiPayloadMessageFactory
public abstract class AdaptrisMessageFactory extends java.lang.ObjectA
staticfactory which returns implementations ofAdaptrisMessage.
-
-
Constructor Summary
Constructors Constructor Description AdaptrisMessageFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static AdaptrisMessageFactorydefaultIfNull(AdaptrisMessageFactory f)Convenience method for null protection.abstract java.lang.StringgetDefaultCharEncoding()Return the default character encoding for the message.static AdaptrisMessageFactorygetDefaultInstance()Get the default implementationion of AdaptrisMessageFactory.IdGeneratorgetUniqueIdGenerator()abstract AdaptrisMessagenewMessage()Returns a newAdaptrisMessage.abstract AdaptrisMessagenewMessage(byte[] payload)Returns a newAdaptrisMessagewith the specified payload and metadata.abstract AdaptrisMessagenewMessage(byte[] payload, java.util.Set metadata)Returns a newAdaptrisMessagewith the specified payload and metadata.abstract AdaptrisMessagenewMessage(AdaptrisMessage source, java.util.Collection<java.lang.String> metadataKeysToPreserve)Returns a newAdaptrisMessagewith an empty payload but with selected metadata from the source.abstract AdaptrisMessagenewMessage(java.lang.String payload)Returns a newAdaptrisMessagewith the specified payload and metadata.abstract AdaptrisMessagenewMessage(java.lang.String payload, java.lang.String charEncoding)Returns a newAdaptrisMessagewith the specified payload and metadata.abstract AdaptrisMessagenewMessage(java.lang.String payload, java.lang.String charEncoding, java.util.Set metadata)Returns a newAdaptrisMessagewith the specified payload and metadata.abstract AdaptrisMessagenewMessage(java.lang.String payload, java.util.Set metadata)Returns a newAdaptrisMessagewith the specified payload and metadata.abstract voidsetDefaultCharEncoding(java.lang.String s)Set the default character encoding to be applied to the message upon creation.voidsetUniqueIdGenerator(IdGenerator s)Set the unique id generator used for messages.protected IdGeneratoruniqueIdGenerator()
-
-
-
Method Detail
-
getDefaultInstance
public static AdaptrisMessageFactory 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:
AdaptrisMessageWorker.getMessageFactory(),AdaptrisMessageTranslator.currentMessageFactory(),DefaultMessageFactory
-
defaultIfNull
public static AdaptrisMessageFactory defaultIfNull(AdaptrisMessageFactory f)
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
public abstract AdaptrisMessage newMessage(byte[] payload, java.util.Set metadata)
Returns a new
AdaptrisMessagewith the specified payload and metadata.- Parameters:
payload- thebyte[]payloadmetadata- aSetofMetadataElements- Returns:
- a new
AdaptrisMessage
-
newMessage
public abstract AdaptrisMessage newMessage(byte[] payload)
Returns a new
AdaptrisMessagewith the specified payload and metadata.- Parameters:
payload- thebyte[]payload- Returns:
- a new
AdaptrisMessage
-
newMessage
public abstract AdaptrisMessage newMessage(java.lang.String payload, java.util.Set metadata)
Returns a new
AdaptrisMessagewith the specified payload and metadata. Uses default platform character encoding.- Parameters:
payload- theStringpayloadmetadata- aSetofMetadataElements- Returns:
- a new
AdaptrisMessage
-
newMessage
public abstract AdaptrisMessage newMessage(java.lang.String payload)
Returns a new
AdaptrisMessagewith the specified payload and metadata. Uses default platform character encoding.- Parameters:
payload- theStringpayload- Returns:
- a new
AdaptrisMessage
-
newMessage
public abstract AdaptrisMessage newMessage(java.lang.String payload, java.lang.String charEncoding, java.util.Set metadata) throws java.io.UnsupportedEncodingException
Returns a new
AdaptrisMessagewith the specified payload and metadata. Uses default platform character encoding.- Parameters:
payload- theStringpayloadmetadata- aSetofMetadataElementscharEncoding- theString's character encoding- Returns:
- a new
AdaptrisMessage - Throws:
java.io.UnsupportedEncodingException- if the passed character encoding is not supported
-
newMessage
public abstract AdaptrisMessage newMessage(java.lang.String payload, java.lang.String charEncoding) throws java.io.UnsupportedEncodingException
Returns a new
AdaptrisMessagewith the specified payload and metadata. Uses default platform character encoding.- Parameters:
payload- theStringpayloadcharEncoding- theString's character encoding- Returns:
- a new
AdaptrisMessage - Throws:
java.io.UnsupportedEncodingException- if the passed character encoding is not supported
-
newMessage
public abstract AdaptrisMessage newMessage(AdaptrisMessage source, java.util.Collection<java.lang.String> metadataKeysToPreserve) throws java.lang.CloneNotSupportedException
Returns a newAdaptrisMessagewith 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:
java.lang.CloneNotSupportedException- if the MleMarkers could not be cloned.
-
getDefaultCharEncoding
public abstract java.lang.String getDefaultCharEncoding()
Return the default character encoding for the message.- Returns:
- the defaultCharEncoding
-
setDefaultCharEncoding
public abstract void setDefaultCharEncoding(java.lang.String s)
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:
AdaptrisMessage.setCharEncoding(String)
-
newMessage
public abstract AdaptrisMessage newMessage()
Returns a new
AdaptrisMessage. Payload and metadata are null.- Returns:
- a new
AdaptrisMessagewith the specified payload and metadata
-
getUniqueIdGenerator
public IdGenerator getUniqueIdGenerator()
- Returns:
- the uniqueIdGenerator
-
setUniqueIdGenerator
public void setUniqueIdGenerator(IdGenerator s)
Set the unique id generator used for messages.In some situations you may not want to use the default
GuidGeneratorinstance when assigning unique ids to messages. This allows you to change theIdGeneratorused both for message ids unique ids associated withMessageLifecycleEvent.- Parameters:
s- the uniqueIdGenerator to set
-
uniqueIdGenerator
protected IdGenerator uniqueIdGenerator()
-
-