Class AbstractChainManager

java.lang.Object
com.softwareag.connectivity.chainmanagers.AbstractChainManager

public abstract class AbstractChainManager extends Object
Base class for a manager that takes responsibility for dynamically creating and managing instances of a transport plug-in.

The connectivity configuration files should specify one or more dynamic chain manager instances for each transport, each of which will be instantiated with their own configuration. A manager instance can create and destroy chains, and also provides a method to create a new instance of the associated transport plug-in for each chain that has been created. Subclasses must provide a constructor with the same signature as AbstractChainManager(org.slf4j.Logger, ChainManagerConstructorParameters).

See ChainManagerConstructorParameters for more information.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The configuration of the dynamic chain definitions that contain the transport associated with this manager.
    The interface through which the host provides services required by chain managers.
    final org.slf4j.Logger
    A slf4j logger to be used by this manager for anything which needs to be written to the host's log.
    final String
    The name used in the configuration file for this dynamic chain manager.
    final String
    The name used in the configuration file for the transport plug-in that created this chain manager.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractChainManager(org.slf4j.Logger logger, ChainManagerConstructorParameters params)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    createTransport(org.slf4j.Logger logger, ManagedTransportConstructorParameters params)
    Called by the connectivity framework creation of each chain, to request the manager to create and return a new instance of its associated transport.
    Helper method to get the chain definition containing the transport associated with this manager, assuming there is only one.
    getChainDefinition(String chainDefinitionId)
    Helper method to get the chain definition matching the specified id, or a singleton chain definition if no id was specified (null or empty).
    Allows reporting status information from this plug-in, such as connected/disconnected status and number of messages sent/received in each direction.
    abstract void
    Called during host shutdown to indicate that the chain manager should stop any background processes and disconnect any remote connections.
    abstract void
    Called after the chain manager is created to indicate that it can register a channel lifecycle listener, make external connections, create threads, and create chains.
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • logger

      public final org.slf4j.Logger logger
      A slf4j logger to be used by this manager for anything which needs to be written to the host's log. The host will take care of adding the transport and manager name to the messages logged using this object.
    • managerName

      public final String managerName
      The name used in the configuration file for this dynamic chain manager.
    • transportPluginName

      public final String transportPluginName
      The name used in the configuration file for the transport plug-in that created this chain manager.
    • host

      public final ChainManagerHost host
      The interface through which the host provides services required by chain managers.
    • chainDefinitions

      public final Collection<ChainDefinition> chainDefinitions
      The configuration of the dynamic chain definitions that contain the transport associated with this manager. The manager can use one or more of these when creating chains. Use of the helper methods getChainDefinition() and getChainDefinition(String) is recommended for most use cases. This data structure should usually not be modified after the constructor has returned, but if it is the caller must provide locking as it is not thread-safe.
  • Constructor Details

    • AbstractChainManager

      public AbstractChainManager(org.slf4j.Logger logger, ChainManagerConstructorParameters params) throws IllegalArgumentException, Exception
      Constructor. A subclass should provide its own constructor with the same signature as this one.

      The constructor will be called once for each dynamic chain manager instance specified in the configuration. A typical implementation will check and process any manager configuration that was passed in; creation of threads, connections etc should not happen until the start() method is called.

      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 manager and other capabilities.
      Throws:
      IllegalArgumentException - should be thrown from the constructor if the configuration is invalid.
      Exception - can be thrown by subclasses to indicate an internal error.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createTransport

      public abstract AbstractTransport createTransport(org.slf4j.Logger logger, ManagedTransportConstructorParameters params) throws IllegalArgumentException, Exception
      Called by the connectivity framework creation of each chain, to request the manager to create and return a new instance of its associated transport.

      This will be called whenever a new chain involving this transport is created, whether that chain is being created by the manager itself or for some other reason such as a static configuration file entry.

      A typical implementation will invoke the constructor of the transport class with the same arguments, and in some cases pass additional information to the transport (such as a reference to the manager instance, or a connection needed by the transport instance) and will usually store a reference to the new transport instance in the chain manager to allow operations to be performed on it later.

      Parameters:
      logger - a slf4j Logger object which can be used to log to the host log file by the new transport.
      params - an extensible interface providing access to the configuration for the transport, and other capabilities.
      Throws:
      IllegalArgumentException - should be thrown from if the configuration is invalid.
      Exception - can be thrown to indicate an internal error.
    • start

      public abstract void start() throws Exception
      Called after the chain manager is created to indicate that it can register a channel lifecycle listener, make external connections, create threads, and create chains.
      Throws:
      Exception - only if a fatal error occurred during startup.
    • shutdown

      public abstract void shutdown() throws Exception
      Called during host shutdown to indicate that the chain manager should stop any background processes and disconnect any remote connections.

      It is recommended that managers should destroy all chains they are managing as part of their implementation of this method.

      Any chains that still exist after the manager shutdown() method has returned will be destroyed automatically.

      ChainManagers must not create new chains or call any other methods on the ChainManagerHost interface after this method has returned.

      .
      Throws:
      Exception
    • getChainDefinition

      public ChainDefinition getChainDefinition() throws IllegalArgumentException
      Helper method to get the chain definition containing the transport associated with this manager, assuming there is only one.
      Returns:
      never null.
      Throws:
      IllegalArgumentException - if there are zero or more than one chain definitions containing this transport.
    • getChainDefinition

      public ChainDefinition getChainDefinition(String chainDefinitionId) throws IllegalArgumentException
      Helper method to get the chain definition matching the specified id, or a singleton chain definition if no id was specified (null or empty).
      Parameters:
      chainDefinitionId - can be null or empty to indicate that a singleton chain definition should be selected.
      Returns:
      never null.
      Throws:
      IllegalArgumentException - if there are no matches, or more than one match and the chainDefinitionId was not specified.
    • getStatusReporter

      public StatusReporter getStatusReporter()
      Allows reporting status information from this plug-in, such as connected/disconnected status and number of messages sent/received in each direction.