Class AbstractTransport
- java.lang.Object
-
- com.softwareag.connectivity.ConnectivityPlugin
-
- com.softwareag.connectivity.AbstractTransport
-
- All Implemented Interfaces:
TransportSide
- Direct Known Subclasses:
AbstractSimpleTransport
public abstract class AbstractTransport extends ConnectivityPlugin implements TransportSide
Base class for transport plug-ins.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 fromAbstractSimpleTransport
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)
.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 toHostSide.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.Logging should be performed using the
ConnectivityPlugin.logger
field.
-
-
Field Summary
Fields Modifier and Type Field Description HostSide
hostSide
The next plug-in in the chain towards host, as set bysetNextTowardsHost(HostSide)
.-
Fields inherited from class com.softwareag.connectivity.ConnectivityPlugin
chainId, config, CONNECTIVITY_API_VERSION, host, logger, pluginName
-
-
Constructor Summary
Constructors Constructor Description AbstractTransport(org.slf4j.Logger logger, PluginConstructorParameters.TransportConstructorParameters params)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
hostReady()
No-op implementation ofConnectivityPlugin.hostReady()
.void
setNextTowardsHost(HostSide next)
Remember the host side of this transport.void
shutdown()
Close any resources created by the plug-in, and terminate and join any background threads.void
start()
No-op implementation ofConnectivityPlugin.start()
.java.lang.String
toString()
-
Methods inherited from class com.softwareag.connectivity.ConnectivityPlugin
getStatusReporter
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.softwareag.connectivity.TransportSide
sendBatchTowardsTransport
-
-
-
-
Field Detail
-
hostSide
public HostSide hostSide
The next plug-in in the chain towards host, as set bysetNextTowardsHost(HostSide)
. This field will be given a valid value before the start() method is called.
-
-
Constructor Detail
-
AbstractTransport
public AbstractTransport(org.slf4j.Logger logger, PluginConstructorParameters.TransportConstructorParameters params) throws java.lang.IllegalArgumentException, java.lang.Exception
Constructor. A subclass should provide its own constructor with the same signature as this one. This base class makes the parameters passed into its constructor available as member fields or methods for use by the subclass.- Parameters:
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.- Throws:
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.- Since:
- 9.12.0.1
-
-
Method Detail
-
setNextTowardsHost
public final void setNextTowardsHost(HostSide next)
Remember the host side of this transport. The next argument is stored in the hostSide member of this class for use by sub-classes when delivering messages to the host from the transport.
-
shutdown
public void shutdown() throws java.lang.Exception
Close any resources created by the plug-in, and terminate and join any background threads. This is a no-op implementation ofConnectivityPlugin.shutdown()
.For convenience. If the transport 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.
- Specified by:
shutdown
in classConnectivityPlugin
- Throws:
java.lang.Exception
-
start
public void start() throws java.lang.Exception
No-op implementation ofConnectivityPlugin.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, theshutdown()
method should typically be implemented as well.- Specified by:
start
in classConnectivityPlugin
- Throws:
java.lang.Exception
- only if a fatal error occurred during startup.
-
hostReady
public void hostReady() throws java.lang.Exception
No-op implementation ofConnectivityPlugin.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.- Specified by:
hostReady
in classConnectivityPlugin
- Throws:
java.lang.Exception
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-