com.tibco.be.custom.channel

## Class BaseChannel

- java.lang.Object
- - com.tibco.be.custom.channel.BaseChannel

- All Implemented Interfaces:
    Channel

      public abstract class BaseChannel
      extends java.lang.Object
      implements Channel

  A `BaseChannel` represents a channel or a transport to which BE can connect, and which can receive and send BE `Event` objects.

  Each `Channel` instance has a set of `BaseDestination`, each of which represent an end-points that the transport can use.

  The execution sequence in a Channel's lifecycle is as follows : `init()` -> `connect()` -> `start()` -> `close()`

  Users must take care of this sequence while providing the Channel's implementation

  `connect()` - Default implementation connects to all of the underlying destinations

  `start()` - Default implementation starts all of the underlying destinations

  `close()` - Default implementation closes all of the underlying destinations

  If needed user can override these methods and provide own implementation

  Since:
    5.4

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CustomChannelConfig` | `config` Stores the configuration of this Channel.
    `protected java.util.Map` | `destinations` Stores all the `Destination` instances for this `Channel`.
    `protected java.lang.String` | `uri` Stores the location of the channel in its containing project.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` A life cycle method used by the framework to close the channel and its associated resources.
    `void` | `connect()` A life cycle method used by the framework to connect the channels's destinations to its transport.
    `java.util.Properties` | `getBeProperties()` Gets BE runtime properties for use in the user channel.
    `java.util.Properties` | `getChannelProperties()` Gets the channel properties as defined in its `drivers.xml` for use in the user channel.
    `java.util.Map` | `getDestinations()` Get all the destinations of this `Channel`
    `java.lang.Object` | `getGlobalVariableValue(java.lang.String name)` Utility method that gets the value of the Global Variable as specified in the `BE Project` that contains this `Channel`.
    `Logger` | `getLogger()` Gets the runtime Logger instance for use in the user channel.
    `java.lang.String` | `getUri()` Gets the full path of the `Channel` in the project.
    `void` | `init()` A life cycle method used by the framework to initialize the channel.
    `void` | `resume()` A life cycle method used by the framework to resume the channel This default implementation will sequentially invoke `Destination.resume()` on each of its destinations.
    `void` | `setDestinations(java.util.Map destinations)` The framework uses this method to set the Channels destination objects
    `void` | `start()` A life cycle method used by the framework to start receiving messages from its destinations.
    `void` | `suspend()` A life cycle method used by the framework to suspend the channel This default implementation will sequentially invoke `Destination.suspend()` on each of its destinations.

    - ### Methods inherited from interface com.tibco.be.custom.channel.framework.Channel

      `getState, stop`

- - ### Field Detail

    - #### config

          protected CustomChannelConfig config

      Stores the configuration of this Channel.
      Since:
        5.4

    - #### uri

          protected java.lang.String uri

      Stores the location of the channel in its containing project.
      Since:
        5.4

    - #### destinations

          protected java.util.Map destinations

      Stores all the `Destination` instances for this `Channel`.
      Since:
        5.4

  - ### Method Detail

    - #### init

          public void init()

      A life cycle method used by the framework to initialize the channel. This default implementation sequentially initializes each of its Destinations by invoking `Destination.init()` User extensions should override this method to perform channel specific initializations. If overridden, it the users responsibility to connect on each of its destinations. The overridden method can use `super.connect()` to do that. `super.init()` in order to initialize its destinations.
      Specified by:
        `init` in interface `Channel`
      Throws:
        `java.lang.Exception` - : propagates the exception thrown by any of its destination's init() methods
      Since:
        5.4
      See Also:
        `BaseChannel.connect()`, `BaseChannel.close()`

    - #### connect

          public void connect()

      A life cycle method used by the framework to connect the channels's destinations to its transport. This default implementation will sequentially invoke `Destination.connect()` on each of its destinations. If overridden, it the users responsibility to invoke connect on each of its destinations. The overridden method can use `super.connect()` to do that.
      Specified by:
        `connect` in interface `Channel`
      Throws:
        `java.lang.Exception` - encountered while invoking connect on each of its destinations.
      Since:
        5.4
      See Also:
        `BaseDestination.connect()`, `BaseChannel.init()`, `BaseChannel.close()`

    - #### start

          public void start()

      A life cycle method used by the framework to start receiving messages from its destinations. This default implementation will sequentially invoke `Destination.start()` on each of its destinations. If overridden, it is the users responsibility to start all its destinations. The overridden method can use `super.start()` to do that.
      Specified by:
        `start` in interface `Channel`
      Throws:
        `java.lang.Exception` - encountered exception
      Since:
        5.4
      See Also:
        `BaseDestination.start()`, `BaseChannel.connect()`, `BaseChannel.close()`

    - #### close

          public void close()

      A life cycle method used by the framework to close the channel and its associated resources. This default implementation will sequentially invoke `Destination.cose()` on each of its destinations. If overridden, it is the users responsibility to start all its destinations. The overridden method can use `super.close()` to do that.
      Specified by:
        `close` in interface `Channel`
      Throws:
        `java.lang.Exception` - encountered exception
      Since:
        5.4
      See Also:
        `BaseChannel.init()`

    - #### suspend

          public void suspend()

      A life cycle method used by the framework to suspend the channel This default implementation will sequentially invoke `Destination.suspend()` on each of its destinations. If overridden, it is the users responsibility to suspend all its destinations. The overridden method can use `super.suspend()` to do that.
      Since:
        5.4

    - #### resume

          public void resume()

      A life cycle method used by the framework to resume the channel This default implementation will sequentially invoke `Destination.resume()` on each of its destinations. If overridden, it is the users responsibility to resume all its destinations. The overridden method can use `super.resume()` to do that.
      Since:
        5.4

    - #### getUri

          public java.lang.String getUri()

      Gets the full path of the `Channel` in the project.
      Returns:
        a String URI.
      Since:
        5.4

    - #### getDestinations

          public java.util.Map getDestinations()

      Get all the destinations of this `Channel`
      Returns:
        a `Map` with the `String`URI of the Destination as its key and the associated `Destination` as its value
      Since:
        5.4

    - #### setDestinations

          public final void setDestinations(java.util.Map destinations)

      The framework uses this method to set the Channels destination objects
      Parameters:
        `destinations` - map of destination uri versus destination

    - #### getGlobalVariableValue

          public java.lang.Object getGlobalVariableValue(java.lang.String name)

      Utility method that gets the value of the Global Variable as specified in the `BE Project` that contains this `Channel`.
      Parameters:
        `name` - name which identifies the Global Variable
      Returns:
        the `GlobalVariables` of the containing `BE Project`.
      Since:
        5.4

    - #### getBeProperties

          public java.util.Properties getBeProperties()

      Gets BE runtime properties for use in the user channel.
      Returns:
        the runtime `Properties` of the BE application
      Since:
        5.4

    - #### getChannelProperties

          public java.util.Properties getChannelProperties()

      Gets the channel properties as defined in its `drivers.xml` for use in the user channel.
      Returns:
        the Channel properties.
      Since:
        5.4

    - #### getLogger

          public Logger getLogger()

      Gets the runtime Logger instance for use in the user channel.
      Returns:
        the `Logger` of the containing `BE Project`.
      Since:
        5.4