JXTA

net.jxta.platform
Class NetworkManager

java.lang.Object
  extended by net.jxta.platform.NetworkManager
All Implemented Interfaces:
EventListener, RendezvousListener

public class NetworkManager
extends Object
implements RendezvousListener

NetworkManager provides a simplified JXTA platform configuration abstraction, and provides a JXTA platform life-cycle management. The node configuration is created during construction of this object and can be obtained for fine tuning or alteration. Note that all alterations must be done prior to calling #startNetwork(), otherwise the default configuration is used. Configuration persistence is on by default and maybe overridden by call to #setEnableConfigPersistence

NetworkManager defines six abstractions of a node configurations as follows : ADHOC : A node which typically deployed in an ad-hoc network EDGE : In addition to supporting ADHOC function, an Edge node can attach to a infrastructure (a Rendezvous, Relay, or both) RENDEZVOUS: provides network bootstrapping services, such as discovery, pipe resolution, etc. RELAY: provides message relaying services, enabling cross firewall traversal PROXY: provide JXME JXTA for J2ME proxying services SUPER: provide the functionality of a Rendezvous, Relay, Proxy node.


Nested Class Summary
static class NetworkManager.ConfigMode
          Define node standard node operating modes
 
Field Summary
protected  URI publicSeedingRdvURI
           
protected  URI publicSeedingRelayURI
           
 
Constructor Summary
NetworkManager(NetworkManager.ConfigMode mode, String instanceName)
          Creates NetworkManger instance with default instance home set to "$CWD"/.jxta" At this point, alternate Infrastructure PeerGroupID maybe specified, as well as a PeerID. if neither are specified, the default NetPeerGroupID will be used, and a new PeerID will be generated.
NetworkManager(NetworkManager.ConfigMode mode, String instanceName, URI instanceHome)
          Creates NetworkManger instance.
 
Method Summary
 NetworkConfigurator getConfigurator()
          Returns the NetworkConfigurator for additional tuning
 PeerGroupID getInfrastructureID()
          Getter for property 'infrastructureID'.
 URI getInstanceHome()
          Getter for property 'instanceHome'.
 String getInstanceName()
          Getter for property 'instanceName'.
 NetworkManager.ConfigMode getMode()
          Getter for property node operating 'mode'.
 PeerGroup getNetPeerGroup()
          Gets the netPeerGroup object
 PeerID getPeerID()
          Getter for property 'peerID'.
 boolean getUseDefaultSeeds()
          Returns true if useDefaultSeeds is set to true
 boolean isConfigPersistent()
          Getter for property 'configPersistent'.
static void login(PeerGroup group, char[] keystore_password, char[] principal_password)
          Establishes group credential.
 void registerShutdownHook()
          Registers a Runtime shutdown hook to cleanly shutdown the JXTA platform
 void rendezvousEvent(RendezvousEvent event)
          rendezvousEvent the rendezvous event
 void setConfigPersistent(boolean persisted)
          Setter for property 'configPersistent'. if disabled a PlatformConfig is not persisted.
 void setInfrastructureID(PeerGroupID infrastructureID)
          Setter for property 'infrastructureID'.
 void setInstanceHome(URI instanceHome)
          Setter for property 'instanceHome'.
 void setInstanceName(String instanceName)
          Setter for property 'instanceName'.
 void setMode(NetworkManager.ConfigMode mode)
          Setter for property 'mode'.
 void setPeerID(PeerID peerID)
          Setter for property 'peerID'.
 void setUseDefaultSeeds(boolean useDefaultSeeds)
          if true uses the public rendezvous seeding service
 PeerGroup startNetwork()
          Creates and starts the JXTA infrastructure peer group (aka NetPeerGroup) based on the specified mode template.
 void stopNetwork()
          Stops and unreferences the NetPeerGroup
 void unregisterShutdownHook()
          Unregisters a Runtime shutdown hook to cleanly shutdown the JXTA platform
 boolean waitForRendezvousConnection(long timeout)
          Blocks only, if not connected to a rendezvous, or until a connection to rendezvous node occurs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

publicSeedingRdvURI

protected final transient URI publicSeedingRdvURI

publicSeedingRelayURI

protected final transient URI publicSeedingRelayURI
Constructor Detail

NetworkManager

public NetworkManager(NetworkManager.ConfigMode mode,
                      String instanceName)
               throws IOException
Creates NetworkManger instance with default instance home set to "$CWD"/.jxta" At this point, alternate Infrastructure PeerGroupID maybe specified, as well as a PeerID. if neither are specified, the default NetPeerGroupID will be used, and a new PeerID will be generated. Also note the default seeding URIs are the to development. Alternate values must be specified, if desired, prior to a call to startNetwork()

Parameters:
mode - Operating mode the node operating NetworkManager.ConfigMode
instanceName - Node name
Throws:
IOException - if an io error occurs

NetworkManager

public NetworkManager(NetworkManager.ConfigMode mode,
                      String instanceName,
                      URI instanceHome)
               throws IOException
Creates NetworkManger instance. At this point, alternate Infrastructure PeerGroupID maybe specified, as well as a PeerID. if neither are specified, the default NetPeerGroupID will be used, and a new PeerID will be generated. Also note the default seeding URIs are the to development. Alternate values must be specified, if desired, prior to a call to startNetwork()

Parameters:
mode - Operating mode the node operating NetworkManager.ConfigMode
instanceName - Node name
instanceHome - instance home is a uri to the instance persistent store (aka Cache Manager store home)
Throws:
IOException - if an io error occurs
Method Detail

getConfigurator

public NetworkConfigurator getConfigurator()
                                    throws IOException
Returns the NetworkConfigurator for additional tuning

Returns:
the NetworkConfigurator for additional tuning
Throws:
IOException - if an io error occurs

getInfrastructureID

public PeerGroupID getInfrastructureID()
Getter for property 'infrastructureID'.

Returns:
Value for property 'infrastructureID'.

setInfrastructureID

public void setInfrastructureID(PeerGroupID infrastructureID)
Setter for property 'infrastructureID'.

Parameters:
infrastructureID - Value to set for property 'infrastructureID'.

getInstanceName

public String getInstanceName()
Getter for property 'instanceName'.

Returns:
Value for property 'instanceName'.

setInstanceName

public void setInstanceName(String instanceName)
Setter for property 'instanceName'.

Parameters:
instanceName - Value to set for property 'instanceName'.

getInstanceHome

public URI getInstanceHome()
Getter for property 'instanceHome'.

Returns:
Value for property 'instanceHome'.

setInstanceHome

public void setInstanceHome(URI instanceHome)
Setter for property 'instanceHome'.

Parameters:
instanceHome - Value to set for property 'instanceHome'.

getMode

public NetworkManager.ConfigMode getMode()
Getter for property node operating 'mode'.

Returns:
Value for property 'mode'.

setMode

public void setMode(NetworkManager.ConfigMode mode)
             throws IOException
Setter for property 'mode'.

Parameters:
mode - Value to set for property 'mode'.
Throws:
IOException - if an io error occurs

getPeerID

public PeerID getPeerID()
Getter for property 'peerID'.

Returns:
Value for property 'peerID'.

setPeerID

public void setPeerID(PeerID peerID)
Setter for property 'peerID'.

Parameters:
peerID - Value to set for property 'peerID'.

isConfigPersistent

public boolean isConfigPersistent()
Getter for property 'configPersistent'.

Returns:
Value for property 'configPersistent'.

setConfigPersistent

public void setConfigPersistent(boolean persisted)
Setter for property 'configPersistent'. if disabled a PlatformConfig is not persisted. It assumed that the PeerID is will be set, or a new PeerID will always be generated.

Parameters:
persisted - Value to set for property 'configPersistent'.

startNetwork

public PeerGroup startNetwork()
                       throws PeerGroupException,
                              IOException
Creates and starts the JXTA infrastructure peer group (aka NetPeerGroup) based on the specified mode template. This class also registers a listener for rendezvous events.

Returns:
The Net Peer Group
Throws:
PeerGroupException - if the group fails to initialize
IOException - if an io error occurs

login

public static void login(PeerGroup group,
                         char[] keystore_password,
                         char[] principal_password)
                  throws PeerGroupException,
                         ProtocolNotSupportedException
Establishes group credential. This is a required step when planning to to utilize TLS messengers or secure pipes

Parameters:
group - peer group to establish credentials in
keystore_password - The passphrase for the keystore. This is a char[] rather than a String so that it can be blanked after use.
principal_password - The passphrase for the identity. This is a char[] rather than a String so that it can be blanked after use.
Throws:
PeerGroupException - if group credentials were rejected
ProtocolNotSupportedException - if authenticator rejected the credential

stopNetwork

public void stopNetwork()
Stops and unreferences the NetPeerGroup


getNetPeerGroup

public PeerGroup getNetPeerGroup()
Gets the netPeerGroup object

Returns:
The netPeerGroup value

waitForRendezvousConnection

public boolean waitForRendezvousConnection(long timeout)
Blocks only, if not connected to a rendezvous, or until a connection to rendezvous node occurs.

Parameters:
timeout - timeout in milliseconds, a zero timeout of waits forever
Returns:
true if connected to a rendezvous, false otherwise

rendezvousEvent

public void rendezvousEvent(RendezvousEvent event)
rendezvousEvent the rendezvous event

Specified by:
rendezvousEvent in interface RendezvousListener
Parameters:
event - rendezvousEvent

setUseDefaultSeeds

public void setUseDefaultSeeds(boolean useDefaultSeeds)
if true uses the public rendezvous seeding service

Parameters:
useDefaultSeeds - if true uses the default development seeding service

getUseDefaultSeeds

public boolean getUseDefaultSeeds()
Returns true if useDefaultSeeds is set to true

Returns:
true if useDefaultSeeds is set to true

registerShutdownHook

public void registerShutdownHook()
Registers a Runtime shutdown hook to cleanly shutdown the JXTA platform


unregisterShutdownHook

public void unregisterShutdownHook()
Unregisters a Runtime shutdown hook to cleanly shutdown the JXTA platform


JXSE