Project JXTA

net.jxta.platform
Interface Module

All Known Subinterfaces:
Application, DiscoveryService, EndpointService, PeerGroup, PeerInfoService, PipeService, RendezVousService, ResolverService, Service

public interface Module

This interface defines a JXTA module. All JXTA services need to implement this interface. Endpoint protocols and applications need to implement that interface if they are to be loaed and started by a PeerGroup. Service and Application implements Module, PeerGroup implements service and ShellApp implements application, as a result both implement Module.

Jxta Modules are given their initialization parameters via the init() method rather than a non-default constructor.

Modules are passed the peer group within which they are created. From the peergroup object, Modules can acccess all the peer group services. The PeerGroup within which a PeerGroup runs is known as its parent. The initial root peer group is known as the World Peer Group and is implemented by an object of class Platform, a subclass of PeerGroup. The "parent" PeerGroup of the World Peer Group is null.

Since:
JXTA 1.0
Version:
$Revision: 1.5 $
See Also:
ModuleImplAdvertisement, ModuleClassID, PeerGroup, Application, Service, Advertisement, ID

Method Summary
 void init(PeerGroup group, ID assignedID, Advertisement implAdv)
          Initialize the module, passing it its peer group and advertisement.
 int startApp(java.lang.String[] args)
          Some Modules will wait for start() being called, before proceeding beyond a certain point.
 void stopApp()
          One can ask a Module to stop.
 

Method Detail

init

public void init(PeerGroup group,
                 ID assignedID,
                 Advertisement implAdv)
          throws PeerGroupException
Initialize the module, passing it its peer group and advertisement.
Parameters:
group - The PeerGroup from which this Module can obtain services. If this module is a service, this is also the PeerGroup of which this module is a service.
assignedID - Identity of Module within group. modules can use it as a the root of their namespace to create names that are unique within the group but predictible by the same module on another peer. This is normaly the ModuleClassID which is also the name under which the module is known by other modules. For a group it is the PeerGroupID itself. The parameters of a service, in the Peer configuration, are indexed by the assignedID of that service, and a Service must publish its run-time parameters in the Peer Advertisement under its assigned ID.
implAdv - The implementation advertisement for this Module.
Throws:
PeerGroupException - This module failed to initialize.
Since:
JXTA 1.0

startApp

public int startApp(java.lang.String[] args)
Some Modules will wait for start() being called, before proceeding beyond a certain point. That's also the opportunity to supply arbitrary arguments (mostly to applications). Note: the name of this method is historical and no-longer adequate.
Parameters:
args - An array of Strings forming the parameters for this Module.
Returns:
int status indication. By convention 0 means that this Module started succesfully.

stopApp

public void stopApp()
One can ask a Module to stop. The Module cannot be forced to comply, but in the future we might be able to deny it access to anything after some timeout. Note: the name of this method is no-longer adequate.

Project JXTA