Package org.jcsp.net2

Class ChannelManager


  • final class ChannelManager
    extends java.lang.Object
    A class used to manage the networked channels on the Node. This is an internal object to JCSP networking. For a description of networked channels, see the relevant documentation.
    See Also:
    NetChannelInput, NetChannelOutput
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Hashtable channels
      The table containing the channels.
      private static int index
      The index for the next channel to be created.
      private static ChannelManager instance
      Singleton instance of the ChannelManager
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ChannelManager()
      Private default constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void create​(int idx, ChannelData cd)
      Stores a channel in the given index in the table.
      (package private) void create​(ChannelData cd)
      Allocates a new number to the channel, and stores it in the table.
      (package private) ChannelData getChannel​(int idx)
      Retrieves a channel from the table
      (package private) static ChannelManager getInstance()
      Allows getting of the singleton instance.
      (package private) void removeChannel​(ChannelData data)
      Removes a channel from the table.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • index

        private static int index
        The index for the next channel to be created. We start at 50 as it allows us to have up to 50 default channels, for example for use to connect to a Channel Name Server.
      • channels

        private final java.util.Hashtable channels
        The table containing the channels. An Integer (object wrapped int) is used as the key, and the ChannelData as the value.
      • instance

        private static ChannelManager instance
        Singleton instance of the ChannelManager
    • Constructor Detail

      • ChannelManager

        private ChannelManager()
        Private default constructor. Used for the singleton instance.
    • Method Detail

      • getInstance

        static ChannelManager getInstance()
        Allows getting of the singleton instance.
        Returns:
        The singleton instance of the ChannelManager
      • create

        void create​(ChannelData cd)
        Allocates a new number to the channel, and stores it in the table.
        Parameters:
        cd - The ChannelData for the channel
      • create

        void create​(int idx,
                    ChannelData cd)
             throws java.lang.IllegalArgumentException
        Stores a channel in the given index in the table.
        Parameters:
        idx - The index to use for the channel
        cd - The ChannelData for the channel
        Throws:
        java.lang.IllegalArgumentException - If a channel of the given index already exists.
      • getChannel

        ChannelData getChannel​(int idx)
        Retrieves a channel from the table
        Parameters:
        idx - Index in the table to retrieve the channel from.
        Returns:
        The ChannelData object for the channel.
      • removeChannel

        void removeChannel​(ChannelData data)
        Removes a channel from the table.
        Parameters:
        data - ChannelData for channel to remove