Interface ChainManagerHost


  • public interface ChainManagerHost
    Interface that the host provides to the chain manager for operations such as creating chains and registering channel lifecycle listeners.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addChannelLifecycleListener​(ChannelLifecycleListener listener, java.lang.String channelPrefix)
      Register a listener to get a callback when interested channel is created/destroyed.
      Chain createChain​(java.lang.String chainInstanceIdSuffix, ChainDefinition dynamicChainDefinition, java.util.Map<java.lang.String,​java.lang.String> substitutions, java.lang.String defaultChannelTowardsHost, java.util.List<java.lang.String> subscribeChannels)
      Create a new instance of a dynamic chain.
    • Method Detail

      • createChain

        Chain createChain​(java.lang.String chainInstanceIdSuffix,
                          ChainDefinition dynamicChainDefinition,
                          java.util.Map<java.lang.String,​java.lang.String> substitutions,
                          java.lang.String defaultChannelTowardsHost,
                          java.util.List<java.lang.String> subscribeChannels)
                   throws java.lang.Exception
        Create a new instance of a dynamic chain.

        Will not return until chain creation has completed and therefore may block.

        Messages will not be sent or received until start() has been called on the returned chain. You may not call createChain from a manager or chain whose shutdown() methods have returned (will throw an exception). Managers may call createChain and destroy from multiple threads simultaneously.

        Typical usage is to use Chain.getTransport() to initialize any transport-specific configuration on the newly created instance, and then call Chain.start().

        Parameters:
        chainInstanceIdSuffix - A string identifier which will be suffixed onto "managerName-" to uniquely identify the new chain instance. Caution: A small amount of memory is allocated for each unique chain instance identifier. This memory is not freed when the chain is destroyed. Therefore, if you are creating many chains, consider reusing old chain instance identifiers. If you create more than 1000 unique identifiers, a warning is written to the correlator log file to notify you of this. You cannot have two active chains with the same chain instance identifier, so only reuse identifiers which are no longer in use.
        dynamicChainDefinition - The definition of the chain to create. This should usually be one of the chain definitions passed to the manager in the ChainManagerConstructorParameters, usually using the AbstractChainManager.getChainDefinition() or AbstractChainManager.getChainDefinition(String) helper methods. Not null.
        substitutions - Map of key/value pairs to be replaced in the chain definition using @{KEY} tags. null is treated the same as an empty map.
        defaultChannelTowardsHost - Default channel to use for sending a message towards the host if no channel is specified on the message; use null or empty string for no default. It is an error to specify non-empty defaultChannelTowardsHost value if defaultChannel is also specified for the host plug-in.
        subscribeChannels - The set of channels that the chain should be subscribed to (for messages from the host to the transport). null is treated the same as an empty list. Note that any value specified for this in the host configuration is ignored when this method is used to create a chain.
        Returns:
        An object representing the new dynamic chain instance.
        Throws:
        java.lang.Exception - if the chain definition is invalid, or if any of the plug-in constructors on the chain to be created throw an exception.
      • addChannelLifecycleListener

        void addChannelLifecycleListener​(ChannelLifecycleListener listener,
                                         java.lang.String channelPrefix)
        Register a listener to get a callback when interested channel is created/destroyed.

        Calling this method from a manager whose shutdown() method has returned will throw an exception. This method is thread safe and may be called from multiple threads simultaneously.

        The call to addChannelLifecycleListener is blocked until listener is immediately notified of all the channels already created matching the channelPrefix in the same thread which calls addChannelLifecycleListener.

        Parameters:
        listener - The listener which will get the notification when a channel starting with the channelPrefix is created or destroyed. It is an error to pass null.
        channelPrefix - The channel prefix for which listener should get callback. Specify an empty string to get notifications for all channels. It is an error to pass null.
        See Also:
        AbstractChainManager