public abstract class AdaptrisMessageWorkerImp extends java.lang.Object implements AdaptrisMessageWorker
Implementation of behaviour common to AdaptrisMessageConsumer and AdaptrisMessageProducer.
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
log |
CONFIRMATION_ID_KEY| Constructor and Description |
|---|
AdaptrisMessageWorkerImp() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
createName()
Create a name for any
MleMarker that is generated. |
java.lang.String |
createQualifier()
Create a qualifier for any
MleMarker that is generated. |
AdaptrisMessage |
decode(byte[] bytes)
Decodes the passed byte[] using the configured
AdaptrisMessageEncoder. |
byte[] |
encode(AdaptrisMessage msg)
Encode the passed message using the configured
AdaptrisMessageEncoder. |
AdaptrisMessageEncoder |
getEncoder()
Returns the
AdaptrisMessageEncoder to use. |
java.lang.Boolean |
getIsTrackingEndpoint() |
AdaptrisMessageFactory |
getMessageFactory() |
java.lang.String |
getUniqueId()
Get the unique-id that is associated with this component.
|
void |
handleConnectionException()
Called if a connection exception is encountered.
|
boolean |
isTrackingEndpoint()
Returns true if this should be considered an 'end-point' for tracking
purposes, otherwise false.
|
void |
registerConnection(AdaptrisConnection conn)
Sets the
AdaptrisConnection this component will use. |
protected void |
registerEncoderMessageFactory() |
<T> T |
retrieveConnection(java.lang.Class<T> type)
Return this components underlying connection.
|
void |
setEncoder(AdaptrisMessageEncoder enc)
Sets the
AdaptrisMessageEncoder to use. |
void |
setIsTrackingEndpoint(java.lang.Boolean b) |
void |
setMessageFactory(AdaptrisMessageFactory f)
Set the message factory used when creating AdaptrisMessage instances.
|
void |
setUniqueId(java.lang.String s) |
<T extends AdaptrisMessageWorkerImp> |
withMessageFactory(AdaptrisMessageFactory f) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, init, start, stoppreparepublic void handleConnectionException()
throws CoreException
AdaptrisMessageWorkerCalled if a connection exception is encountered. Generally this will be when a polling consumer fails to obtain input, when a producer fails to produce or when some third party thread such as JMS exception listener is invoked.
handleConnectionException in interface AdaptrisMessageWorkerCoreException - wrapping underlying Exceptions#handleConnectionException()public java.lang.String createName()
MessageEventGeneratorMleMarker that is generated.
The default implementation is to return the classname of the component in question.
* @return the name for anyMleMarker that is generated.createName in interface MessageEventGeneratorpublic java.lang.String createQualifier()
MessageEventGeneratorMleMarker that is generated.
The default implementation is to return the unique-id of the component in question, or the empty string if not configured
createQualifier in interface MessageEventGeneratorMleMarker that is generated.public byte[] encode(AdaptrisMessage msg) throws CoreException
AdaptrisMessageWorker
Encode the passed message using the configured
AdaptrisMessageEncoder. If no AME is configured
implementations should return msg.getBytes().
encode in interface AdaptrisMessageWorkermsg - the AdaptrisMessage to encodeAdaptrisMessage encoded as a byte[]CoreException - wrapping any that occurpublic AdaptrisMessage decode(byte[] bytes) throws CoreException
AdaptrisMessageWorker
Decodes the passed byte[] using the configured
AdaptrisMessageEncoder. If no AME is configured,
implementations should just set the byte[] as the payload of a new message.
decode in interface AdaptrisMessageWorkerbytes - the byte[] to decodeAdaptrisMessageCoreException - wrapping any that occurpublic AdaptrisMessageEncoder getEncoder()
AdaptrisMessageWorker
Returns the AdaptrisMessageEncoder to use.
getEncoder in interface AdaptrisMessageWorkerAdaptrisMessageEncoder to usepublic void setEncoder(AdaptrisMessageEncoder enc)
AdaptrisMessageWorker
Sets the AdaptrisMessageEncoder to use.
setEncoder in interface AdaptrisMessageWorkerenc - the AdaptrisMessageEncoder to usepublic <T> T retrieveConnection(java.lang.Class<T> type)
AdaptrisMessageWorkerretrieveConnection in interface AdaptrisMessageWorkertype - the type of connection to cast to.public void registerConnection(AdaptrisConnection conn)
AdaptrisMessageWorker
Sets the AdaptrisConnection this component will use.
registerConnection in interface AdaptrisMessageWorkerconn - the AdaptrisConnection to usepublic java.lang.String getUniqueId()
AdaptrisComponentgetUniqueId in interface AdaptrisComponentpublic void setUniqueId(java.lang.String s)
public java.lang.Boolean getIsTrackingEndpoint()
public boolean isTrackingEndpoint()
MessageEventGeneratorReturns true if this should be considered an 'end-point' for tracking purposes, otherwise false.
isTrackingEndpoint in interface MessageEventGeneratorpublic void setIsTrackingEndpoint(java.lang.Boolean b)
public AdaptrisMessageFactory getMessageFactory()
getMessageFactory in interface AdaptrisMessageWorkerpublic void setMessageFactory(AdaptrisMessageFactory f)
AdaptrisMessageWorkersetMessageFactory in interface AdaptrisMessageWorkerf - the messageFactory to setpublic <T extends AdaptrisMessageWorkerImp> T withMessageFactory(AdaptrisMessageFactory f)
protected void registerEncoderMessageFactory()