Missing Modules Resolver (part II)

For those who are interested in implementation of Missing Modules Resolver I can show some implementation details.

The Missing Modules Resolver is built on the top of Autoupdate API and uses several Autoupdate services for find out broken modules, download&install missing modules to match its dependencies and enable them again in the end. Rest of implementation is just UI.

Okay, let's see the utilized services and look at code snippets.

Find out broken modules

Entry point into Autoupdate API is the
UpdateManager.getDefault ()
what providers set of units which can be browsed in UI and perform operations on them (i.e. install, update or unistall etc.) Each UpdateUnit represents a NetBeans module either as installed in IDE or available on Update Center. If a module is already installed but also has available higher version in any Update Center, the module has update one.
Now, we need find out modules what are already installed but aren't enabled in IDE.
Collection<UpdateUnit> units = UpdateManager.getDefault().getUpdateUnits(UpdateManager.TYPE.MODULE);
for (UpdateUnit unit : allUnits) {
if (unit.getInstalled() != null && ! unit.getInstalled().isEnabled()) {
res.add (unit.getInstalled());
Great, we have installed but disabled modules but how to diagnose the module is broken and cannot be enabled? Ask them why cannot be enable, i.e. get its broken dependencies. If there are some broken we have a candidate for resolving.
OperationContainer<operationsupport> forEnable = OperationContainer.createForEnable (); // take support for enabling modules
OperationContainer.OperationInfo<operationsupport> info = forEnable.add([installed-but-disabled-module]);
Set<string> broken = info.getBrokenDependencies(); // ask for broken dependencies
if (! broken.isEmpty()) { // if are some => we have the candidate
candidate.put(el, broken);

So, now we have all candidate for resolving its problems.

Look for missing modules

Now let's look for missing modules. Each candidate knows own broken dependencies. These dependencies are the clue for us to search out set of missing module which can fix these dependencies. There is a sample how to get it:

Collection<UpdateElement> missingModules = ...
OperationContainer.OperationInfo<operationsupport> info = forEnable.add([installed-but-disabled-module]);
Set<UpdateElement> reqs = new HashSet<UpdateElement>(info.getRequiredElements()); // add required modules

Great, we found out a collection of missing modules what are required by other modules in IDE. We should install them.


Take the operation container for install operation, put all missing modules into this container what can perform all action for install them: download, validate, install and restart IDE if needed.

OperationContainer<InstallSupport> forInstall = OperationContainer.createForInstall(); // take the install container
forInstall.add(missing-modules); // put all missing modules
InstallSupport installSupport = installContainer.getSupport(); // take the install support what is executive for actions above
ProgressHandle progress = ... // ProgressHandle
Validator v = installSupport.doDownload(progress); // perform download
Installer i = installSupport.doValidate(v, progress); // perform validation
Restarter r = installSupport.doInstall(i, progress); // perform install
if (r != null) { // need restart?
installSupport.doRestart(r, progress);

Enabled broken modules again

It's easy, just let's take a operation container for enabling modules, put all broken module and invoke enable action. All module should be able to turn on again.
OperationContainer<OperationSupport> forEnable = OperationContainer.createForEnable (); // take support for enabling modules
forEnable.add(candiates); // put all candidates
OperationSupport enableSupport = enableContainer.getSupport(); // take the enable support
ProgressHandle progress = ... // ProgressHandle enableSupport.doOperation(progress);

That's all :-)

Who would like to see all sources or contribute some improvements or fix bugs, go into contrib repository at http://hg.netbeans.org/main/contrib/. The NetBeans project takes name moduleresolver.
Bugs or RFE report into IssueZilla against component contrib and owner jrechtacek-AT-netbeans.org. Thanks for your feedback.


okay! after a bit of searching what i found was ur part 1 of the same missing module resolver project(?) but sadly all the links provided in that page was broken! then i found this one - part 2! imo this is a great effort from your part to resolve a really painful update problem of Netbeans IDE! but almost over a year and no one even posted a comment doesnt reflect that..maybe its the nature of the problem..like u said earlier its more like A RARE scenario for this problem to ever occur! I live in a part of the world where electricity disruption is a regular fact! while i was doing the auto update my elec went off and when it came back i found myself with this problem!! now there is virtually no way to solve it (other than reinstall)! anyway as i am a total newbie to this programming concept of Java can u plz help me out? i want to try this out before doing a reinstall. my version is IDE 6.7 (that comes bundled with JDK) is there a fully working version of ur project/program/plugin..sorry for my lack of knowledge on this matter..but i would really appreciate any response to my comment..thanks

Posted by Asif on August 16, 2009 at 02:39 AM CEST #

Thanks for the excelent series of post about silent update, remove and others. My firt step came from those examples, but i'm rolling over Unistall. How can i look for updates.xml and compare with installed modules to find who is missing and what module i have to unistall. Can you provide some example. Again, thank you!


Posted by Thiago Bonfante on November 17, 2010 at 03:51 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed



« July 2016