JXTA

net.jxta.instantp2p
Class PeerGroupApp

java.lang.Object
  |
  +--net.jxta.instantp2p.PeerGroupApp
Direct Known Subclasses:
InstantP2P, InstantP2PApp

public class PeerGroupApp
extends java.lang.Object
implements net.jxta.platform.Application


Constructor Summary
PeerGroupApp()
           
 
Method Summary
 void addGroup(net.jxta.protocol.PeerGroupAdvertisement groupAdv)
          Adds the PeerGroupAdvertisement to the list of discovered Groups in the PeerGroup
 void addPeer(net.jxta.protocol.PeerGroupAdvertisement peerAdv)
          Adds the PeerGroupAdvertisement to the list of discovered Peers in the PeerGroup
 void checkDiscoverResults()
          check results of discovery request
 net.jxta.protocol.PipeAdvertisement createPipeAdvertisement()
          creates a new PipeAdvertisment
 net.jxta.protocol.PeerGroupAdvertisement getAdvertisement()
          Returns the PeerGroupAdvertisement for this PeerGroupApp
 java.io.File getDirectory()
          Returns the Group Directory for storing persistent data
 net.jxta.discovery.Discovery getDiscovery()
          Returns the Discovery for the PeerGroup
 java.util.Enumeration getGids()
          Returns an Enumeration of the gid Strings of currently discovered Groups in the PeerGroup
 net.jxta.protocol.PeerGroupAdvertisement getGroup(java.lang.String gid)
          Returns the PeerGroupAdvertisement of the requested Group
 java.lang.String getGroupName()
          Returns the Group name for this PeerGroupApp
 java.util.Enumeration getGroups()
          Returns an Enumeration of the PeerGroupAdvertisements of currently discovered Groups in the PeerGroup
protected  net.jxta.protocol.PeerGroupAdvertisement getNewPeerGroupAdvertisement(java.lang.String name)
           
 PeerGroupApp getParentApp()
          Returns the parent PeerGroupApp for this PeerGroupApp
 net.jxta.protocol.PeerGroupAdvertisement getPeer(java.lang.String pid)
          Returns the PeerGroupAdvertisement of the requested Peer
 net.jxta.peergroup.PeerGroup getPeerGroup()
          Returns the PeerGroup for this PeerGroupApp
 java.util.Enumeration getPeers()
          Returns an Enumeration of the PeerGroupAdvertisements of currently discovered Peers in the PeerGroup
 java.util.Enumeration getPids()
          Returns an Enumeration of the pid Strings of currently discovered Peers in the PeerGroup
 net.jxta.pipe.Pipe getPipePolicy()
          Returns the PipePolicy for the PeerGroup
protected static java.io.File getRootDirectory()
           
 void init(net.jxta.peergroup.PeerGroup group, net.jxta.document.Advertisement adv)
          Initialize the application
protected  boolean isValidPeer(net.jxta.protocol.PeerGroupAdvertisement newPeerAdv)
           
 net.jxta.platform.Application joinGroup(java.lang.String gid)
          Joins the PeerGroup with the given gid The group is only joined if the group is in the list and has not already been joined
 net.jxta.platform.Application joinNewGroup(java.lang.String name)
          Creates a new PeerGroup with the given name and Joins the group
 net.jxta.document.Advertisement loadAdvertisement(java.io.File advFile)
          load the advertisement located in the given file
 void pollDiscover(boolean flag)
          set polling flag state if true, poll local discover results at regular intervals
 void removeGroup(java.lang.String gid)
          Removes the PeerGroupAdvertisement for the given pid from the list of discovered Groups in the PeerGroup
 void removePeer(java.lang.String pid)
          Removes the PeerGroupAdvertisement for the given pid from the list of discovered Peers in the PeerGroup
protected  boolean replaceTest(net.jxta.protocol.PeerGroupAdvertisement newPeerAdv, net.jxta.protocol.PeerGroupAdvertisement oldPeerAdv)
           
 void requestRemoteDiscover()
          request remote discovery request
 void saveAdvertisement(net.jxta.document.Advertisement adv, java.io.File advFile)
          save the advertisement to the given file
 void selectPeer(net.jxta.protocol.PeerGroupAdvertisement pgAdv)
           
 void setApp(PeerGroupApp app)
           
 void setParentApp(PeerGroupApp parent)
          Set the parent PeerGroupApp for this PeerGroupApp
protected static void setRootDirectory(java.io.File newRootDir)
           
 int startApp(java.lang.String[] str)
           
protected  void startPolicy()
          Protected Methods to be overloaded by subclasses
 void stopApp()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeerGroupApp

public PeerGroupApp()
Method Detail

init

public void init(net.jxta.peergroup.PeerGroup group,
                 net.jxta.document.Advertisement adv)
          throws net.jxta.exception.PeerGroupException
Initialize the application
Specified by:
init in interface net.jxta.platform.Application
Parameters:
group - PeerGroup this application is started from
Since:
JXTA 1.0

startApp

public int startApp(java.lang.String[] str)
Specified by:
startApp in interface net.jxta.platform.Application

stopApp

public void stopApp()
Specified by:
stopApp in interface net.jxta.platform.Application

getPeerGroup

public net.jxta.peergroup.PeerGroup getPeerGroup()
Returns the PeerGroup for this PeerGroupApp
Returns:
the PeerGroup
Since:
JXTA 1.0

getAdvertisement

public net.jxta.protocol.PeerGroupAdvertisement getAdvertisement()
Returns the PeerGroupAdvertisement for this PeerGroupApp
Returns:
the PeerGroupAdvertisement
Since:
JXTA 1.0

getGroupName

public java.lang.String getGroupName()
Returns the Group name for this PeerGroupApp
Returns:
the name for this group
Since:
JXTA 1.0

getParentApp

public PeerGroupApp getParentApp()
Returns the parent PeerGroupApp for this PeerGroupApp
Returns:
the parent PeerGroupApp
Since:
JXTA 1.0

setParentApp

public void setParentApp(PeerGroupApp parent)
Set the parent PeerGroupApp for this PeerGroupApp
Parameters:
parent - new parent PeerGroupApp
Since:
JXTA 1.0

getDirectory

public java.io.File getDirectory()
Returns the Group Directory for storing persistent data
Returns:
File that points to group directory
Since:
JXTA 1.0

getDiscovery

public net.jxta.discovery.Discovery getDiscovery()
Returns the Discovery for the PeerGroup
Returns:
the Discovery for the PeerGroup
Since:
JXTA 1.0

getPipePolicy

public net.jxta.pipe.Pipe getPipePolicy()
Returns the PipePolicy for the PeerGroup
Returns:
the PipePolicy for the PeerGroup
Since:
JXTA 1.0

getPids

public java.util.Enumeration getPids()
Returns an Enumeration of the pid Strings of currently discovered Peers in the PeerGroup
Returns:
an Enumeration of the pid Strings
Since:
JXTA 1.0

getPeer

public net.jxta.protocol.PeerGroupAdvertisement getPeer(java.lang.String pid)
Returns the PeerGroupAdvertisement of the requested Peer
Parameters:
pid - Pid of the requested Peer
Since:
JXTA 1.0

addPeer

public void addPeer(net.jxta.protocol.PeerGroupAdvertisement peerAdv)
Adds the PeerGroupAdvertisement to the list of discovered Peers in the PeerGroup
Parameters:
peer - PeerGroupAdvertisement of the Peer to add
Since:
JXTA 1.0

removePeer

public void removePeer(java.lang.String pid)
Removes the PeerGroupAdvertisement for the given pid from the list of discovered Peers in the PeerGroup
Parameters:
pid - Pid of the Peer to remove
Since:
JXTA 1.0

getPeers

public java.util.Enumeration getPeers()
Returns an Enumeration of the PeerGroupAdvertisements of currently discovered Peers in the PeerGroup
Returns:
an Enumeration of the PeerGroupAdvertisements
Since:
JXTA 1.0

getGids

public java.util.Enumeration getGids()
Returns an Enumeration of the gid Strings of currently discovered Groups in the PeerGroup
Returns:
an Enumeration of the gid Strings
Since:
JXTA 1.0

getGroup

public net.jxta.protocol.PeerGroupAdvertisement getGroup(java.lang.String gid)
Returns the PeerGroupAdvertisement of the requested Group
Parameters:
gid - Gid of the requested Group
Since:
JXTA 1.0

addGroup

public void addGroup(net.jxta.protocol.PeerGroupAdvertisement groupAdv)
Adds the PeerGroupAdvertisement to the list of discovered Groups in the PeerGroup
Parameters:
peer - PeerGroupAdvertisement of the Group to add
Since:
JXTA 1.0

removeGroup

public void removeGroup(java.lang.String gid)
Removes the PeerGroupAdvertisement for the given pid from the list of discovered Groups in the PeerGroup
Parameters:
gid - Gid of the Group to remove
Since:
JXTA 1.0

getGroups

public java.util.Enumeration getGroups()
Returns an Enumeration of the PeerGroupAdvertisements of currently discovered Groups in the PeerGroup
Returns:
an Enumeration of the PeerGroupAdvertisements
Since:
JXTA 1.0

pollDiscover

public void pollDiscover(boolean flag)
set polling flag state if true, poll local discover results at regular intervals
Parameters:
flag - new polling flag value
Since:
JXTA 1.0

joinGroup

public net.jxta.platform.Application joinGroup(java.lang.String gid)
                                        throws net.jxta.exception.PeerGroupException
Joins the PeerGroup with the given gid The group is only joined if the group is in the list and has not already been joined
Parameters:
gid - Gid of the requested Group to join
Returns:
the Application for the joined group
Since:
JXTA 1.0

joinNewGroup

public net.jxta.platform.Application joinNewGroup(java.lang.String name)
                                           throws net.jxta.exception.PeerGroupException
Creates a new PeerGroup with the given name and Joins the group
Parameters:
gid - Gid of the requested Group to join
Returns:
the Application for the new group
Since:
JXTA 1.0

requestRemoteDiscover

public void requestRemoteDiscover()
request remote discovery request
Since:
JXTA 1.0

checkDiscoverResults

public void checkDiscoverResults()
check results of discovery request
Since:
JXTA 1.0

loadAdvertisement

public net.jxta.document.Advertisement loadAdvertisement(java.io.File advFile)
load the advertisement located in the given file
Parameters:
advFile - file that contains the Advertisement
Returns:
the Advertisement that the file contains or null if error
Since:
JXTA 1.0

saveAdvertisement

public void saveAdvertisement(net.jxta.document.Advertisement adv,
                              java.io.File advFile)
save the advertisement to the given file
Parameters:
adv - the Advertisement to save
advFile - file to write the Advertisement
Since:
JXTA 1.0

createPipeAdvertisement

public net.jxta.protocol.PipeAdvertisement createPipeAdvertisement()
creates a new PipeAdvertisment
Returns:
the new PipeAdvertisement
Since:
JXTA 1.0

startPolicy

protected void startPolicy()
                    throws net.jxta.exception.PeerGroupException
Protected Methods to be overloaded by subclasses

isValidPeer

protected boolean isValidPeer(net.jxta.protocol.PeerGroupAdvertisement newPeerAdv)

replaceTest

protected boolean replaceTest(net.jxta.protocol.PeerGroupAdvertisement newPeerAdv,
                              net.jxta.protocol.PeerGroupAdvertisement oldPeerAdv)

getRootDirectory

protected static java.io.File getRootDirectory()

setRootDirectory

protected static void setRootDirectory(java.io.File newRootDir)

setApp

public void setApp(PeerGroupApp app)

selectPeer

public void selectPeer(net.jxta.protocol.PeerGroupAdvertisement pgAdv)

getNewPeerGroupAdvertisement

protected net.jxta.protocol.PeerGroupAdvertisement getNewPeerGroupAdvertisement(java.lang.String name)
                                                                         throws net.jxta.exception.PeerGroupException

JXTA