public abstract class AbstractSimpleCodec extends AbstractCodec
transformMessageTowardsHost(Message)
and
transformMessageTowardsTransport(Message)
methods.
Subclasses should provide a constructor with the same signature as
AbstractSimpleCodec(org.slf4j.Logger, PluginConstructorParameters.CodecConstructorParameters)
.
The legacy constructor AbstractSimpleCodec(Map, String, org.apache.log4j.Logger)
is still permitted
as an alternative but should not be used for new plug-ins.
chainId, config, hostSide, logger, pluginName, transportSide
Constructor and Description |
---|
AbstractSimpleCodec(org.slf4j.Logger logger,
PluginConstructorParameters.CodecConstructorParameters params)
Constructor.
|
AbstractSimpleCodec(java.util.Map<java.lang.String,java.lang.Object> config,
java.lang.String chainId,
org.apache.log4j.Logger log4jLogger)
Legacy constructor.
|
Modifier and Type | Method and Description |
---|---|
Message |
handleException(java.lang.Exception ex,
Message message,
boolean towardsTransport)
Handle an exception thrown from transforming messages.
|
void |
sendBatchTowardsHost(java.util.List<Message> messages)
Transform a batch of messages and pass them on to the next
plug-in synchronously.
|
void |
sendBatchTowardsTransport(java.util.List<Message> messages)
Transform a batch of messages and pass them on to the next
plug-in synchronously.
|
abstract Message |
transformMessageTowardsHost(Message message)
Transform an individual message with a non-null payload.
|
abstract Message |
transformMessageTowardsTransport(Message message)
Transform an individual message with a non-null payload.
|
Message |
transformNullPayloadTowardsHost(Message message)
Transform an individual message that has a null payload.
|
Message |
transformNullPayloadTowardsTransport(Message message)
Transform an individual message that has a null payload.
|
hostReady, setNextTowardsHost, setNextTowardsTransport, shutdown, start, toString
public AbstractSimpleCodec(java.util.Map<java.lang.String,java.lang.Object> config, java.lang.String chainId, org.apache.log4j.Logger log4jLogger) throws java.lang.IllegalArgumentException
AbstractSimpleCodec(org.slf4j.Logger, PluginConstructorParameters.CodecConstructorParameters)
instead for new plug-ins.java.lang.IllegalArgumentException
AbstractCodec.AbstractCodec(Map, String, org.apache.log4j.Logger)
public AbstractSimpleCodec(org.slf4j.Logger logger, PluginConstructorParameters.CodecConstructorParameters params) throws java.lang.IllegalArgumentException, java.lang.Exception
logger
- a slf4j Logger object which can be used to log to the host log file.params
- an extensible interface providing access to the configuration for this plug-in and other
capabilities.java.lang.IllegalArgumentException
- should be thrown from a plug-in's constructor if
the configuration is invalid.java.lang.Exception
- can be thrown to indicate an internal error.public void sendBatchTowardsTransport(java.util.List<Message> messages)
transformMessageTowardsTransport(Message)
or
transformNullPayloadTowardsTransport(Message)
(if the payload was
null). On an exception, calls handleException(Exception, Message, boolean)
. Any non-null
results are then sent in a batch by calling the next
plug-in in this thread.public void sendBatchTowardsHost(java.util.List<Message> messages)
transformMessageTowardsHost(Message)
or transformNullPayloadTowardsHost(Message)
(if the payload was null).On
an exception, calls handleException(Exception, Message, boolean)
. Any non-null results
are then sent in a batch by calling the next plug-in in
this thread.public abstract Message transformMessageTowardsHost(Message message) throws java.lang.Exception
message
- - the message, guaranteed to be non-null and have a non-null payload.java.lang.Exception
transformNullPayloadTowardsHost(Message)
public abstract Message transformMessageTowardsTransport(Message message) throws java.lang.Exception
message
- - the message, guaranteed to be non-null and have a non-null payload.java.lang.Exception
transformNullPayloadTowardsTransport(Message)
public Message transformNullPayloadTowardsHost(Message message) throws java.lang.Exception
By convention, most plug-ins silently pass through messages with null payloads without transforming them. Thus, the default implementation of this method is to just return the value passed in. If this method throws then the exception will be logged and the message dropped.
java.lang.Exception
public Message transformNullPayloadTowardsTransport(Message message) throws java.lang.Exception
By convention, most plug-ins silently pass through messages with null payloads without transforming them. Thus, the default implementation of this method is to just return the value passed in. If this method throws then the exception will be logged and the message dropped.
java.lang.Exception
public Message handleException(java.lang.Exception ex, Message message, boolean towardsTransport)
The default implementation is to log an error and return null (thus discarding this message, but not others in the same batch)
e
- TSubmit a bug or feature
Copyright (c) 2013-2016 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.