Lines 65-70
Link Here
|
65 |
import java.util.StringTokenizer; |
65 |
import java.util.StringTokenizer; |
66 |
import java.util.TreeMap; |
66 |
import java.util.TreeMap; |
67 |
import java.util.TreeSet; |
67 |
import java.util.TreeSet; |
|
|
68 |
import java.util.concurrent.Callable; |
68 |
import java.util.jar.Attributes; |
69 |
import java.util.jar.Attributes; |
69 |
import java.util.jar.JarEntry; |
70 |
import java.util.jar.JarEntry; |
70 |
import java.util.jar.JarFile; |
71 |
import java.util.jar.JarFile; |
Lines 83-94
Link Here
|
83 |
import org.openide.modules.Dependency; |
84 |
import org.openide.modules.Dependency; |
84 |
import org.openide.modules.ModuleInfo; |
85 |
import org.openide.modules.ModuleInfo; |
85 |
import org.openide.modules.ModuleInstall; |
86 |
import org.openide.modules.ModuleInstall; |
|
|
87 |
import org.openide.modules.Modules; |
86 |
import org.openide.modules.SpecificationVersion; |
88 |
import org.openide.modules.SpecificationVersion; |
|
|
89 |
import org.openide.util.Lookup; |
87 |
import org.openide.util.NbCollections; |
90 |
import org.openide.util.NbCollections; |
88 |
import org.openide.util.SharedClassObject; |
91 |
import org.openide.util.SharedClassObject; |
89 |
import org.openide.util.NbBundle; |
92 |
import org.openide.util.NbBundle; |
|
|
93 |
import org.openide.util.RequestProcessor; |
94 |
import org.openide.util.RequestProcessor.Task; |
90 |
import org.openide.util.Utilities; |
95 |
import org.openide.util.Utilities; |
91 |
import org.openide.util.lookup.InstanceContent; |
96 |
import org.openide.util.lookup.InstanceContent; |
|
|
97 |
import org.openide.util.lookup.Lookups; |
92 |
import org.xml.sax.SAXException; |
98 |
import org.xml.sax.SAXException; |
93 |
|
99 |
|
94 |
/** Concrete implementation of the module installation functionality. |
100 |
/** Concrete implementation of the module installation functionality. |
Lines 318-327
Link Here
|
318 |
} |
324 |
} |
319 |
} |
325 |
} |
320 |
|
326 |
|
|
|
327 |
private static final RequestProcessor onStartStop = new RequestProcessor("On Start/Stop", 8); // NOI18N |
328 |
private final Map<String,Task> onStart = new HashMap<String, Task>(); |
321 |
@Override |
329 |
@Override |
322 |
protected void classLoaderUp(ClassLoader cl) { |
330 |
protected void classLoaderUp(ClassLoader cl) { |
323 |
MainLookup.systemClassLoaderChanged(cl); |
331 |
MainLookup.systemClassLoaderChanged(cl); |
324 |
ev.log(Events.PERF_TICK, "META-INF/services/ additions registered"); // NOI18N |
332 |
ev.log(Events.PERF_TICK, "META-INF/services/ additions registered"); // NOI18N |
|
|
333 |
|
334 |
for (Lookup.Item<Runnable> item : Lookups.forPath("Modules/Start").lookupResult(Runnable.class).allItems()) { |
335 |
synchronized (onStart) { |
336 |
Task already = onStart.get(item.getId()); |
337 |
if (already == null) { |
338 |
Runnable r = item.getInstance(); |
339 |
if (r != null) { |
340 |
onStart.put(item.getId(), onStartStop.post(r)); |
341 |
} |
342 |
} |
343 |
} |
344 |
} |
345 |
} |
346 |
|
347 |
final void waitOnStart() { |
348 |
Task[] all; |
349 |
synchronized (onStart) { |
350 |
all = onStart.values().toArray(new Task[0]); |
351 |
} |
352 |
for (Task t : all) { |
353 |
t.waitFinished(); |
354 |
} |
325 |
} |
355 |
} |
326 |
|
356 |
|
327 |
@Override |
357 |
@Override |
Lines 651-657
Link Here
|
651 |
|
681 |
|
652 |
public boolean closing(List<Module> modules) { |
682 |
public boolean closing(List<Module> modules) { |
653 |
Util.err.fine("closing: " + modules); |
683 |
Util.err.fine("closing: " + modules); |
654 |
for (Module m: modules) { |
684 |
for (Module m: modules) { |
655 |
Class<? extends ModuleInstall> instClazz = installs.get(m); |
685 |
Class<? extends ModuleInstall> instClazz = installs.get(m); |
656 |
if (instClazz != null) { |
686 |
if (instClazz != null) { |
657 |
try { |
687 |
try { |
Lines 668-673
Link Here
|
668 |
} |
698 |
} |
669 |
} |
699 |
} |
670 |
} |
700 |
} |
|
|
701 |
for (Callable<?> c : Lookups.forPath("Modules/Stop").lookupAll(Callable.class)) { // NOI18N |
702 |
if (!modules.contains(Modules.getDefault().ownerOf(c.getClass()))) { |
703 |
continue; |
704 |
} |
705 |
try { |
706 |
if (Boolean.TRUE.equals(c.call())) { |
707 |
Util.err.log(Level.FINE, "{0} refused to close", c.getClass()); // NOI18N |
708 |
} |
709 |
} catch (Exception ex) { |
710 |
Util.err.log(Level.FINE, c.getClass() + " thrown an exception", ex); // NOI18N |
711 |
return false; |
712 |
} |
713 |
} |
671 |
return true; |
714 |
return true; |
672 |
} |
715 |
} |
673 |
|
716 |
|
Lines 675-680
Link Here
|
675 |
Util.err.fine("close: " + modules); |
718 |
Util.err.fine("close: " + modules); |
676 |
ev.log(Events.CLOSE); |
719 |
ev.log(Events.CLOSE); |
677 |
moduleList.shutDown(); |
720 |
moduleList.shutDown(); |
|
|
721 |
List<Task> waitFor = new ArrayList<Task>(); |
722 |
for (Runnable r : Lookups.forPath("Modules/Stop").lookupAll(Runnable.class)) { // NOI18N |
723 |
if (!modules.contains(Modules.getDefault().ownerOf(r.getClass()))) { |
724 |
continue; |
725 |
} |
726 |
waitFor.add(onStartStop.post(r)); |
727 |
} |
678 |
// [PENDING] this may need to write out changed ModuleInstall externalized |
728 |
// [PENDING] this may need to write out changed ModuleInstall externalized |
679 |
// forms...is that really necessary to do here, or isn't it enough to |
729 |
// forms...is that really necessary to do here, or isn't it enough to |
680 |
// do right after loading etc.? Currently these are only written when |
730 |
// do right after loading etc.? Currently these are only written when |
Lines 695-700
Link Here
|
695 |
} |
745 |
} |
696 |
} |
746 |
} |
697 |
} |
747 |
} |
|
|
748 |
for (Task t : waitFor) { |
749 |
t.waitFinished(); |
750 |
} |
698 |
} |
751 |
} |
699 |
|
752 |
|
700 |
private static String cacheCnb; |
753 |
private static String cacheCnb; |