Package org.jcsp.net

# Class ProtocolManager

java.lang.Object
org.jcsp.net.ProtocolManager

public class ProtocolManager extends Object

The `ProtocolManager` class is a singleton class. See the documentation for the `Node` class for information on how to obtain a reference to its instance.

A reference to a Node's `ProtocolManager` allows the Nodes installed protocols to be managed. Installing a protocol server creates a `LinkServer` that listens on a specified `NodeAddressID`. In order to connect to a Node's `LinkServer`, a Node must have a matching protocol client installed in its local `ProtocolManager`.

When protocol clients and servers are installed, an array of `Specification` objects can be supplied. These are specifications that the client or server meets. The specifications for a given protocol can be obtained and then used to test whether a set of specifications match a given `Profile`.

Author:
  Quickstone Technologies Limited

## Method Summary

Modifier and Type
Method
Description
`org.jcsp.net.Specification[]`
`getAddressSpecifications(NodeAddressID addressID)`
Returns an array of `Specification` objects that are held for a specified local address.
`org.jcsp.net.Specification[]`
`getProtocolSpecifications(ProtocolID protocolID)`
Returns an array of `Specification` objects that are held for a specified protocol.
`boolean`
`installProtocolClient(ProtocolID protocolID, org.jcsp.net.Specification[] specifications, Hashtable settings)`
Installs a protocol client so that links can be established to Nodes with `LinkServer` processes listening on the specified protocol.
`boolean`
`installProtocolServer(NodeAddressID addressID, org.jcsp.net.Specification[] specifications)`
Installs a `LinkServer` listening on a specified `NodeAddressID` and holds the specified set of `Specification` objects against the address.
`boolean`
`removeProtocolClient(ProtocolID protocolID)`
Removes the installed protocol client for a specified protocol.
`boolean`
`stopProtocolServer(NodeAddressID addressID)`
Stops the `LinkServer` that is listening on the specified address.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### getProtocolSpecifications

public org.jcsp.net.Specification[] getProtocolSpecifications(ProtocolID protocolID)
Returns an array of `Specification` objects that are held for a specified protocol.

Parameters:
  `protocolID` - the `ProtocolID` of a protocol
Returns:
  the specifications of the supplied protocol.

### getAddressSpecifications

public org.jcsp.net.Specification[] getAddressSpecifications(NodeAddressID addressID)
Returns an array of `Specification` objects that are held for a specified local address.

Parameters:
  `addressID` - a `NodeAddressID` that should match an address on which a local `LinkServer` is listening.
Returns:
  the set of specifications that are held against the specified address.

### installProtocolServer

public boolean installProtocolServer(NodeAddressID addressID, org.jcsp.net.Specification[] specifications)
Installs a `LinkServer` listening on a specified `NodeAddressID` and holds the specified set of `Specification` objects against the address.

Parameters:
  `addressID` - the address on which the `LinkServer` should be started.
  `specifications` - the specifications to hold against the address.
Returns:
  `true` iff the server is successfully installed.

### stopProtocolServer

public boolean stopProtocolServer(NodeAddressID addressID)
Stops the `LinkServer` that is listening on the specified address.

Parameters:
  `addressID` - the `NodeAddressID` on which the `LinkServer` to stop is listening.
Returns:
  `true` if, after returning, no `LinkServer` is listening on the specified adddress.

### installProtocolClient

public boolean installProtocolClient(ProtocolID protocolID, org.jcsp.net.Specification[] specifications, Hashtable settings)
Installs a protocol client so that links can be established to Nodes with `LinkServer` processes listening on the specified protocol.

Parameters:
  `protocolID` - The `ProtocolID` of the protocol to install.
  `specifications` - The specification of the protocol being installed.
  `settings` - a `HashTable` that can contain settings that are passed to the protocol's `Builder`.
Returns:
  `true` iff the protocol client is successfully installed or has already been installed.

### removeProtocolClient

public boolean removeProtocolClient(ProtocolID protocolID)
Removes the installed protocol client for a specified protocol.

Parameters:
  `protocolID` - the `ProtocolID` of the protocol client to remove.
Returns:
  `true` iff a matching protocol client has been successfully removed.