Project JXTA

net.jxta.impl.peergroup
Class StdPeerGroup

java.lang.Object
  extended by net.jxta.impl.peergroup.GenericPeerGroup
      extended by net.jxta.impl.peergroup.StdPeerGroup
All Implemented Interfaces:
CompatibilityEquater, PeerGroup, Module, Service
Direct Known Subclasses:
Platform, ShadowPeerGroup

public class StdPeerGroup
extends GenericPeerGroup
implements CompatibilityEquater

A subclass of GenericPeerGroup that makes a peer group out of independent plugin services listed in its impl advertisement.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.jxta.peergroup.PeerGroup
PeerGroup.GlobalRegistry
 
Field Summary
(package private) static String compatKey1
           
(package private) static String compatKey2
           
(package private) static String compatVal1
           
(package private) static String compatVal2
           
(package private)  Vector disabledModules
           
static StructuredTextDocument stdCompatStatement
           
static String stdProvider
           
static String stdUri
           
 
Fields inherited from class net.jxta.impl.peergroup.GenericPeerGroup
configAdvertisement, configurator, parentGroup
 
Fields inherited from interface net.jxta.peergroup.PeerGroup
accessClassID, allPurposePeerGroupSpecID, applicationClassID, Both, DEFAULT_EXPIRATION, DEFAULT_LIFETIME, discoveryClassID, endpointClassID, FromParent, globalRegistry, Here, httpProtoClassID, membershipClassID, peerGroupClassID, peerinfoClassID, pipeClassID, proxyClassID, refAccessSpecID, refDiscoverySpecID, refEndpointSpecID, refHttpProtoSpecID, refMembershipSpecID, refNetPeerGroupSpecID, refPeerinfoSpecID, refPipeSpecID, refPlatformSpecID, refProxySpecID, refRelayProtoSpecID, refRendezvousSpecID, refResolverSpecID, refRouterProtoSpecID, refShellSpecID, refStartNetPeerGroupSpecID, refTcpProtoSpecID, refTlsProtoSpecID, relayProtoClassID, rendezvousClassID, resolverClassID, routerProtoClassID, tcpProtoClassID, tlsProtoClassID, WK_ID_PREFIX
 
Fields inherited from interface net.jxta.platform.Module
START_AGAIN_PROGRESS, START_AGAIN_STALLED, START_OK
 
Constructor Summary
StdPeerGroup()
          constructor
 
Method Summary
 boolean compatible(Element compat)
          Evaluates if the given compatibility statement makes the module that bears it is lodable by this group.
 ModuleImplAdvertisement getAllPurposePeerGroupImplAdvertisement()
          Returns the all purpose peer group implementation advertisement.
 Cm getCacheManager()
          Returns the cache manager associated with this group.
protected  void initFirst(PeerGroup parent, ID assignedID, Advertisement impl)
          Performs all initialization steps that need to be performed before any subclass initialization is performed. This method loads and initializes all modules described in the given implementation advertisement.
protected  void initLast()
          Perform all initialization steps that need to be performed after any subclass initialization is performed.
static boolean isCompatible(Element compat)
          Evaluates if the given compatibility statement makes the module that bears it is loadable by this group.
protected  void loadAllModules(Hashtable modules, ModuleClassID thisClassOnly, boolean privileged)
          Builds a table of modules indexed by their class ID.
protected  ModuleImplAdvertisement mkImplAdvBuiltin(ModuleSpecID specID, String code, String descr)
          An internal convenience method essentially for bootstrapping.
 int startApp(String[] arg)
          The group does not care for start args, and does not come-up with args to pass to its main app.
 void stopApp()
          Stops the group and all its services.
 
Methods inherited from class net.jxta.impl.peergroup.GenericPeerGroup
addService, checkServices, decRefCount, equals, getAccessService, getConfigAdvertisement, getDiscoveryService, getEndpointService, getHomeThreadGroup, getImplAdvertisement, getInterface, getJxtaLoader, getLoader, getMembershipService, getParentGroup, getPeerAdvertisement, getPeerGroupAdvertisement, getPeerGroupID, getPeerGroupName, getPeerID, getPeerInfoService, getPeerName, getPipeService, getRendezVousService, getResolverService, getRoleMap, getWeakInterface, hashCode, init, isRendezvous, loadModule, loadModule, loadModule, loadModule, lookupService, lookupService, newGroup, newGroup, newGroup, publishGroup, removeService, setConfigAdvertisement, setJxtaLoader, unref
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stdCompatStatement

public static final StructuredTextDocument stdCompatStatement

stdUri

public static final String stdUri
See Also:
Constant Field Values

stdProvider

public static final String stdProvider
See Also:
Constant Field Values

compatKey1

static final String compatKey1
See Also:
Constant Field Values

compatKey2

static final String compatKey2
See Also:
Constant Field Values

compatVal1

static final String compatVal1
See Also:
Constant Field Values

compatVal2

static final String compatVal2
See Also:
Constant Field Values

disabledModules

Vector disabledModules
Constructor Detail

StdPeerGroup

public StdPeerGroup()
constructor

Method Detail

mkImplAdvBuiltin

protected ModuleImplAdvertisement mkImplAdvBuiltin(ModuleSpecID specID,
                                                   String code,
                                                   String descr)
An internal convenience method essentially for bootstrapping. Make a standard ModuleImplAdv for any service that comes builtin this reference implementation. In most cases there are no params, so we do not take that argument. The invoker may add params afterwards.


compatible

public boolean compatible(Element compat)
Evaluates if the given compatibility statement makes the module that bears it is lodable by this group.

Specified by:
compatible in interface CompatibilityEquater
Specified by:
compatible in interface PeerGroup
Specified by:
compatible in class GenericPeerGroup
Returns:
boolean True if the given statement is compatible.

isCompatible

public static boolean isCompatible(Element compat)
Evaluates if the given compatibility statement makes the module that bears it is loadable by this group.

Returns:
boolean True if the given statement is compatible.

loadAllModules

protected void loadAllModules(Hashtable modules,
                              ModuleClassID thisClassOnly,
                              boolean privileged)
Builds a table of modules indexed by their class ID. The values are the loaded modules, the keys are their classId. This routine interprets the parameter list in the advertisement.

Parameters:
modules - The modules to load
thisClassOnly - load only the module specified from the map
privileged - if true then modules will get a real reference to the group loading them, otherwise its an interface object.

startApp

public int startApp(String[] arg)
The group does not care for start args, and does not come-up with args to pass to its main app. So, until we decide on something more useful, the args of the group's startApp are passed-on to the group's main app. NB: both the apps init and startApp methods are invoked.

Specified by:
startApp in interface Module
Overrides:
startApp in class GenericPeerGroup
Returns:
int Status.

stopApp

public void stopApp()
Stops the group and all its services.

PeerGroupInterface's stopApp() does nothing. Only a real reference to the group object permits to stop it without going through ref counting.

Specified by:
stopApp in interface Module
Overrides:
stopApp in class GenericPeerGroup

initFirst

protected void initFirst(PeerGroup parent,
                         ID assignedID,
                         Advertisement impl)
                  throws PeerGroupException
Performs all initialization steps that need to be performed before any subclass initialization is performed.

Classes that override this method should always call super.initFirst() before doing any of their own work. This method loads and initializes all modules described in the given implementation advertisement. Then, all modules are placed in a list and the list is processed iteratively. During each iteration, the Module.startApp(String[]) method of each module is invoked once. Iterations continue until no progress is being made or the list is empty.

The status returned by the Module.startApp(String[]) method of each module is considered as follows:

Iterations through the list stop when:

Overrides:
initFirst in class GenericPeerGroup
Parameters:
parent - The group that serves as a parent to this group.
assignedID - The unique ID assigned to this module. For group this is the group ID or null if a group ID has not yet been assigned. If null is passed, GenericPeerGroup choses a new group ID.
impl - The ModuleImplAdvertisement which defines this group's implementation.
Throws:
PeerGroupException

initLast

protected void initLast()
                 throws PeerGroupException
Perform all initialization steps that need to be performed after any subclass initialization is performed.

Classes that override this method should always call super.initLast after doing any of their own work.

Overrides:
initLast in class GenericPeerGroup
Throws:
PeerGroupException

getAllPurposePeerGroupImplAdvertisement

public ModuleImplAdvertisement getAllPurposePeerGroupImplAdvertisement()
                                                                throws Exception
Returns the all purpose peer group implementation advertisement. This defines a peergroup implementation that can be used for many purposes, and from which one may derive slightly different peergroup implementations. This definition is always the same and has a well known ModuleSpecID. It includes the basic service, no protocols and the shell for main application. The user must remember to change the specID if the set of services protocols or applications is altered before use.

Specified by:
getAllPurposePeerGroupImplAdvertisement in interface PeerGroup
Specified by:
getAllPurposePeerGroupImplAdvertisement in class GenericPeerGroup
Returns:
ModuleImplAdvertisement The new peergroup impl adv.
Throws:
Exception

getCacheManager

public Cm getCacheManager()
Returns the cache manager associated with this group.

Returns:
the cache manager associated with this group.

JXTA J2SE