JXTA

net.jxta.test
Class PeerGroupAppImpl

java.lang.Object
  |
  +--net.jxta.test.PeerGroupAppImpl
Direct Known Subclasses:
PeerGroupAppTest, SharePeerGroupAppImpl

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


Constructor Summary
PeerGroupAppImpl()
           
 
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
 java.io.File getDirectory()
          Returns the Group Directory for storing persistent data
 net.jxta.discovery.Discovery getDiscoveryPolicy()
          Returns the DiscoveryPolicy for the PeerGroup
 java.lang.String getGid()
          Returns the gid String for this PeerGroupApp
 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)
          Protected Methods to be overloaded by subclasses
 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.protocol.PeerGroupAdvertisement getPeerAdvertisement()
          Returns the getPeerAdvertisement for this PeerGroupApp
 net.jxta.peergroup.PeerGroup getPeerGroup()
          Returns the PeerGroup for this PeerGroupApp
 net.jxta.protocol.PeerGroupAdvertisement getPeerGroupAdvertisement()
          Returns the getPeerGroupAdvertisement for this PeerGroup
 java.lang.String getPeerName()
          Returns the Peer name for this PeerGroupApp
 java.util.Enumeration getPeers()
          Returns an Enumeration of the PeerGroupAdvertisements of currently discovered Peers in the PeerGroup
 java.lang.String getPid()
          Returns the pid String for this PeerGroupApp
 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
 void init(net.jxta.peergroup.PeerGroup group, net.jxta.document.Advertisement adv)
          Initialize the application
protected  void initDone()
           
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 setParentApp(PeerGroupApp parent)
          Set the parent PeerGroupApp for this PeerGroupApp
 void setPeerName(java.lang.String name)
          Set the Peer name for this PeerGroupApp
 int startApp(java.lang.String[] str)
          PeerGroupApp Interface Methods
protected  void startPolicy()
           
 void stopApp()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeerGroupAppImpl

public PeerGroupAppImpl()
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)
PeerGroupApp Interface Methods
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
Specified by:
getPeerGroup in interface PeerGroupApp
Returns:
the PeerGroup
Since:
JXTA 1.0

getPeerGroupAdvertisement

public net.jxta.protocol.PeerGroupAdvertisement getPeerGroupAdvertisement()
Returns the getPeerGroupAdvertisement for this PeerGroup
Specified by:
getPeerGroupAdvertisement in interface PeerGroupApp
Returns:
the PeerGroupAdvertisement for this PeerGroup
Since:
JXTA 1.0

getPeerAdvertisement

public net.jxta.protocol.PeerGroupAdvertisement getPeerAdvertisement()
Returns the getPeerAdvertisement for this PeerGroupApp
Specified by:
getPeerAdvertisement in interface PeerGroupApp
Returns:
the PeerGroupAdvertisement for this Peer
Since:
JXTA 1.0

getPid

public java.lang.String getPid()
Returns the pid String for this PeerGroupApp
Specified by:
getPid in interface PeerGroupApp
Returns:
the pid String for the PeerGroup
Since:
JXTA 1.0

getGid

public java.lang.String getGid()
Returns the gid String for this PeerGroupApp
Specified by:
getGid in interface PeerGroupApp
Returns:
the gid String for the PeerGroup
Since:
JXTA 1.0

getGroupName

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

getPeerName

public java.lang.String getPeerName()
Returns the Peer name for this PeerGroupApp
Specified by:
getPeerName in interface PeerGroupApp
Returns:
the name for this peer
Since:
JXTA 1.0

setPeerName

public void setPeerName(java.lang.String name)
Set the Peer name for this PeerGroupApp
Specified by:
setPeerName in interface PeerGroupApp
Parameters:
name - new name for this Peer
Since:
JXTA 1.0

getParentApp

public PeerGroupApp getParentApp()
Returns the parent PeerGroupApp for this PeerGroupApp
Specified by:
getParentApp in interface PeerGroupApp
Returns:
the parent PeerGroupApp
Since:
JXTA 1.0

setParentApp

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

getDirectory

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

getDiscoveryPolicy

public net.jxta.discovery.Discovery getDiscoveryPolicy()
Returns the DiscoveryPolicy for the PeerGroup
Specified by:
getDiscoveryPolicy in interface PeerGroupApp
Returns:
the DiscoveryPolicy for the PeerGroup
Since:
JXTA 1.0

getPipePolicy

public net.jxta.pipe.Pipe getPipePolicy()
Returns the PipePolicy for the PeerGroup
Specified by:
getPipePolicy in interface PeerGroupApp
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
Specified by:
getPids in interface PeerGroupApp
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
Specified by:
getPeer in interface PeerGroupApp
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
Specified by:
addPeer in interface PeerGroupApp
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
Specified by:
removePeer in interface PeerGroupApp
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
Specified by:
getPeers in interface PeerGroupApp
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
Specified by:
getGids in interface PeerGroupApp
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
Specified by:
getGroup in interface PeerGroupApp
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
Specified by:
addGroup in interface PeerGroupApp
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
Specified by:
removeGroup in interface PeerGroupApp
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
Specified by:
getGroups in interface PeerGroupApp
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
Specified by:
pollDiscover in interface PeerGroupApp
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
Specified by:
joinGroup in interface PeerGroupApp
Parameters:
gid - Gid of the requested Group to join
Returns:
the JxtaApp 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
Specified by:
joinNewGroup in interface PeerGroupApp
Parameters:
gid - Gid of the requested Group to join
Returns:
the JxtaApp for the new group
Since:
JXTA 1.0

requestRemoteDiscover

public void requestRemoteDiscover()
request remote discovery request
Specified by:
requestRemoteDiscover in interface PeerGroupApp
Since:
JXTA 1.0

checkDiscoverResults

public void checkDiscoverResults()
check results of discovery request
Specified by:
checkDiscoverResults in interface PeerGroupApp
Since:
JXTA 1.0

loadAdvertisement

public net.jxta.document.Advertisement loadAdvertisement(java.io.File advFile)
load the advertisement located in the given file
Specified by:
loadAdvertisement in interface PeerGroupApp
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
Specified by:
saveAdvertisement in interface PeerGroupApp
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
Specified by:
createPipeAdvertisement in interface PeerGroupApp
Returns:
the new PipeAdvertisement
Since:
JXTA 1.0

getNewPeerGroupAdvertisement

protected net.jxta.protocol.PeerGroupAdvertisement getNewPeerGroupAdvertisement(java.lang.String name)
                                                                         throws net.jxta.exception.PeerGroupException
Protected Methods to be overloaded by subclasses

initDone

protected void initDone()
                 throws net.jxta.exception.PeerGroupException

startPolicy

protected void startPolicy()
                    throws net.jxta.exception.PeerGroupException

isValidPeer

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

replaceTest

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

JXTA