Collection modules =
Lookup.getDefault().lookupAll(ModuleInfo.class);
- ModuleInfo class
- The module system provides a ModuleInfo class for each module, where all information about modules is stored.
- The ModuleInfo objects are available centrally via the Lookup, and can be obtained there as above.
- Information List / getAttribute():
- name
- version
- dependencies
- current status (activated or deactivated)
- the existence of service implementations for the current module
- Being informed of changes / PropertyChangeListener
- LookupListener
- Informs you of the installation and uninstallation of modules
Lookup.Result res = Lookup.getDefault().lookupResult(ModuleInfo.class);
result.addLookupListener(new LookupListener() {
public void resultChanged(LookupEvent lookupEvent) {
Collection c = res.allInstances();
System.out.println("Available modules: " + c.size());
}
});
res.allItems(); //initialize the listener
No comments:
Post a Comment