public abstract class AbstractTransport extends java.lang.Object implements ConnectivityPlugin, TransportSide
Transports can be implemented by inheriting from this class
directly which provides implementation of some of the methods. For
simple transports, inheriting from AbstractSimpleTransport
may be more convenient as it deals with batching of events and
ignoring null event messages.
Implementors will typically sub-class this class providing an
implementation of sendBatchTowardsTransport or sub-class AbstractSimpleTransport
.
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.
(java.lang.Map<String, Object> instanceConfiguration, String chainId, org.apache.log4j.Logger logger) throws Exception, IllegalArgumentException
An IllegalArgumentException should be thrown from the constructor if the configuration is invalid; any other exception indicates an internal error in the plug-in.
Modifier and Type | Field and Description |
---|---|
java.lang.String |
chainId
Chain name.
|
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.
|
Constructor and Description |
---|
AbstractTransport(java.util.Map<java.lang.String,java.lang.Object> config,
java.lang.String chainId,
org.apache.log4j.Logger logger)
Constructor, storing config, chainId and logger.
|
Modifier and Type | Method and Description |
---|---|
void |
hostReady()
No-op implementation of hostReady.
|
void |
setNextTowardsHost(HostSide next)
Remember the host side of this transport.
|
void |
shutdown()
No-op implementation of shutdown.
|
void |
start()
No-op implementation of start.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
sendBatchTowardsTransport
public final java.util.Map<java.lang.String,java.lang.Object> config
public final java.lang.String chainId
public HostSide hostSide
public AbstractTransport(java.util.Map<java.lang.String,java.lang.Object> config, java.lang.String chainId, org.apache.log4j.Logger logger)
public final void setNextTowardsHost(HostSide next)
public void shutdown() throws java.lang.Exception
shutdown
in interface ConnectivityPlugin
java.lang.Exception
public void start() throws java.lang.Exception
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
hostReady
in interface ConnectivityPlugin
java.lang.Exception
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.