public class TCPIPNodeFactory extends java.lang.Object implements NodeFactory
Default factory for simple initialisations using the TCPIPv4 protocol package.
Other constructors can be used to specify a particular CNS server. The default behaviour will extract a CNS server from the system property "org.jcsp.tcpip.DefaultCNSServer" with the server specified as a name or IP address with optional port number.
If built with 1.4 or higher the user preferences will also be checked but only if a runtime supporting the preferences is available. If not present the system preferences will then be checked.
Modifier and Type | Field and Description |
---|---|
private NodeAddressID |
cnsServer
Address of the CNS server.
|
private int |
localPort
Port number to use for the local link server.
|
private SecurityService |
security
Optional security service to install.
|
Constructor and Description |
---|
TCPIPNodeFactory()
Default constructor, connecting to the local host on the default CNS port or to a host name
in the system properties.
|
TCPIPNodeFactory(java.lang.String cnsServer)
Connect to the named host on the default CNS port.
|
TCPIPNodeFactory(java.lang.String cnsServerAddress,
int cnsServerPort)
Connect to a named host on a specific port.
|
Modifier and Type | Method and Description |
---|---|
private NodeAddressID |
construct(java.lang.String cnsServer)
Split the server string into a server and port component on the : character.
|
private NodeAddressID |
construct(java.lang.String cnsServerAddress,
int cnsServerPort)
Construct the server address, assuming the local host if none is specified.
|
private java.lang.String |
getServerFromPrefs()
This code was moved into this method from the constructor below
in the hope that code would compile on 1.4 and still run on 1.3 and 1.2,
|
NodeKey |
initNode(Node node,
Node.Attributes attribs)
Initialise the node to listen on all local addresses, and start a CNS service.
|
static NodeFactory |
instantiate()
Constructs an instance of this class.
|
void |
setLocalPort(int port)
Sets the port number that should be used.
|
void |
setSecurityAuthority(SecurityService security)
Sets the security service to be used.
|
private final NodeAddressID cnsServer
private int localPort
private SecurityService security
public TCPIPNodeFactory()
public TCPIPNodeFactory(java.lang.String cnsServer)
null
then the CNS service will not be loaded.cnsServer
- name of serverpublic TCPIPNodeFactory(java.lang.String cnsServerAddress, int cnsServerPort)
cnsServerAddress
- name of the servercnsServerPort
- port to connect topublic static NodeFactory instantiate()
private NodeAddressID construct(java.lang.String cnsServerAddress, int cnsServerPort)
cnsServerAddress
- address of CNS server or null to use the local host.cnsServerPort
- port numberprivate NodeAddressID construct(java.lang.String cnsServer)
construct
method.cnsServer
- server with optional port numberprivate java.lang.String getServerFromPrefs()
public NodeKey initNode(Node node, Node.Attributes attribs) throws NodeInitFailedException
initNode
in interface NodeFactory
node
- the node to be initializedattribs
- access to the restricted node attributesNodeInitFailedException
- if a problem occurspublic void setLocalPort(int port)
port
- the port number, 0 <= port < 65536.public void setSecurityAuthority(SecurityService security)
security
- the new security authority.