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, wait
close, init, start, stop
prepare
public void handleConnectionException() throws CoreException
AdaptrisMessageWorker
Called 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 AdaptrisMessageWorker
CoreException
- wrapping underlying Exceptions#handleConnectionException()
public java.lang.String createName()
MessageEventGenerator
MleMarker
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 MessageEventGenerator
public java.lang.String createQualifier()
MessageEventGenerator
MleMarker
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 MessageEventGenerator
MleMarker
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 AdaptrisMessageWorker
msg
- 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 AdaptrisMessageWorker
bytes
- the byte[] to decodeAdaptrisMessage
CoreException
- wrapping any that occurpublic AdaptrisMessageEncoder getEncoder()
AdaptrisMessageWorker
Returns the AdaptrisMessageEncoder
to use.
getEncoder
in interface AdaptrisMessageWorker
AdaptrisMessageEncoder
to usepublic void setEncoder(AdaptrisMessageEncoder enc)
AdaptrisMessageWorker
Sets the AdaptrisMessageEncoder
to use.
setEncoder
in interface AdaptrisMessageWorker
enc
- the AdaptrisMessageEncoder
to usepublic <T> T retrieveConnection(java.lang.Class<T> type)
AdaptrisMessageWorker
retrieveConnection
in interface AdaptrisMessageWorker
type
- the type of connection to cast to.public void registerConnection(AdaptrisConnection conn)
AdaptrisMessageWorker
Sets the AdaptrisConnection
this component will use.
registerConnection
in interface AdaptrisMessageWorker
conn
- the AdaptrisConnection
to usepublic java.lang.String getUniqueId()
AdaptrisComponent
getUniqueId
in interface AdaptrisComponent
public void setUniqueId(java.lang.String s)
public java.lang.Boolean getIsTrackingEndpoint()
public boolean isTrackingEndpoint()
MessageEventGenerator
Returns true if this should be considered an 'end-point' for tracking purposes, otherwise false.
isTrackingEndpoint
in interface MessageEventGenerator
public void setIsTrackingEndpoint(java.lang.Boolean b)
public AdaptrisMessageFactory getMessageFactory()
getMessageFactory
in interface AdaptrisMessageWorker
public void setMessageFactory(AdaptrisMessageFactory f)
AdaptrisMessageWorker
setMessageFactory
in interface AdaptrisMessageWorker
f
- the messageFactory to setpublic <T extends AdaptrisMessageWorkerImp> T withMessageFactory(AdaptrisMessageFactory f)
protected void registerEncoderMessageFactory()