public abstract class AbstractCodec extends ConnectivityPlugin implements HostSide, TransportSide
Implementors may extend this class, providing an
implementation of its abstract methods to provide any required
transformation of Message
objects as they are sent towards
the transport or host side. For
many codecs inheriting from AbstractSimpleCodec
may be more convenient than using this class directly, as it deals with batching of events and
ignoring messages with null payloads.
Subclasses should provide a constructor with the same signature as
AbstractCodec(org.slf4j.Logger, PluginConstructorParameters.CodecConstructorParameters)
.
The deprecated legacy constructor AbstractCodec(Map, String, org.apache.log4j.Logger)
is still permitted
as an alternative but should not be used for new plug-ins.
Codecs should typically process a batch of Message
objects and pass the
batch on to the next plug-in in the chain. Unless they are looking
for certain control messages, codecs should ignore messages with null
payload,
passing them on to the next plug-in in the chain untouched.
Logging should be performed using the ConnectivityPlugin.logger
field.
MapExtractor
can be used to extract the content of payload.
Modifier and Type | Field and Description |
---|---|
HostSide |
hostSide
The next plug-in in the chain towards host, as set by
setNextTowardsHost(HostSide) . |
TransportSide |
transportSide
The next plug-in in the chain towards transport, as set by
setNextTowardsTransport(TransportSide) . |
chainId, config, CONNECTIVITY_API_VERSION, host, logger, pluginName
Constructor and Description |
---|
AbstractCodec(org.slf4j.Logger logger,
PluginConstructorParameters.CodecConstructorParameters params)
Constructor.
|
AbstractCodec(java.util.Map<java.lang.String,java.lang.Object> config,
java.lang.String chainId,
org.apache.log4j.Logger log4jLogger)
Deprecated.
This constructor signature is deprecated; please use the alternative constructor signature
AbstractCodec(org.slf4j.Logger, PluginConstructorParameters.CodecConstructorParameters) instead for new plug-ins. |
Modifier and Type | Method and Description |
---|---|
void |
hostReady()
No-op implementation of
ConnectivityPlugin.hostReady() . |
void |
setNextTowardsHost(HostSide hostSide)
Remember the host side of this codec.
|
void |
setNextTowardsTransport(TransportSide transportSide)
Remember the transport side of this codec.
|
void |
shutdown()
No-op implementation of
ConnectivityPlugin.shutdown() . |
void |
start()
No-op implementation of
ConnectivityPlugin.start() . |
java.lang.String |
toString() |
getStatusReporter
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
sendBatchTowardsHost
sendBatchTowardsTransport
public HostSide hostSide
setNextTowardsHost(HostSide)
.
This field will be given a valid value before the start() method is called.public TransportSide transportSide
setNextTowardsTransport(TransportSide)
.
This field will be given a valid value before the start() method is called.@Deprecated public AbstractCodec(java.util.Map<java.lang.String,java.lang.Object> config, java.lang.String chainId, org.apache.log4j.Logger log4jLogger) throws java.lang.IllegalArgumentException
AbstractCodec(org.slf4j.Logger, PluginConstructorParameters.CodecConstructorParameters)
instead for new plug-ins.config
- the configuration specified for this plug-inchainId
- the identifier of the chain this plug-in is part oflog4jLogger
- a log4j Logger object which can be used to log to the host log file.
This is no longer recommended for use and will be deprecated in a future release;
please use ConnectivityPlugin.logger
instead.java.lang.IllegalArgumentException
- should be thrown from a plug-in's constructor if
the configuration is invalid; any other exception indicates an internal error in the plug-in.AbstractCodec(org.slf4j.Logger, PluginConstructorParameters.CodecConstructorParameters)
public AbstractCodec(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 final void setNextTowardsHost(HostSide hostSide)
public final void setNextTowardsTransport(TransportSide transportSide)
public void shutdown() throws java.lang.Exception
ConnectivityPlugin.shutdown()
.
For convenience. If the codec creates any resources that
need closing, it must override this method.
This method may be called while messages are still being delivered towards the host or towards the transport.
shutdown
in class ConnectivityPlugin
java.lang.Exception
public void start() throws java.lang.Exception
ConnectivityPlugin.start()
.
For convenience. If the codec creates any resources, it
will need to override this method to do so and will
typically need to implement shutdown
as well.start
in class ConnectivityPlugin
java.lang.Exception
- only if a fatal error occurred during startup.public void hostReady() throws java.lang.Exception
ConnectivityPlugin.hostReady()
.
For convenience. Plug-ins are not required to do
anything at this point, and most codecs will not need to implement this method.hostReady
in class ConnectivityPlugin
java.lang.Exception
public java.lang.String toString()
toString
in class java.lang.Object
Submit a bug or feature
Copyright (c) 2013-2019 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.