public abstract class AbstractTransport extends java.lang.Object implements ConnectivityPlugin, TransportSide
Implementors may extend this class, providing an
implementation of its abstract methods and calling
HostSide.sendBatchTowardsHost(java.util.List)
as necessary. For
many transports inheriting from AbstractSimpleTransport
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
AbstractTransport(org.slf4j.Logger, PluginConstructorParameters.TransportConstructorParameters)
.
The legacy constructor AbstractTransport(Map, String, org.apache.log4j.Logger)
is still permitted
as an alternative but should not be used for new plug-ins.
Events are delivered to or from transports in batches, which transports may be able to make use of to deliver many events in a single operation, amortizing the cost of delivering events. The division into batches is of no significance beyond them all being available for delivery within a short space of time - a transport should function the same if given the events individually or in batches.
Some transports may need to respond to every message received from the host with a corresponding reply back towards the host. This has
to be done carefully; if the implementation of TransportSide.sendBatchTowardsTransport(java.util.List)
contains a simple
synchronous call back to HostSide.sendBatchTowardsHost(java.util.List)
, this has the potential to cause a deadlock in the host
application, depending on the disposition of internal queues. Transports needing to follow this pattern should generate their responses
on a distinct thread, not the thread that processes the message(s) from the host.
Modifier and Type | Field and Description |
---|---|
java.lang.String |
chainId
The identifier used for the chain this plug-in is part of.
|
java.util.Map<java.lang.String,java.lang.Object> |
config
Configuration of this plug-in.
|
HostSide |
hostSide
The next plug-in in the chain towards host, as set by
setNextTowardsHost(HostSide) . |
org.slf4j.Logger |
logger
A slf4j logger to be used by this plug-in instance for anything which needs
to be written to the host's log.
|
java.lang.String |
pluginName
The name used in the configuration file for this plug-in.
|
Constructor and Description |
---|
AbstractTransport(org.slf4j.Logger logger,
PluginConstructorParameters.TransportConstructorParameters params)
Constructor.
|
AbstractTransport(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 |
---|---|
void |
hostReady()
No-op implementation of
ConnectivityPlugin.hostReady() . |
void |
setNextTowardsHost(HostSide next)
Remember the host side of this transport.
|
void |
shutdown()
No-op implementation of
ConnectivityPlugin.shutdown() . |
void |
start()
No-op implementation of
ConnectivityPlugin.start() . |
java.lang.String |
toString() |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
sendBatchTowardsTransport
public final org.slf4j.Logger logger
public final java.util.Map<java.lang.String,java.lang.Object> config
public final java.lang.String chainId
public final java.lang.String pluginName
public HostSide hostSide
setNextTowardsHost(HostSide)
.
This field will be given a valid value before the start() method is called.public AbstractTransport(java.util.Map<java.lang.String,java.lang.Object> config, java.lang.String chainId, org.apache.log4j.Logger log4jLogger) throws java.lang.IllegalArgumentException
AbstractTransport(org.slf4j.Logger, PluginConstructorParameters.TransportConstructorParameters)
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 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.AbstractTransport(org.slf4j.Logger, PluginConstructorParameters.TransportConstructorParameters)
public AbstractTransport(org.slf4j.Logger logger, PluginConstructorParameters.TransportConstructorParameters 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 next)
public void shutdown() throws java.lang.Exception
ConnectivityPlugin.shutdown()
.
For convenience. If the transport creates any resources
that need closing, it must override this method.shutdown
in interface ConnectivityPlugin
java.lang.Exception
public void start() throws java.lang.Exception
ConnectivityPlugin.start()
.
For convenience. If the transport creates any resources such as background threads or connections, it
will need to override this method to do so. If this is
overridden, the shutdown
method should typically be
implemented as well.start
in interface ConnectivityPlugin
java.lang.Exception
- only if a fatal error occurred during startup.public void hostReady() throws java.lang.Exception
ConnectivityPlugin.hostReady()
.
For convenience. Transports are not required to do
anything at this point, though they may choose to avoid
pulling events from an external system until the host is ready.hostReady
in interface ConnectivityPlugin
java.lang.Exception
public java.lang.String toString()
toString
in class java.lang.Object
Submit 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.