Package org.jcsp.net2
Class ChannelManager
java.lang.Object
org.jcsp.net2.ChannelManager
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Hashtable
The table containing the channels.private static int
The index for the next channel to be created.private static ChannelManager
Singleton instance of the ChannelManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(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
Allows getting of the singleton instance.(package private) void
removeChannel
(ChannelData data) Removes a channel from the table.
-
Field Details
-
index
private static int indexThe 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
The table containing the channels. An Integer (object wrapped int) is used as the key, and the ChannelData as the value. -
instance
Singleton instance of the ChannelManager
-
-
Constructor Details
-
ChannelManager
private ChannelManager()Private default constructor. Used for the singleton instance.
-
-
Method Details
-
getInstance
Allows getting of the singleton instance.- Returns:
- The singleton instance of the ChannelManager
-
create
Allocates a new number to the channel, and stores it in the table.- Parameters:
cd
- The ChannelData for the channel
-
create
Stores a channel in the given index in the table.- Parameters:
idx
- The index to use for the channelcd
- The ChannelData for the channel- Throws:
IllegalArgumentException
- If a channel of the given index already exists.
-
getChannel
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
Removes a channel from the table.- Parameters:
data
- ChannelData for channel to remove
-