Lines 92-97
Link Here
|
92 |
import org.openide.util.NbCollections; |
92 |
import org.openide.util.NbCollections; |
93 |
import org.openide.util.SharedClassObject; |
93 |
import org.openide.util.SharedClassObject; |
94 |
import org.openide.util.NbBundle; |
94 |
import org.openide.util.NbBundle; |
|
|
95 |
import org.openide.util.RequestProcessor; |
96 |
import org.openide.util.RequestProcessor.Task; |
95 |
import org.openide.util.Utilities; |
97 |
import org.openide.util.Utilities; |
96 |
import org.openide.util.lookup.InstanceContent; |
98 |
import org.openide.util.lookup.InstanceContent; |
97 |
import org.xml.sax.SAXException; |
99 |
import org.xml.sax.SAXException; |
Lines 361-369
Link Here
|
361 |
Main.initUICustomizations(); |
363 |
Main.initUICustomizations(); |
362 |
|
364 |
|
363 |
ev.log(Events.PERF_START, "NbInstaller.load - ModuleInstalls"); // NOI18N |
365 |
ev.log(Events.PERF_START, "NbInstaller.load - ModuleInstalls"); // NOI18N |
|
|
366 |
|
367 |
RequestProcessor rp = createModuleInstallProcessor(); |
368 |
Set<Task> waitFor = new HashSet<Task>(); |
364 |
for (Module m: modules) { |
369 |
for (Module m: modules) { |
365 |
try { |
370 |
try { |
366 |
loadCode(m, true); |
371 |
waitFor.add(loadCode(m, true, rp)); |
367 |
} catch (Exception t) { |
372 |
} catch (Exception t) { |
368 |
Util.err.log(Level.SEVERE, null, t); |
373 |
Util.err.log(Level.SEVERE, null, t); |
369 |
} catch (LinkageError le) { |
374 |
} catch (LinkageError le) { |
Lines 371-392
Link Here
|
371 |
} catch (AssertionError e) { |
376 |
} catch (AssertionError e) { |
372 |
Util.err.log(Level.SEVERE, null, e); |
377 |
Util.err.log(Level.SEVERE, null, e); |
373 |
} |
378 |
} |
374 |
ev.log(Events.PERF_TICK, "ModuleInstall for " + m.getCodeName() + " called"); // NOI18N |
379 |
ev.log(Events.PERF_TICK, "ModuleInstall for " + m.getCodeName() + " called"); // NOI18N |
375 |
} |
380 |
} |
376 |
ev.log(Events.PERF_END, "NbInstaller.load - ModuleInstalls"); // NOI18N |
|
|
377 |
|
381 |
|
378 |
ev.log(Events.FINISH_LOAD, modules); |
|
|
379 |
|
382 |
|
380 |
if (Boolean.getBoolean("netbeans.preresolve.classes")) { |
383 |
if (Boolean.getBoolean("netbeans.preresolve.classes")) { |
381 |
preresolveClasses(modules); |
384 |
preresolveClasses(modules); |
382 |
} |
385 |
} |
|
|
386 |
|
387 |
for (Task t : waitFor) { |
388 |
if (t != null) { |
389 |
t.waitFinished(); |
390 |
} |
391 |
} |
392 |
ev.log(Events.PERF_END, "NbInstaller.load - ModuleInstalls"); // NOI18N |
393 |
ev.log(Events.FINISH_LOAD, modules); |
383 |
} |
394 |
} |
384 |
|
395 |
|
|
|
396 |
@Override |
385 |
public void unload(List<Module> modules) { |
397 |
public void unload(List<Module> modules) { |
386 |
ev.log(Events.START_UNLOAD, modules); |
398 |
ev.log(Events.START_UNLOAD, modules); |
|
|
399 |
RequestProcessor rp = createModuleInstallProcessor(); |
400 |
Set<Task> waitFor = new HashSet<Task>(); |
387 |
for (Module m: modules) { |
401 |
for (Module m: modules) { |
388 |
try { |
402 |
try { |
389 |
loadCode(m, false); |
403 |
waitFor.add(loadCode(m, false, rp)); |
390 |
} catch (Exception t) { |
404 |
} catch (Exception t) { |
391 |
Util.err.log(Level.SEVERE, null, t); |
405 |
Util.err.log(Level.SEVERE, null, t); |
392 |
} catch (LinkageError le) { |
406 |
} catch (LinkageError le) { |
Lines 412-434
Link Here
|
412 |
} |
426 |
} |
413 |
} |
427 |
} |
414 |
loadLayers(modules, false); |
428 |
loadLayers(modules, false); |
|
|
429 |
for (Task t : waitFor) { |
430 |
if (t != null) { |
431 |
t.waitFinished(); |
432 |
} |
433 |
} |
415 |
ev.log(Events.FINISH_UNLOAD, modules); |
434 |
ev.log(Events.FINISH_UNLOAD, modules); |
416 |
} |
435 |
} |
417 |
|
436 |
|
418 |
/** Load/unload installer code for a module. */ |
437 |
/** Load/unload installer code for a module. */ |
419 |
@SuppressWarnings("deprecation") // old ModuleInstall methods we have to call |
438 |
@SuppressWarnings("deprecation") // old ModuleInstall methods we have to call |
420 |
private void loadCode(Module m, boolean load) throws Exception { |
439 |
private Task loadCode(final Module m, final boolean load, RequestProcessor rp) throws Exception { |
421 |
Class<? extends ModuleInstall> instClazz = installs.get(m); |
440 |
final Class<? extends ModuleInstall> instClazz = installs.get(m); |
422 |
if (instClazz != null) { |
441 |
if (instClazz != null) { |
423 |
ModuleInstall inst = SharedClassObject.findObject(instClazz, true); |
442 |
final Runnable operation = new Runnable() { |
424 |
if (load) { |
443 |
@Override |
425 |
ev.log(Events.RESTORE, m); |
444 |
public void run() { |
426 |
inst.restored(); |
445 |
ModuleInstall inst = SharedClassObject.findObject(instClazz, true); |
427 |
} else { |
446 |
if (load) { |
428 |
ev.log(Events.UNINSTALL, m); |
447 |
ev.log(Events.RESTORE, m); |
429 |
inst.uninstalled(); |
448 |
inst.restored(); |
|
|
449 |
} else { |
450 |
ev.log(Events.UNINSTALL, m); |
451 |
inst.uninstalled(); |
452 |
} |
453 |
} |
454 |
}; |
455 |
if (rp == null) { |
456 |
operation.run(); |
457 |
return null; |
430 |
} |
458 |
} |
|
|
459 |
return rp.post(operation); |
431 |
} |
460 |
} |
|
|
461 |
return null; |
432 |
} |
462 |
} |
433 |
|
463 |
|
434 |
/** Load/unload all manifest sections for a given module. */ |
464 |
/** Load/unload all manifest sections for a given module. */ |
Lines 484-489
Link Here
|
484 |
} |
514 |
} |
485 |
|
515 |
|
486 |
private final InstanceContent.Convertor<ManifestSection,Object> convertor = new Convertor(); |
516 |
private final InstanceContent.Convertor<ManifestSection,Object> convertor = new Convertor(); |
|
|
517 |
|
518 |
private RequestProcessor createModuleInstallProcessor() { |
519 |
int throughput = Integer.parseInt(NbBundle.getMessage(NbInstaller.class, "PARALLEL_MODULE_INSTALL")); |
520 |
return throughput <= 0 ? null : new RequestProcessor("Module Installs", throughput); // NOI18N |
521 |
} |
487 |
private final class Convertor implements InstanceContent.Convertor<ManifestSection,Object> { // or <ManifestSection,SharedClassObject>? |
522 |
private final class Convertor implements InstanceContent.Convertor<ManifestSection,Object> { // or <ManifestSection,SharedClassObject>? |
488 |
Convertor() {} |
523 |
Convertor() {} |
489 |
public Object convert(ManifestSection s) { |
524 |
public Object convert(ManifestSection s) { |