Class AdaptrisMessageWorkerImp
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisMessageWorker,ComponentLifecycle,ComponentLifecycleExtension,MessageEventGenerator
- Direct Known Subclasses:
AdaptrisMessageConsumerImp,AdaptrisMessageProducerImp
public abstract class AdaptrisMessageWorkerImp extends java.lang.Object implements AdaptrisMessageWorker
Implementation of behaviour common to
AdaptrisMessageConsumerandAdaptrisMessageProducer.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Loggerlog
-
Constructor Summary
Constructors Constructor Description AdaptrisMessageWorkerImp()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringcreateName()Create a name for anyMleMarkerthat is generated.java.lang.StringcreateQualifier()Create a qualifier for anyMleMarkerthat is generated.AdaptrisMessagedecode(byte[] bytes)Decodes the passed byte[] using the configuredAdaptrisMessageEncoder.byte[]encode(AdaptrisMessage msg)Encode the passed message using the configuredAdaptrisMessageEncoder.AdaptrisMessageEncodergetEncoder()Returns theAdaptrisMessageEncoderto use.java.lang.BooleangetIsTrackingEndpoint()AdaptrisMessageFactorygetMessageFactory()java.lang.StringgetUniqueId()Get the unique-id that is associated with this component.voidhandleConnectionException()Called if a connection exception is encountered.booleanisTrackingEndpoint()Returns true if this should be considered an 'end-point' for tracking purposes, otherwise false.voidregisterConnection(AdaptrisConnection conn)Sets theAdaptrisConnectionthis component will use.protected voidregisterEncoderMessageFactory()<T> TretrieveConnection(java.lang.Class<T> type)Return this components underlying connection.voidsetEncoder(AdaptrisMessageEncoder enc)Sets theAdaptrisMessageEncoderto use.voidsetIsTrackingEndpoint(java.lang.Boolean b)voidsetMessageFactory(AdaptrisMessageFactory f)Set the message factory used when creating AdaptrisMessage instances.voidsetUniqueId(java.lang.String s)<T extends AdaptrisMessageWorkerImp>
TwithMessageFactory(AdaptrisMessageFactory f)<T extends AdaptrisMessageWorkerImp>
TwithUniqueID(java.lang.String uid)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init, start, stop
-
Methods inherited from interface com.adaptris.core.ComponentLifecycleExtension
prepare
-
-
-
-
Method Detail
-
handleConnectionException
public void handleConnectionException() throws CoreExceptionDescription copied from interface: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.
- Specified by:
handleConnectionExceptionin interfaceAdaptrisMessageWorker- Throws:
CoreException- wrapping underlying Exceptions- See Also:
#handleConnectionException()
-
createName
public java.lang.String createName()
Description copied from interface:MessageEventGeneratorCreate a name for anyMleMarkerthat is generated.The default implementation is to return the classname of the component in question.
* @return the name for anyMleMarkerthat is generated.- Specified by:
createNamein interfaceMessageEventGenerator
-
createQualifier
public java.lang.String createQualifier()
Description copied from interface:MessageEventGeneratorCreate a qualifier for anyMleMarkerthat is generated.The default implementation is to return the unique-id of the component in question, or the empty string if not configured
- Specified by:
createQualifierin interfaceMessageEventGenerator- Returns:
- the qualifier for any
MleMarkerthat is generated.
-
encode
public byte[] encode(AdaptrisMessage msg) throws CoreException
Description copied from interface:AdaptrisMessageWorkerEncode the passed message using the configured
AdaptrisMessageEncoder. If no AME is configured implementations should returnmsg.getBytes().- Specified by:
encodein interfaceAdaptrisMessageWorker- Parameters:
msg- theAdaptrisMessageto encode- Returns:
- the
AdaptrisMessageencoded as a byte[] - Throws:
CoreException- wrapping any that occur
-
decode
public AdaptrisMessage decode(byte[] bytes) throws CoreException
Description copied from interface:AdaptrisMessageWorkerDecodes 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.- Specified by:
decodein interfaceAdaptrisMessageWorker- Parameters:
bytes- the byte[] to decode- Returns:
- an
AdaptrisMessage - Throws:
CoreException- wrapping any that occur
-
getEncoder
public AdaptrisMessageEncoder getEncoder()
Description copied from interface:AdaptrisMessageWorkerReturns the
AdaptrisMessageEncoderto use.- Specified by:
getEncoderin interfaceAdaptrisMessageWorker- Returns:
- the
AdaptrisMessageEncoderto use
-
setEncoder
public void setEncoder(AdaptrisMessageEncoder enc)
Description copied from interface:AdaptrisMessageWorkerSets the
AdaptrisMessageEncoderto use.- Specified by:
setEncoderin interfaceAdaptrisMessageWorker- Parameters:
enc- theAdaptrisMessageEncoderto use
-
retrieveConnection
public <T> T retrieveConnection(java.lang.Class<T> type)
Description copied from interface:AdaptrisMessageWorkerReturn this components underlying connection.- Specified by:
retrieveConnectionin interfaceAdaptrisMessageWorker- Parameters:
type- the type of connection to cast to.- Returns:
- the connection
-
registerConnection
public void registerConnection(AdaptrisConnection conn)
Description copied from interface:AdaptrisMessageWorkerSets the
AdaptrisConnectionthis component will use.- Specified by:
registerConnectionin interfaceAdaptrisMessageWorker- Parameters:
conn- theAdaptrisConnectionto use
-
getUniqueId
public java.lang.String getUniqueId()
Description copied from interface:AdaptrisComponentGet the unique-id that is associated with this component.- Specified by:
getUniqueIdin interfaceAdaptrisComponent- Returns:
- the unique-id
-
setUniqueId
public void setUniqueId(java.lang.String s)
-
getIsTrackingEndpoint
public java.lang.Boolean getIsTrackingEndpoint()
-
isTrackingEndpoint
public boolean isTrackingEndpoint()
Description copied from interface:MessageEventGeneratorReturns true if this should be considered an 'end-point' for tracking purposes, otherwise false.
- Specified by:
isTrackingEndpointin interfaceMessageEventGenerator- Returns:
- true if this should be considered an 'end-point' for tracking purposes, otherwise false
-
setIsTrackingEndpoint
public void setIsTrackingEndpoint(java.lang.Boolean b)
-
getMessageFactory
public AdaptrisMessageFactory getMessageFactory()
- Specified by:
getMessageFactoryin interfaceAdaptrisMessageWorker- Returns:
- the messageFactory
-
setMessageFactory
public void setMessageFactory(AdaptrisMessageFactory f)
Description copied from interface:AdaptrisMessageWorkerSet the message factory used when creating AdaptrisMessage instances.- Specified by:
setMessageFactoryin interfaceAdaptrisMessageWorker- Parameters:
f- the messageFactory to set
-
withMessageFactory
public <T extends AdaptrisMessageWorkerImp> T withMessageFactory(AdaptrisMessageFactory f)
-
withUniqueID
public <T extends AdaptrisMessageWorkerImp> T withUniqueID(java.lang.String uid)
-
registerEncoderMessageFactory
protected void registerEncoderMessageFactory()
-
-