Lines 17-33
Link Here
|
17 |
import java.beans.*; |
17 |
import java.beans.*; |
18 |
import java.io.IOException; |
18 |
import java.io.IOException; |
19 |
import java.io.File; |
19 |
import java.io.File; |
|
|
20 |
import java.io.InputStream; |
20 |
import java.net.MalformedURLException; |
21 |
import java.net.MalformedURLException; |
21 |
import java.net.URL; |
22 |
import java.net.URL; |
22 |
import org.openide.util.*; |
23 |
import org.openide.util.*; |
23 |
import org.openide.modules.ModuleInfo; |
24 |
import org.openide.modules.ModuleInfo; |
24 |
import java.security.*; |
25 |
import java.security.*; |
|
|
26 |
import java.util.jar.Attributes; |
25 |
import java.util.jar.JarFile; |
27 |
import java.util.jar.JarFile; |
26 |
import java.util.jar.Manifest; |
28 |
import java.util.jar.Manifest; |
27 |
import org.openide.modules.SpecificationVersion; |
29 |
import org.openide.modules.SpecificationVersion; |
28 |
import org.openide.modules.Dependency; |
30 |
import org.openide.modules.Dependency; |
29 |
import org.openide.ErrorManager; |
31 |
import org.openide.ErrorManager; |
30 |
import org.netbeans.JarClassLoader; |
32 |
|
31 |
|
33 |
|
32 |
/** Manages a collection of modules. |
34 |
/** Manages a collection of modules. |
33 |
* Must use {@link #mutex} to access its important methods. |
35 |
* Must use {@link #mutex} to access its important methods. |
Lines 55-76
Link Here
|
55 |
// modules providing a given requires token; set may never be empty |
57 |
// modules providing a given requires token; set may never be empty |
56 |
private final Map providersOf = new HashMap(25); // Map<String,Set<Module>> |
58 |
private final Map providersOf = new HashMap(25); // Map<String,Set<Module>> |
57 |
|
59 |
|
58 |
private final ModuleInstaller installer; |
60 |
private ModuleInstaller installer; |
59 |
private ModuleFactory moduleFactory; |
61 |
private ModuleFactory moduleFactory; |
60 |
|
62 |
|
61 |
private SystemClassLoader classLoader; |
63 |
private SystemClassLoader classLoader; |
62 |
private List classLoaderPatches; // List<File|JarFile> |
64 |
private List classLoaderPatches; // List<File|JarFile> |
63 |
private final Object classLoaderLock = new String("ModuleManager.classLoaderLock"); // NOI18N |
65 |
private final Object classLoaderLock = new String("ModuleManager.classLoaderLock"); // NOI18N |
64 |
|
66 |
|
65 |
private final Events ev; |
67 |
private Events ev; |
|
|
68 |
|
69 |
private static ModuleManager DEFAULT; |
66 |
|
70 |
|
67 |
/** Create a manager, initially with no managed modules. |
71 |
/** Create a manager, initially with no managed modules. |
68 |
* The handler for installing modules is given. |
72 |
* The handler for installing modules is given. |
69 |
* Also the sink for event messages must be given. |
73 |
* Also the sink for event messages must be given. |
70 |
*/ |
74 |
*/ |
71 |
public ModuleManager(ModuleInstaller installer, Events ev) { |
75 |
private ModuleManager() { |
72 |
this.installer = installer; |
76 |
this (null, null); |
73 |
this.ev = ev; |
77 |
} |
|
|
78 |
|
79 |
public ModuleManager(ModuleInstaller i, Events e) { |
80 |
if (i == null) { |
81 |
i = new EmptyInstaller(); |
82 |
} |
83 |
this.installer = i; |
84 |
this.ev = e; |
85 |
|
74 |
String patches = System.getProperty("netbeans.systemclassloader.patches"); |
86 |
String patches = System.getProperty("netbeans.systemclassloader.patches"); |
75 |
if (patches != null) { |
87 |
if (patches != null) { |
76 |
// Probably temporary helper for XTest. By setting this system property |
88 |
// Probably temporary helper for XTest. By setting this system property |
Lines 96-102
Link Here
|
96 |
// Normal case. |
108 |
// Normal case. |
97 |
classLoaderPatches = Collections.EMPTY_LIST; |
109 |
classLoaderPatches = Collections.EMPTY_LIST; |
98 |
} |
110 |
} |
99 |
classLoader = new SystemClassLoader(classLoaderPatches, new ClassLoader[] {installer.getClass ().getClassLoader()}, Collections.EMPTY_SET); |
111 |
classLoader = new SystemClassLoader(classLoaderPatches, new ClassLoader[] {ModuleManager.class.getClassLoader()}, Collections.EMPTY_SET); |
100 |
updateContextClassLoaders(classLoader, true); |
112 |
updateContextClassLoaders(classLoader, true); |
101 |
|
113 |
|
102 |
moduleFactory = (ModuleFactory)Lookup.getDefault().lookup(ModuleFactory.class); |
114 |
moduleFactory = (ModuleFactory)Lookup.getDefault().lookup(ModuleFactory.class); |
Lines 105-117
Link Here
|
105 |
} |
117 |
} |
106 |
} |
118 |
} |
107 |
|
119 |
|
108 |
/** Access for ManifestSection. |
120 |
/** Getter for the default implementation of module manager. |
109 |
* @since JST-PENDING needed by ManifestSection |
121 |
* @return module manager |
110 |
*/ |
122 |
* @since JST-PENDING more standalone rewrite |
111 |
public final Events getEvents() { |
123 |
*/ |
112 |
return ev; |
124 |
public static synchronized ModuleManager getDefault() { |
|
|
125 |
if (DEFAULT == null) { |
126 |
DEFAULT = new ModuleManager(); |
127 |
} |
128 |
return DEFAULT; |
129 |
} |
130 |
|
131 |
/** Load modules found in the classpath. |
132 |
* Note that they might not satisfy all their dependencies, in which |
133 |
* case oh well... |
134 |
*/ |
135 |
final void loadBootModules() { |
136 |
// Keep a list of manifest URL prefixes which we know we do not need to |
137 |
// parse. Some of these manifests might be signed, and if so, we do not |
138 |
// want to touch them, as it slows down startup quite a bit. |
139 |
Collection ignoredPrefixes = new ArrayList(3); // List<String> |
140 |
try { |
141 |
// skip the JDK/JRE libraries |
142 |
String jdk = System.getProperty("java.home"); |
143 |
if (jdk.endsWith(File.separator + "jre")) { // NOI18N |
144 |
jdk = jdk.substring(0, jdk.length() - 4); |
145 |
} |
146 |
File f = new File(jdk); |
147 |
ignoredPrefixes.add("jar:" + f.toURI().toURL()); // NOI18N |
148 |
// skip $nbhome/lib/ext/*.jar; all fixes modules should be in |
149 |
// $nbhome/lib/ (or perhaps elsewhere, with -cp:a) |
150 |
String nbhomeS = System.getProperty("netbeans.home"); |
151 |
if (nbhomeS != null) { |
152 |
File nbhome = new File(nbhomeS); |
153 |
f = new File(new File(nbhome, "lib"), "ext"); // NOI18N |
154 |
ignoredPrefixes.add("jar:" + f.toURI().toURL()); // NOI18N |
155 |
} |
156 |
} catch (MalformedURLException e) { |
157 |
Util.err.notify(ErrorManager.INFORMATIONAL, e); |
158 |
} |
159 |
if (Util.err.isLoggable(ErrorManager.INFORMATIONAL)) { |
160 |
Util.err.log("ignoredPrefixes=" + ignoredPrefixes); |
161 |
} |
162 |
|
163 |
mutexPrivileged().enterWriteAccess(); |
164 |
ev.log(Events.START_LOAD_BOOT_MODULES); |
165 |
try { |
166 |
HashSet bootModules = new HashSet(10); |
167 |
ClassLoader loader = getClass().getClassLoader(); |
168 |
Enumeration e = loader.getResources("META-INF/MANIFEST.MF"); // NOI18N |
169 |
ev.log(Events.PERF_TICK, "got all manifests"); // NOI18N |
170 |
|
171 |
// There will be duplicates: cf. #32576. |
172 |
Set checkedManifests = new HashSet(); // Set<URL> |
173 |
MANIFESTS: |
174 |
while (e.hasMoreElements()) { |
175 |
URL manifestUrl = (URL)e.nextElement(); |
176 |
if (!checkedManifests.add(manifestUrl)) { |
177 |
// Already seen, ignore. |
178 |
continue; |
179 |
} |
180 |
String manifestUrlS = manifestUrl.toExternalForm(); |
181 |
Iterator it = ignoredPrefixes.iterator(); |
182 |
while (it.hasNext()) { |
183 |
if (manifestUrlS.startsWith((String)it.next())) { |
184 |
continue MANIFESTS; |
185 |
} |
186 |
} |
187 |
if (Util.err.isLoggable(ErrorManager.INFORMATIONAL)) { |
188 |
Util.err.log("Checking boot manifest: " + manifestUrlS); |
189 |
} |
190 |
|
191 |
InputStream is; |
192 |
try { |
193 |
is = manifestUrl.openStream(); |
194 |
} catch (IOException ioe) { |
195 |
// Debugging for e.g. #32493 - which JAR was guilty? |
196 |
Util.err.annotate(ioe, ErrorManager.UNKNOWN, "URL: " + manifestUrl, null, null, null); // NOI18N |
197 |
throw ioe; |
198 |
} |
199 |
try { |
200 |
Manifest mani = new Manifest(is); |
201 |
Attributes attr = mani.getMainAttributes(); |
202 |
if (attr.getValue("OpenIDE-Module") == null) { // NOI18N |
203 |
// Not a module. |
204 |
continue; |
205 |
} |
206 |
bootModules.add(createFixed(mani, manifestUrl, loader)); |
207 |
} finally { |
208 |
is.close(); |
209 |
} |
210 |
} |
211 |
//JST-PENDING: ? if (list == null) { |
212 |
// Plain calling us, we have to install now. |
213 |
// Do it the simple way. |
214 |
enable(bootModules); |
215 |
//} |
216 |
ev.log(Events.PERF_TICK, "added all classpath modules"); // NOI18N |
217 |
|
218 |
} catch (IOException ioe) { |
219 |
// Note: includes also InvalidException's for malformed this and that. |
220 |
// Probably if a bootstrap module is corrupt we are in pretty bad shape |
221 |
// anyway, so don't bother trying to be fancy and install just some of |
222 |
// them etc. |
223 |
Util.err.notify(ioe); |
224 |
} catch (DuplicateException de) { |
225 |
Util.err.notify(de); |
226 |
} finally { |
227 |
// Not 100% accurate in this case: |
228 |
ev.log(Events.FINISH_LOAD_BOOT_MODULES); |
229 |
mutexPrivileged().exitWriteAccess(); |
230 |
} |
113 |
} |
231 |
} |
114 |
|
232 |
|
|
|
233 |
|
115 |
private final Mutex.Privileged MUTEX_PRIVILEGED = new Mutex.Privileged(); |
234 |
private final Mutex.Privileged MUTEX_PRIVILEGED = new Mutex.Privileged(); |
116 |
private final Mutex MUTEX = new Mutex(MUTEX_PRIVILEGED); |
235 |
private final Mutex MUTEX = new Mutex(MUTEX_PRIVILEGED); |
117 |
/** Get a locking mutex for this module installer. |
236 |
/** Get a locking mutex for this module installer. |
Lines 433-439
Link Here
|
433 |
} |
552 |
} |
434 |
|
553 |
|
435 |
protected boolean isSpecialResource(String pkg) { |
554 |
protected boolean isSpecialResource(String pkg) { |
436 |
if (installer.isSpecialResource(pkg)) { |
555 |
if (getInstaller(false).isSpecialResource(pkg)) { |
437 |
return true; |
556 |
return true; |
438 |
} |
557 |
} |
439 |
return super.isSpecialResource(pkg); |
558 |
return super.isSpecialResource(pkg); |
Lines 469-479
Link Here
|
469 |
* You cannot request that a module be both autoload and eager. |
588 |
* You cannot request that a module be both autoload and eager. |
470 |
*/ |
589 |
*/ |
471 |
public Module create(File jar, Object history, boolean reloadable, boolean autoload, boolean eager) throws IOException, DuplicateException { |
590 |
public Module create(File jar, Object history, boolean reloadable, boolean autoload, boolean eager) throws IOException, DuplicateException { |
|
|
591 |
return create(jar, history, reloadable, autoload, eager, false); |
592 |
} |
593 |
|
594 |
/** Package private accessor to create modules that are on dynamic classpath. |
595 |
*/ |
596 |
final Module create(File jar, Object history, boolean reloadable, boolean autoload, boolean eager, boolean fixed) throws IOException, DuplicateException { |
472 |
assertWritable(); |
597 |
assertWritable(); |
473 |
ev.log(Events.START_CREATE_REGULAR_MODULE, jar); |
598 |
getEvents().log(Events.START_CREATE_REGULAR_MODULE, jar); |
474 |
Module m = moduleFactory.create(jar.getAbsoluteFile(), |
599 |
Module m = moduleFactory.create(jar.getAbsoluteFile(), |
475 |
history, reloadable, autoload, eager, this, ev); |
600 |
history, reloadable, autoload, eager, this, getEvents()); |
476 |
ev.log(Events.FINISH_CREATE_REGULAR_MODULE, jar); |
601 |
|
|
|
602 |
m.fixed = fixed; |
603 |
getEvents().log(Events.FINISH_CREATE_REGULAR_MODULE, jar); |
477 |
subCreate(m); |
604 |
subCreate(m); |
478 |
if (m.isEager()) { |
605 |
if (m.isEager()) { |
479 |
List immediate = simulateEnable(Collections.EMPTY_SET); |
606 |
List immediate = simulateEnable(Collections.EMPTY_SET); |
Lines 504-529
Link Here
|
504 |
public Module createFixed(Manifest mani, Object history, ClassLoader loader) throws InvalidException, DuplicateException { |
631 |
public Module createFixed(Manifest mani, Object history, ClassLoader loader) throws InvalidException, DuplicateException { |
505 |
assertWritable(); |
632 |
assertWritable(); |
506 |
if (mani == null || loader == null) throw new IllegalArgumentException("null manifest or loader"); // NOI18N |
633 |
if (mani == null || loader == null) throw new IllegalArgumentException("null manifest or loader"); // NOI18N |
507 |
ev.log(Events.START_CREATE_BOOT_MODULE, history); |
634 |
getEvents().log(Events.START_CREATE_BOOT_MODULE, history); |
508 |
Module m = moduleFactory.createFixed(mani, history, loader, this, ev); |
635 |
Module m = moduleFactory.createFixed(mani, history, loader, this, getEvents()); |
509 |
ev.log(Events.FINISH_CREATE_BOOT_MODULE, history); |
636 |
getEvents().log(Events.FINISH_CREATE_BOOT_MODULE, history); |
510 |
subCreate(m); |
637 |
subCreate(m); |
511 |
return m; |
638 |
return m; |
512 |
} |
639 |
} |
513 |
|
640 |
|
514 |
/** Used by Module to communicate with the ModuleInstaller re. dependencies. */ |
641 |
/** Used by Module to communicate with the ModuleInstaller re. dependencies. */ |
515 |
void refineDependencies(Module m, Set dependencies) { |
642 |
void refineDependencies(Module m, Set dependencies) { |
516 |
installer.refineDependencies(m, dependencies); |
643 |
getInstaller(false).refineDependencies(m, dependencies); |
517 |
} |
644 |
} |
518 |
/** Allows the installer to add provides (used to provide name of platform we run on) |
645 |
/** Allows the installer to add provides (used to provide name of platform we run on) |
519 |
*/ |
646 |
*/ |
520 |
String[] refineProvides (Module m) { |
647 |
String[] refineProvides (Module m) { |
521 |
return installer.refineProvides (m); |
648 |
String[] refineOrig = getInstaller(false).refineProvides(m); |
|
|
649 |
|
650 |
if (m.getCodeNameBase ().equals ("org.openide.modules")) { // NOI18N |
651 |
// module format is now 1 |
652 |
ArrayList refine = new ArrayList(); |
653 |
if (refineOrig != null) { |
654 |
refine.addAll (Arrays.asList (refineOrig)); |
655 |
} |
656 |
refine.add ("org.openide.modules.ModuleFormat1"); // NOI18N |
657 |
return (String[])refine.toArray(new String[0]); |
658 |
} else { |
659 |
return refineOrig; |
660 |
} |
522 |
} |
661 |
} |
523 |
/** Used by Module to communicate with the ModuleInstaller re. classloader. */ |
662 |
/** Used by Module to communicate with the ModuleInstaller re. classloader. */ |
524 |
public void refineClassLoader(Module m, List parents) { |
663 |
public void refineClassLoader(Module m, List parents) { |
525 |
// #27853: |
664 |
// #27853: |
526 |
installer.refineClassLoader(m, parents); |
665 |
getInstaller(false).refineClassLoader(m, parents); |
527 |
} |
666 |
} |
528 |
/** Use by OneModuleClassLoader to communicate with the ModuleInstaller re. masking. */ |
667 |
/** Use by OneModuleClassLoader to communicate with the ModuleInstaller re. masking. */ |
529 |
public boolean shouldDelegateResource(Module m, Module parent, String pkg) { |
668 |
public boolean shouldDelegateResource(Module m, Module parent, String pkg) { |
Lines 578-591
Link Here
|
578 |
return false; |
717 |
return false; |
579 |
} |
718 |
} |
580 |
// The installer can perform additional checks: |
719 |
// The installer can perform additional checks: |
581 |
return installer.shouldDelegateResource(m, parent, pkg); |
720 |
return getInstaller(false).shouldDelegateResource(m, parent, pkg); |
582 |
} |
721 |
} |
583 |
public boolean isSpecialResource(String pkg) { |
722 |
public boolean isSpecialResource(String pkg) { |
584 |
return installer.isSpecialResource(pkg); |
723 |
return getInstaller(false).isSpecialResource(pkg); |
585 |
} |
724 |
} |
586 |
// Again, access from Module to ModuleInstaller: |
725 |
// Again, access from Module to ModuleInstaller: |
587 |
Manifest loadManifest(File jar) throws IOException { |
726 |
Manifest loadManifest(File jar) throws IOException { |
588 |
return installer.loadManifest(jar); |
727 |
return getInstaller(false).loadManifest(jar); |
589 |
} |
728 |
} |
590 |
|
729 |
|
591 |
private void subCreate(Module m) throws DuplicateException { |
730 |
private void subCreate(Module m) throws DuplicateException { |
Lines 627-633
Link Here
|
627 |
assertWritable(); |
766 |
assertWritable(); |
628 |
if (m.isFixed()) throw new IllegalArgumentException("fixed module: " + m); // NOI18N |
767 |
if (m.isFixed()) throw new IllegalArgumentException("fixed module: " + m); // NOI18N |
629 |
if (m.isEnabled()) throw new IllegalArgumentException("enabled module: " + m); // NOI18N |
768 |
if (m.isEnabled()) throw new IllegalArgumentException("enabled module: " + m); // NOI18N |
630 |
ev.log(Events.DELETE_MODULE, m); |
769 |
getEvents().log(Events.DELETE_MODULE, m); |
631 |
modules.remove(m); |
770 |
modules.remove(m); |
632 |
modulesByName.remove(m.getCodeNameBase()); |
771 |
modulesByName.remove(m.getCodeNameBase()); |
633 |
possibleProviderRemoved(m); |
772 |
possibleProviderRemoved(m); |
Lines 731-740
Link Here
|
731 |
return; |
870 |
return; |
732 |
} |
871 |
} |
733 |
*/ |
872 |
*/ |
734 |
ev.log(Events.PERF_START, "ModuleManager.enable"); // NOI18N |
873 |
getEvents().log(Events.PERF_START, "ModuleManager.enable"); // NOI18N |
735 |
// Basic problems will be caught here, and we also get the autoloads: |
874 |
// Basic problems will be caught here, and we also get the autoloads: |
736 |
List toEnable = simulateEnable(modules); |
875 |
List toEnable = simulateEnable(modules); |
737 |
ev.log(Events.PERF_TICK, "checked the required ordering and autoloads"); // NOI18N |
876 |
getEvents().log(Events.PERF_TICK, "checked the required ordering and autoloads"); // NOI18N |
738 |
|
877 |
|
739 |
Util.err.log("enable: toEnable=" + toEnable); // NOI18N |
878 |
Util.err.log("enable: toEnable=" + toEnable); // NOI18N |
740 |
{ |
879 |
{ |
Lines 754-762
Link Here
|
754 |
} |
893 |
} |
755 |
} |
894 |
} |
756 |
Util.err.log("enable: verified dependencies"); |
895 |
Util.err.log("enable: verified dependencies"); |
757 |
ev.log(Events.PERF_TICK, "verified dependencies"); // NOI18N |
896 |
getEvents().log(Events.PERF_TICK, "verified dependencies"); // NOI18N |
758 |
|
897 |
|
759 |
ev.log(Events.START_ENABLE_MODULES, toEnable); |
898 |
getEvents().log(Events.START_ENABLE_MODULES, toEnable); |
760 |
{ |
899 |
{ |
761 |
// Actually turn on the listed modules. |
900 |
// Actually turn on the listed modules. |
762 |
// List of modules that need to be "rolled back". |
901 |
// List of modules that need to be "rolled back". |
Lines 770-781
Link Here
|
770 |
try { |
909 |
try { |
771 |
Iterator teIt = toEnable.iterator(); |
910 |
Iterator teIt = toEnable.iterator(); |
772 |
|
911 |
|
773 |
ev.log(Events.PERF_START, "module preparation" ); // NOI18N |
912 |
getEvents().log(Events.PERF_START, "module preparation" ); // NOI18N |
774 |
while (teIt.hasNext()) { |
913 |
while (teIt.hasNext()) { |
775 |
Module m = (Module)teIt.next(); |
914 |
Module m = (Module)teIt.next(); |
776 |
fallback.addFirst(m); |
915 |
fallback.addFirst(m); |
777 |
Util.err.log("enable: bringing up: " + m); |
916 |
Util.err.log("enable: bringing up: " + m); |
778 |
ev.log(Events.PERF_START, "bringing up classloader on " + m.getCodeName() ); // NOI18N |
917 |
getEvents().log(Events.PERF_START, "bringing up classloader on " + m.getCodeName() ); // NOI18N |
779 |
try { |
918 |
try { |
780 |
// Calculate the parents to initialize the classloader with. |
919 |
// Calculate the parents to initialize the classloader with. |
781 |
Dependency[] dependencies = m.getDependenciesArray(); |
920 |
Dependency[] dependencies = m.getDependenciesArray(); |
Lines 802-810
Link Here
|
802 |
throw ie; |
941 |
throw ie; |
803 |
} |
942 |
} |
804 |
m.setEnabled(true); |
943 |
m.setEnabled(true); |
805 |
ev.log(Events.PERF_END, "bringing up classloader on " + m.getCodeName() ); // NOI18N |
944 |
getEvents().log(Events.PERF_END, "bringing up classloader on " + m.getCodeName() ); // NOI18N |
806 |
// Check package dependencies. |
945 |
// Check package dependencies. |
807 |
ev.log(Events.PERF_START, "package dependency check on " + m.getCodeName() ); // NOI18N |
946 |
getEvents().log(Events.PERF_START, "package dependency check on " + m.getCodeName() ); // NOI18N |
808 |
Util.err.log("enable: checking package dependencies for " + m); |
947 |
Util.err.log("enable: checking package dependencies for " + m); |
809 |
Dependency[] dependencies = m.getDependenciesArray(); |
948 |
Dependency[] dependencies = m.getDependenciesArray(); |
810 |
for (int i = 0; i < dependencies.length; i++) { |
949 |
for (int i = 0; i < dependencies.length; i++) { |
Lines 818-830
Link Here
|
818 |
} |
957 |
} |
819 |
Util.err.log("Successful check for: " + dep); |
958 |
Util.err.log("Successful check for: " + dep); |
820 |
} |
959 |
} |
821 |
ev.log(Events.PERF_END, "package dependency check on " + m.getCodeName() ); // NOI18N |
960 |
getEvents().log(Events.PERF_END, "package dependency check on " + m.getCodeName() ); // NOI18N |
822 |
// Prepare to load it. |
961 |
// Prepare to load it. |
823 |
ev.log(Events.PERF_START, "ModuleInstaller.prepare " + m.getCodeName() ); // NOI18N |
962 |
getEvents().log(Events.PERF_START, "ModuleInstaller.prepare " + m.getCodeName() ); // NOI18N |
824 |
installer.prepare(m); |
963 |
getInstaller(false).prepare(m); |
825 |
ev.log(Events.PERF_END, "ModuleInstaller.prepare " + m.getCodeName() ); // NOI18N |
964 |
getEvents().log(Events.PERF_END, "ModuleInstaller.prepare " + m.getCodeName() ); // NOI18N |
826 |
} |
965 |
} |
827 |
ev.log(Events.PERF_END, "module preparation" ); // NOI18N |
966 |
getEvents().log(Events.PERF_END, "module preparation" ); // NOI18N |
828 |
|
967 |
|
829 |
} catch (InvalidException ie) { |
968 |
} catch (InvalidException ie) { |
830 |
// Remember that there was a problem with this guy. |
969 |
// Remember that there was a problem with this guy. |
Lines 895-901
Link Here
|
895 |
Util.err.log("enable: no class loader yet, not appending"); |
1034 |
Util.err.log("enable: no class loader yet, not appending"); |
896 |
} |
1035 |
} |
897 |
Util.err.log("enable: continuing to installation"); |
1036 |
Util.err.log("enable: continuing to installation"); |
898 |
installer.load(toEnable); |
1037 |
getInstaller(false).load(toEnable); |
899 |
} |
1038 |
} |
900 |
{ |
1039 |
{ |
901 |
// Take care of notifying various changes. |
1040 |
// Take care of notifying various changes. |
Lines 911-917
Link Here
|
911 |
} |
1050 |
} |
912 |
} |
1051 |
} |
913 |
} |
1052 |
} |
914 |
ev.log(Events.FINISH_ENABLE_MODULES, toEnable); |
1053 |
getEvents().log(Events.FINISH_ENABLE_MODULES, toEnable); |
915 |
firer.fire(); |
1054 |
firer.fire(); |
916 |
} |
1055 |
} |
917 |
|
1056 |
|
Lines 941-954
Link Here
|
941 |
} |
1080 |
} |
942 |
} |
1081 |
} |
943 |
Util.err.log("disable: verified dependencies"); |
1082 |
Util.err.log("disable: verified dependencies"); |
944 |
ev.log(Events.START_DISABLE_MODULES, toDisable); |
1083 |
getEvents().log(Events.START_DISABLE_MODULES, toDisable); |
945 |
{ |
1084 |
{ |
946 |
// Actually turn off all modules. |
1085 |
// Actually turn off all modules. |
947 |
installer.unload(toDisable); |
1086 |
getInstaller(true).unload(toDisable); |
948 |
Iterator it = toDisable.iterator(); |
1087 |
Iterator it = toDisable.iterator(); |
949 |
while (it.hasNext()) { |
1088 |
while (it.hasNext()) { |
950 |
Module m = (Module)it.next(); |
1089 |
Module m = (Module)it.next(); |
951 |
installer.dispose(m); |
1090 |
getInstaller(true).dispose(m); |
952 |
m.setEnabled(false); |
1091 |
m.setEnabled(false); |
953 |
m.classLoaderDown(); |
1092 |
m.classLoaderDown(); |
954 |
} |
1093 |
} |
Lines 974-980
Link Here
|
974 |
firer.change(new ChangeFirer.Change(m, Module.PROP_CLASS_LOADER, null, null)); |
1113 |
firer.change(new ChangeFirer.Change(m, Module.PROP_CLASS_LOADER, null, null)); |
975 |
} |
1114 |
} |
976 |
} |
1115 |
} |
977 |
ev.log(Events.FINISH_DISABLE_MODULES, toDisable); |
1116 |
getEvents().log(Events.FINISH_DISABLE_MODULES, toDisable); |
978 |
firer.fire(); |
1117 |
firer.fire(); |
979 |
} |
1118 |
} |
980 |
|
1119 |
|
Lines 1549-1555
Link Here
|
1549 |
Util.err.log(ErrorManager.WARNING, "Cyclic module dependencies, will not shut down cleanly: " + deps); // NOI18N |
1688 |
Util.err.log(ErrorManager.WARNING, "Cyclic module dependencies, will not shut down cleanly: " + deps); // NOI18N |
1550 |
return true; |
1689 |
return true; |
1551 |
} |
1690 |
} |
1552 |
if (! installer.closing(modules)) { |
1691 |
if (! getInstaller(true).closing(modules)) { |
1553 |
return false; |
1692 |
return false; |
1554 |
} |
1693 |
} |
1555 |
if (midHook != null) { |
1694 |
if (midHook != null) { |
Lines 1561-1567
Link Here
|
1561 |
Util.err.notify(e); |
1700 |
Util.err.notify(e); |
1562 |
} |
1701 |
} |
1563 |
} |
1702 |
} |
1564 |
installer.close(modules); |
1703 |
getInstaller(true).close(modules); |
1565 |
return true; |
1704 |
return true; |
1566 |
} |
1705 |
} |
|
|
1706 |
|
1707 |
final ModuleInstaller getInstaller(boolean needRealInstaller) { |
1708 |
if (needRealInstaller && (installer instanceof EmptyInstaller)) { |
1709 |
installer = (ModuleInstaller)Lookup.getDefault().lookup(ModuleInstaller.class); |
1710 |
assert installer != null : "ModuleInstaller must be provided in lookup"; // NOI18N |
1711 |
} |
1712 |
return installer; |
1713 |
} |
1714 |
|
1715 |
/** Access for ManifestSection. |
1716 |
* @since JST-PENDING needed by ManifestSection |
1717 |
*/ |
1718 |
public final Events getEvents() { |
1719 |
if (ev == null) { |
1720 |
ev = new NbEvents(); |
1721 |
//ev = (Events)Lookup.getDefault().lookup(Events.class); |
1722 |
assert ev != null : "Must register Events in lookup"; // NOI18N |
1723 |
} |
1724 |
return ev; |
1725 |
} |
1726 |
private static class EmptyInstaller extends ModuleInstaller { |
1727 |
public void unload(List modules) { |
1728 |
throw new IllegalStateException(); |
1729 |
} |
1730 |
|
1731 |
public void prepare(Module m) throws InvalidException { |
1732 |
System.err.println("default prepare: " + m); |
1733 |
} |
1734 |
|
1735 |
public void load(List modules) { |
1736 |
System.err.println("default load: " + modules); |
1737 |
} |
1738 |
|
1739 |
public void dispose(Module m) { |
1740 |
throw new IllegalStateException(); |
1741 |
} |
1742 |
|
1743 |
public boolean closing(List modules) { |
1744 |
throw new IllegalStateException(); |
1745 |
} |
1746 |
|
1747 |
public void close(List modules) { |
1748 |
throw new IllegalStateException(); |
1749 |
} |
1750 |
|
1751 |
}; |
1567 |
} |
1752 |
} |