Class ProtocolManager
- java.lang.Object
-
- org.jcsp.net.ProtocolManager
-
public class ProtocolManager extends java.lang.Object
The
ProtocolManager
class is a singleton class. See the documentation for theNode
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 aLinkServer
that listens on a specifiedNodeAddressID
. In order to connect to a Node'sLinkServer
, a Node must have a matching protocol client installed in its localProtocolManager
.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 givenProfile
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Hashtable
addressSpecifications
private static ProtocolManager
instance
private java.util.Hashtable
linkServers
private java.util.Hashtable
protocolClients
This Hashtable contains protocolID's as the keys which map to builders that build the links for that protocol.private java.util.Hashtable
protocolSpecifications
-
Constructor Summary
Constructors Modifier Constructor Description private
ProtocolManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Specification[]
getAddressSpecifications(NodeAddressID addressID)
Returns an array ofSpecification
objects that are held for a specified local address.(package private) static ProtocolManager
getInstance()
Specification[]
getProtocolSpecifications(ProtocolID protocolID)
Returns an array ofSpecification
objects that are held for a specified protocol.boolean
installProtocolClient(ProtocolID protocolID, Specification[] specifications, java.util.Hashtable settings)
Installs a protocol client so that links can be established to Nodes withLinkServer
processes listening on the specified protocol.boolean
installProtocolServer(NodeAddressID addressID, Specification[] specifications)
Installs aLinkServer
listening on a specifiedNodeAddressID
and holds the specified set ofSpecification
objects against the address.boolean
removeProtocolClient(ProtocolID protocolID)
Removes the installed protocol client for a specified protocol.boolean
stopProtocolServer(NodeAddressID addressID)
Stops theLinkServer
that is listening on the specified address.
-
-
-
Field Detail
-
instance
private static ProtocolManager instance
-
linkServers
private java.util.Hashtable linkServers
-
protocolClients
private java.util.Hashtable protocolClients
This Hashtable contains protocolID's as the keys which map to builders that build the links for that protocol.
-
addressSpecifications
private java.util.Hashtable addressSpecifications
-
protocolSpecifications
private java.util.Hashtable protocolSpecifications
-
-
Method Detail
-
getInstance
static ProtocolManager getInstance()
-
getProtocolSpecifications
public Specification[] getProtocolSpecifications(ProtocolID protocolID)
Returns an array ofSpecification
objects that are held for a specified protocol.- Parameters:
protocolID
- theProtocolID
of a protocol- Returns:
- the specifications of the supplied protocol.
-
getAddressSpecifications
public Specification[] getAddressSpecifications(NodeAddressID addressID)
Returns an array ofSpecification
objects that are held for a specified local address.- Parameters:
addressID
- aNodeAddressID
that should match an address on which a localLinkServer
is listening.- Returns:
- the set of specifications that are held against the specified address.
-
installProtocolServer
public boolean installProtocolServer(NodeAddressID addressID, Specification[] specifications)
Installs aLinkServer
listening on a specifiedNodeAddressID
and holds the specified set ofSpecification
objects against the address.- Parameters:
addressID
- the address on which theLinkServer
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 theLinkServer
that is listening on the specified address.- Parameters:
addressID
- theNodeAddressID
on which theLinkServer
to stop is listening.- Returns:
true
if, after returning, noLinkServer
is listening on the specified adddress.
-
installProtocolClient
public boolean installProtocolClient(ProtocolID protocolID, Specification[] specifications, java.util.Hashtable settings)
Installs a protocol client so that links can be established to Nodes withLinkServer
processes listening on the specified protocol.- Parameters:
protocolID
- TheProtocolID
of the protocol to install.specifications
- The specification of the protocol being installed.settings
- aHashTable
that can contain settings that are passed to the protocol'sBuilder
.- 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
- theProtocolID
of the protocol client to remove.- Returns:
true
iff a matching protocol client has been successfully removed.
-
-