|
Project JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.impl.util.ModuleManager
public class ModuleManager
Module Manager. This class allows to manage modules to be loaded, started and stopped within a PeerGroup. Modules that are loaded using the ModuleManager do not need to be listed within the PeerGroup advertisement, nor do they have to have published their ModuleSpec and ModuleImpl advertisements: the ModuleManager takes care of this task. However, other peers which may want to load the Module will also have to use its own loader (or the ModuleManager itself, of course): the ModuleManager only manages Modules on the local peer. The Module Manager allows, as an option, to use an application provided class loader. The default class loader is the PeerGroup class loader. The following example shows how to use the ModuleManager:
// Get the peergroup PeerGroup group = getMyPeerGroup(); // Get the ModuleManager ModuleManager moduleManager = ModuleManager.getModuleManager (group); // Is the Module already loaded ? Module module = moduleManager.lookupModule ("SampleModule"); if (module == null) { // SampleModue is not loaded yet. Load it now. module = moduleManager.loadModule ( "SampleModule", "net.jxta.app.SampleModule.SampleModule"); } // Start SampleModule moduleManager.startModule ("SampleModule", moduleArgs);
Nested Class Summary | |
---|---|
static interface |
ModuleManager.ModuleManagerLoader
ModuleManagerLoader interface. |
Method Summary | |
---|---|
void |
createServiceAdvertisement(PeerGroup group,
String moduleName,
String description,
String moduleSpecURI,
String moduleCode,
String moduleCodeURI,
ModuleClassID mcID,
ModuleSpecID msID,
String code,
Advertisement serviceAdv,
long localTTL,
long remoteTTL)
Creates a Module Class, Spec, and Impl advertisements, and adds the service Advertisement as part of the Module Impl Advertisement, and publishes the advertisements in local cache |
static ModuleManager |
getModuleManager(PeerGroup group)
getModuleManager This method is used in order to get the instance of the ModuleManager for a given PeerGroup. getModuleManager will create a new instance automatically if there is no instance for the given PeerGroup. |
Advertisement |
getServiceAdvertisement(PeerGroup group,
ModuleImplAdvertisement mia,
String advertismentType)
Retreives a Service Advertisement from a module impl advertisement |
Module |
loadModule(String moduleName,
ModuleManager.ModuleManagerLoader loader)
loadModule Loads a Module. |
Module |
loadModule(String moduleName,
String moduleCode)
loadModule Loads a Module. |
Module |
lookupModule(String moduleName)
lookupModule Get the Module from its symbolic name. |
void |
startModule(String moduleName,
String[] args)
startModule This method is invoked by the application to start a previously loaded module. |
void |
stopModule(String moduleName)
stopModule This method is invoked by the application to stop a running module. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void startModule(String moduleName, String[] args)
moduleName
- is the symbolic name of the module.args
- is an array of String containing optional arguments for the module. This
array is passed directly to the startApp (String[] ) method of the Module.public void stopModule(String moduleName)
moduleName
- is the symbolic name of the module.public static ModuleManager getModuleManager(PeerGroup group)
group
- the PeerGroup for which the ModuleManager is asked.
public Module lookupModule(String moduleName)
moduleName
- symbolic name of the Module
public Module loadModule(String moduleName, ModuleManager.ModuleManagerLoader loader)
moduleName
- symbolic name of the Moduleloader
- application provided class loader
public Module loadModule(String moduleName, String moduleCode)
moduleName
- symbolic name of the ModulemoduleCode
- the name of the class to be loaded.
public void createServiceAdvertisement(PeerGroup group, String moduleName, String description, String moduleSpecURI, String moduleCode, String moduleCodeURI, ModuleClassID mcID, ModuleSpecID msID, String code, Advertisement serviceAdv, long localTTL, long remoteTTL) throws IOException
group
- groupmoduleName
- module namedescription
- module descriptionmoduleSpecURI
- module spec urimoduleCode
- module codemoduleCodeURI
- module code urimcID
- module class idmsID
- module spec idserviceAdv
- service advertisementlocalTTL
- local cache lifetime in msremoteTTL
- remote cache lifetime in ms
IOException
- if an io error occurspublic Advertisement getServiceAdvertisement(PeerGroup group, ModuleImplAdvertisement mia, String advertismentType) throws IOException
group
- peer groupmia
- ModuleImplAdvertisementadvertismentType
- service advertisment string Type
IOException
- if an io error occurs
|
JXTA J2SE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |