Lines 52-60
Link Here
|
52 |
import java.io.FileNotFoundException; |
52 |
import java.io.FileNotFoundException; |
53 |
import java.io.IOException; |
53 |
import java.io.IOException; |
54 |
import java.io.InputStream; |
54 |
import java.io.InputStream; |
|
|
55 |
import java.io.ObjectInputStream; |
55 |
import java.io.ObjectOutput; |
56 |
import java.io.ObjectOutput; |
|
|
57 |
import java.io.ObjectOutputStream; |
56 |
import java.io.OutputStream; |
58 |
import java.io.OutputStream; |
57 |
import java.io.OutputStreamWriter; |
59 |
import java.io.OutputStreamWriter; |
|
|
60 |
import java.io.PushbackInputStream; |
58 |
import java.io.Writer; |
61 |
import java.io.Writer; |
59 |
import java.util.ArrayList; |
62 |
import java.util.ArrayList; |
60 |
import java.util.Arrays; |
63 |
import java.util.Arrays; |
Lines 82-87
Link Here
|
82 |
import org.openide.filesystems.FileObject; |
85 |
import org.openide.filesystems.FileObject; |
83 |
import org.openide.filesystems.FileRenameEvent; |
86 |
import org.openide.filesystems.FileRenameEvent; |
84 |
import org.openide.filesystems.FileSystem; |
87 |
import org.openide.filesystems.FileSystem; |
|
|
88 |
import org.openide.filesystems.FileSystem.AtomicAction; |
85 |
import org.openide.filesystems.FileUtil; |
89 |
import org.openide.filesystems.FileUtil; |
86 |
import org.openide.modules.Dependency; |
90 |
import org.openide.modules.Dependency; |
87 |
import org.openide.modules.InstalledFileLocator; |
91 |
import org.openide.modules.InstalledFileLocator; |
Lines 164-316
Link Here
|
164 |
ev.log(Events.START_READ); |
168 |
ev.log(Events.START_READ); |
165 |
final Set<Module> read = new HashSet<Module>(); |
169 |
final Set<Module> read = new HashSet<Module>(); |
166 |
try { |
170 |
try { |
167 |
folder.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() { |
171 |
folder.getFileSystem().runAtomicAction(new ReadInitial(read)); |
168 |
public void run() throws IOException { |
|
|
169 |
|
170 |
Map<String, Map<String, Object>> cache = readCache(); |
171 |
String[] names; |
172 |
if (cache != null) { |
173 |
names = cache.keySet().toArray(new String[0]); |
174 |
} else { |
175 |
FileObject[] children = folder.getChildren(); |
176 |
List<String> arr = new ArrayList<String>(children.length); |
177 |
for (FileObject f : children) { |
178 |
if (f.hasExt("ser")) { // NOI18N |
179 |
// Fine, skip over. |
180 |
} else if (f.hasExt("xml")) { // NOI18N |
181 |
// Assume this is one of ours. Note fixed naming scheme. |
182 |
String nameDashes = f.getName(); // NOI18N |
183 |
char[] badChars = {'.', '/', '>', '='}; |
184 |
for (int j = 0; j < 4; j++) { |
185 |
if (nameDashes.indexOf(badChars[j]) != -1) { |
186 |
throw new IllegalArgumentException("Bad name: " + nameDashes); // NOI18N |
187 |
} |
188 |
} |
189 |
String name = nameDashes.replace('-', '.').intern(); // NOI18N |
190 |
arr.add(name); |
191 |
} else { |
192 |
LOG.fine("Strange file encountered in modules folder: " + f); |
193 |
} |
194 |
} |
195 |
names = arr.toArray(new String[0]); |
196 |
} |
197 |
ev.log( Events.MODULES_FILE_SCANNED, names.length ); |
198 |
|
199 |
XMLReader reader = null; |
200 |
|
201 |
for (int i = 0; i < names.length; i++) { |
202 |
String name = names[i]; |
203 |
FileObject f = null; |
204 |
try { |
205 |
|
206 |
// Now name is the code name base of the module we expect to find. |
207 |
// Check its format (throws IllegalArgumentException if bad): |
208 |
Dependency.create(Dependency.TYPE_MODULE, name); |
209 |
|
210 |
// OK, read it from disk. |
211 |
Map<String,Object> props = cache == null ? null : cache.get(name); |
212 |
if (props == null) { |
213 |
LOG.log(Level.FINEST, "no cache for {0}", name); |
214 |
f = folder.getFileObject(name.replace('.', '-') + ".xml"); |
215 |
InputStream is = f.getInputStream(); |
216 |
try { |
217 |
props = readStatus(new BufferedInputStream(is),true); |
218 |
if (props == null) { |
219 |
LOG.warning("Note - failed to parse " + f + " the quick way, falling back on XMLReader"); |
220 |
is.close(); |
221 |
is = f.getInputStream(); |
222 |
InputSource src = new InputSource(is); |
223 |
// Make sure any includes etc. are handled properly: |
224 |
src.setSystemId(f.getURL().toExternalForm()); |
225 |
if (reader == null) { |
226 |
try { |
227 |
reader = XMLUtil.createXMLReader(); |
228 |
} catch(SAXException e) { |
229 |
throw (IllegalStateException) new IllegalStateException(e.toString()).initCause(e); |
230 |
} |
231 |
reader.setEntityResolver(listener); |
232 |
reader.setErrorHandler(listener); |
233 |
} |
234 |
props = readStatus(src,reader); |
235 |
} |
236 |
} finally { |
237 |
is.close(); |
238 |
} |
239 |
} |
240 |
if (! name.equals(props.get("name"))) throw new IOException("Code name mismatch: " /* #25011 */ + name + " vs. " + props.get("name")); // NOI18N |
241 |
Boolean enabledB = (Boolean)props.get("enabled"); // NOI18N |
242 |
String jar = (String)props.get("jar"); // NOI18N |
243 |
File jarFile; |
244 |
try { |
245 |
jarFile = findJarByName(jar, name); |
246 |
} catch (FileNotFoundException fnfe) { |
247 |
//LOG.fine("Cannot find: " + fnfe.getMessage()); |
248 |
ev.log(Events.MISSING_JAR_FILE, new File(fnfe.getMessage()), enabledB); |
249 |
if (!Boolean.FALSE.equals(enabledB)) { |
250 |
try { |
251 |
f.delete(); |
252 |
} catch (IOException ioe) { |
253 |
LOG.log(Level.WARNING, null, ioe); |
254 |
} |
255 |
} |
256 |
continue; |
257 |
} |
258 |
|
259 |
ModuleHistory history = new ModuleHistory(jar); // NOI18N |
260 |
Integer prevReleaseI = (Integer)props.get("release"); // NOI18N |
261 |
int prevRelease = (prevReleaseI == null ? -1 : prevReleaseI.intValue()); |
262 |
SpecificationVersion prevSpec = (SpecificationVersion)props.get("specversion"); // NOI18N |
263 |
history.upgrade(prevRelease, prevSpec); |
264 |
Boolean reloadableB = (Boolean)props.get("reloadable"); // NOI18N |
265 |
boolean reloadable = (reloadableB != null ? reloadableB.booleanValue() : false); |
266 |
boolean enabled = (enabledB != null ? enabledB.booleanValue() : false); |
267 |
Boolean autoloadB = (Boolean)props.get("autoload"); // NOI18N |
268 |
boolean autoload = (autoloadB != null ? autoloadB.booleanValue() : false); |
269 |
Boolean eagerB = (Boolean)props.get("eager"); // NOI18N |
270 |
boolean eager = (eagerB != null ? eagerB.booleanValue() : false); |
271 |
String installer = (String)props.get("installer"); // NOI18N |
272 |
if (installer != null) { |
273 |
String nameDashes = name.replace('.', '-'); |
274 |
if (! installer.equals(nameDashes + ".ser")) throw new IOException("Incorrect installer ser name: " + installer); // NOI18N |
275 |
// Load from disk in mentioned file. |
276 |
FileObject installerSer = folder.getFileObject(nameDashes, "ser"); // NOI18N |
277 |
if (installerSer == null) throw new IOException("No such install ser: " + installer + "; I see only: " + Arrays.asList(folder.getChildren())); // NOI18N |
278 |
// Hope the stored state is not >Integer.MAX_INT! :-) |
279 |
byte[] buf = new byte[(int)installerSer.getSize()]; |
280 |
InputStream is2 = installerSer.getInputStream(); |
281 |
try { |
282 |
is2.read(buf); |
283 |
} finally { |
284 |
is2.close(); |
285 |
} |
286 |
history.setInstallerState(buf); |
287 |
// Quasi-prop which is stored separately. |
288 |
props.put("installerState", buf); // NOI18N |
289 |
} |
290 |
Module m = mgr.create(jarFile, history, reloadable, autoload, eager); |
291 |
read.add(m); |
292 |
DiskStatus status = new DiskStatus(); |
293 |
status.module = m; |
294 |
status.file = f; |
295 |
//status.lastApprovedChange = children[i].lastModified().getTime(); |
296 |
status.pendingInstall = enabled; |
297 |
// Will only really be flushed if mgr props != disk props, i.e |
298 |
// if version changed or could not be enabled. |
299 |
//status.pendingFlush = true; |
300 |
status.setDiskProps(props); |
301 |
statuses.put(name, status); |
302 |
} catch (Exception e) { |
303 |
LOG.log(Level.WARNING, "Error encountered while reading " + name, e); |
304 |
} |
305 |
ev.log( Events.MODULES_FILE_PROCESSED, name ); |
306 |
} |
307 |
if (LOG.isLoggable(Level.FINE)) { |
308 |
LOG.fine("read initial XML files: statuses=" + statuses); |
309 |
} |
310 |
ev.log(Events.FINISH_READ, read); |
311 |
// Handle changes in the Modules/ folder on disk by parsing & applying them. |
312 |
folder.addFileChangeListener(FileUtil.weakFileChangeListener (listener, folder)); |
313 |
}}); |
314 |
} catch (IOException ioe) { |
172 |
} catch (IOException ioe) { |
315 |
LOG.log(Level.WARNING, null, ioe); |
173 |
LOG.log(Level.WARNING, null, ioe); |
316 |
} |
174 |
} |
Lines 786-834
Link Here
|
786 |
* you have to use a real parser. |
644 |
* you have to use a real parser. |
787 |
* @see "#26786" |
645 |
* @see "#26786" |
788 |
*/ |
646 |
*/ |
789 |
private Map<String, Object> readStatus(InputStream is,boolean checkEOF) throws IOException { |
647 |
private Map<String, Object> readStatus(InputStream is, boolean checkEOF) throws IOException { |
|
|
648 |
PushbackInputStream pbis = new PushbackInputStream(is, 1); |
790 |
Map<String,Object> m = new HashMap<String,Object>(15); |
649 |
Map<String,Object> m = new HashMap<String,Object>(15); |
791 |
if (!expect(is, MODULE_XML_INTRO)) { |
650 |
if (!expect(pbis, MODULE_XML_INTRO)) { |
792 |
LOG.fine("Could not read intro"); |
651 |
LOG.fine("Could not read intro"); |
793 |
return null; |
652 |
return null; |
794 |
} |
653 |
} |
795 |
String name = readTo(is, '"'); |
654 |
String name = readTo(pbis, '"'); |
796 |
if (name == null) { |
655 |
if (name == null) { |
797 |
LOG.fine("Could not read code name base"); |
656 |
LOG.fine("Could not read code name base"); |
798 |
return null; |
657 |
return null; |
799 |
} |
658 |
} |
800 |
m.put("name", name.intern()); // NOI18N |
659 |
m.put("name", name.intern()); // NOI18N |
801 |
if (!expect(is, MODULE_XML_INTRO_END)) { |
660 |
if (!expect(pbis, MODULE_XML_INTRO_END)) { |
802 |
LOG.fine("Could not read stuff after cnb"); |
661 |
LOG.fine("Could not read stuff after cnb"); |
803 |
return null; |
662 |
return null; |
804 |
} |
663 |
} |
805 |
// Now we have <param>s some number of times, finally </module>. |
664 |
// Now we have <param>s some number of times, finally </module>. |
806 |
PARSE: |
665 |
PARSE: |
807 |
while (true) { |
666 |
while (true) { |
808 |
int c = is.read(); |
667 |
int c = pbis.read(); |
809 |
switch (c) { |
668 |
switch (c) { |
810 |
case ' ': |
669 |
case ' ': |
811 |
// <param> |
670 |
// <param> |
812 |
if (!expect(is, MODULE_XML_DIV2)) { |
671 |
if (!expect(pbis, MODULE_XML_DIV2)) { |
813 |
LOG.fine("Could not read up to param"); |
672 |
LOG.fine("Could not read up to param"); |
814 |
return null; |
673 |
return null; |
815 |
} |
674 |
} |
816 |
String k = readTo(is, '"'); |
675 |
String k = readTo(pbis, '"'); |
817 |
if (k == null) { |
676 |
if (k == null) { |
818 |
LOG.fine("Could not read param"); |
677 |
LOG.fine("Could not read param"); |
819 |
return null; |
678 |
return null; |
820 |
} |
679 |
} |
821 |
k = k.intern(); |
680 |
k = k.intern(); |
822 |
if (is.read() != '>') { |
681 |
if (pbis.read() != '>') { |
823 |
LOG.fine("No > at end of <param> " + k); |
682 |
LOG.fine("No > at end of <param> " + k); |
824 |
return null; |
683 |
return null; |
825 |
} |
684 |
} |
826 |
String v = readTo(is, '<'); |
685 |
String v = readTo(pbis, '<'); |
827 |
if (v == null) { |
686 |
if (v == null) { |
828 |
LOG.fine("Could not read value of " + k); |
687 |
LOG.fine("Could not read value of " + k); |
829 |
return null; |
688 |
return null; |
830 |
} |
689 |
} |
831 |
if (!expect(is, MODULE_XML_DIV3)) { |
690 |
if (!expect(pbis, MODULE_XML_DIV3)) { |
832 |
LOG.fine("Could not read end of param " + k); |
691 |
LOG.fine("Could not read end of param " + k); |
833 |
return null; |
692 |
return null; |
834 |
} |
693 |
} |
Lines 841-854
Link Here
|
841 |
break; |
700 |
break; |
842 |
case '<': |
701 |
case '<': |
843 |
// </module> |
702 |
// </module> |
844 |
if (!expect(is, MODULE_XML_END)) { |
703 |
if (!expect(pbis, MODULE_XML_END)) { |
845 |
LOG.fine("Strange ending"); |
704 |
LOG.fine("Strange ending"); |
846 |
return null; |
705 |
return null; |
847 |
} |
706 |
} |
848 |
if (!checkEOF) { |
707 |
if (!checkEOF) { |
849 |
break PARSE; |
708 |
break PARSE; |
850 |
} |
709 |
} |
851 |
if (is.read() != -1) { |
710 |
if (pbis.read() != -1) { |
852 |
LOG.fine("Trailing garbage"); |
711 |
LOG.fine("Trailing garbage"); |
853 |
return null; |
712 |
return null; |
854 |
} |
713 |
} |
Lines 867-873
Link Here
|
867 |
* Newline conventions are normalized to Unix \n. |
726 |
* Newline conventions are normalized to Unix \n. |
868 |
* @return true upon success, false if stream contained something else |
727 |
* @return true upon success, false if stream contained something else |
869 |
*/ |
728 |
*/ |
870 |
private boolean expect(InputStream is, byte[] stuff) throws IOException { |
729 |
private boolean expect(PushbackInputStream is, byte[] stuff) throws IOException { |
871 |
int len = stuff.length; |
730 |
int len = stuff.length; |
872 |
boolean inNewline = false; |
731 |
boolean inNewline = false; |
873 |
for (int i = 0; i < len; ) { |
732 |
for (int i = 0; i < len; ) { |
Lines 890-901
Link Here
|
890 |
if (stuff[len - 1] == 10) { |
749 |
if (stuff[len - 1] == 10) { |
891 |
// Expecting something ending in a \n - so we have to |
750 |
// Expecting something ending in a \n - so we have to |
892 |
// read any further \r or \n and discard. |
751 |
// read any further \r or \n and discard. |
893 |
if (!is.markSupported()) throw new IOException("Mark not supported"); // NOI18N |
|
|
894 |
is.mark(1); |
895 |
int c = is.read(); |
752 |
int c = is.read(); |
896 |
if (c != -1 && c != 10 && c != 13) { |
753 |
if (c != -1 && c != 10 && c != 13) { |
897 |
// Got some non-newline character, push it back! |
754 |
// Got some non-newline character, push it back! |
898 |
is.reset(); |
755 |
is.unread(c); |
899 |
} |
756 |
} |
900 |
} |
757 |
} |
901 |
return true; |
758 |
return true; |
Lines 939-945
Link Here
|
939 |
} |
796 |
} |
940 |
} |
797 |
} |
941 |
|
798 |
|
942 |
private Map<String,Map<String,Object>> readCache() throws IOException { |
799 |
final Map<String,Map<String,Object>> readCache() throws IOException { |
943 |
InputStream is = Stamps.getModulesJARs().asStream("all-modules.dat"); // NOI18N |
800 |
InputStream is = Stamps.getModulesJARs().asStream("all-modules.dat"); // NOI18N |
944 |
if (is == null) { |
801 |
if (is == null) { |
945 |
// schedule write for later |
802 |
// schedule write for later |
Lines 947-979
Link Here
|
947 |
return null; |
804 |
return null; |
948 |
} |
805 |
} |
949 |
LOG.log(Level.FINEST, "Reading cache all-modules.dat"); |
806 |
LOG.log(Level.FINEST, "Reading cache all-modules.dat"); |
|
|
807 |
ObjectInputStream ois = new ObjectInputStream(is); |
950 |
|
808 |
|
951 |
Map<String,Map<String,Object>> ret = new HashMap<String, Map<String, Object>>(1333); |
809 |
Map<String,Map<String,Object>> ret = new HashMap<String, Map<String, Object>>(1333); |
952 |
while (is.available() > 0) { |
810 |
while (is.available() > 0) { |
953 |
Map<String, Object> prop = readStatus(is, false); |
811 |
Map<String, Object> prop = readStatus(ois, false); |
954 |
if (prop == null) { |
812 |
if (prop == null) { |
955 |
LOG.log(Level.CONFIG, "Cache is invalid all-modules.dat"); |
813 |
LOG.log(Level.CONFIG, "Cache is invalid all-modules.dat"); |
956 |
return null; |
814 |
return null; |
957 |
} |
815 |
} |
|
|
816 |
Set<?> deps; |
817 |
try { |
818 |
deps = (Set<?>) ois.readObject(); |
819 |
} catch (ClassNotFoundException ex) { |
820 |
throw (IOException)new IOException(ex.getMessage()).initCause(ex); |
821 |
} |
822 |
prop.put("deps", deps); |
958 |
String cnb = (String)prop.get("name"); // NOI18N |
823 |
String cnb = (String)prop.get("name"); // NOI18N |
959 |
ret.put(cnb, prop); |
824 |
ret.put(cnb, prop); |
960 |
} |
825 |
} |
961 |
is.close(); |
|
|
962 |
|
826 |
|
963 |
return ret; |
827 |
|
964 |
} |
828 |
is.close(); |
|
|
829 |
|
830 |
return ret; |
831 |
} |
965 |
|
832 |
|
966 |
final void writeCache() { |
833 |
final void writeCache() { |
967 |
Stamps.getModulesJARs().scheduleSave(this, "all-modules.dat", false); |
834 |
Stamps.getModulesJARs().scheduleSave(this, "all-modules.dat", false); |
968 |
} |
835 |
} |
969 |
|
836 |
|
|
|
837 |
public void cacheReady() { |
838 |
} |
839 |
|
970 |
public void flushCaches(DataOutputStream os) throws IOException { |
840 |
public void flushCaches(DataOutputStream os) throws IOException { |
|
|
841 |
ObjectOutputStream oss = new ObjectOutputStream(os); |
971 |
for (Module m : mgr.getModules()) { |
842 |
for (Module m : mgr.getModules()) { |
972 |
if (m.isFixed()) { |
843 |
if (m.isFixed()) { |
973 |
continue; |
844 |
continue; |
974 |
} |
845 |
} |
975 |
Map<String, Object> prop = computeProperties(m); |
846 |
Map<String, Object> prop = computeProperties(m); |
976 |
writeStatus(prop, os); |
847 |
writeStatus(prop, oss); |
|
|
848 |
oss.writeObject(m.getDependencies()); |
977 |
} |
849 |
} |
978 |
} |
850 |
} |
979 |
|
851 |
|
Lines 1819-1825
Link Here
|
1819 |
} |
1691 |
} |
1820 |
} |
1692 |
} |
1821 |
|
1693 |
|
1822 |
public void cacheReady() { |
1694 |
private class ReadInitial implements AtomicAction { |
|
|
1695 |
|
1696 |
private final Set<Module> read; |
1697 |
|
1698 |
public ReadInitial(Set<Module> read) { |
1699 |
this.read = read; |
1700 |
} |
1701 |
|
1702 |
public void run() throws IOException { |
1703 |
Map<String, Map<String, Object>> cache = readCache(); |
1704 |
String[] names; |
1705 |
if (cache != null) { |
1706 |
names = cache.keySet().toArray(new String[0]); |
1707 |
} else { |
1708 |
FileObject[] children = folder.getChildren(); |
1709 |
List<String> arr = new ArrayList<String>(children.length); |
1710 |
for (FileObject f : children) { |
1711 |
if (f.hasExt("ser")) { // NOI18N |
1712 |
// Fine, skip over. |
1713 |
} else if (f.hasExt("xml")) { |
1714 |
// NOI18N |
1715 |
// Assume this is one of ours. Note fixed naming scheme. |
1716 |
String nameDashes = f.getName(); // NOI18N |
1717 |
char[] badChars = {'.', '/', '>', '='}; |
1718 |
for (int j = 0; j < 4; j++) { |
1719 |
if (nameDashes.indexOf(badChars[j]) != -1) { |
1720 |
throw new IllegalArgumentException("Bad name: " + nameDashes); // NOI18N |
1721 |
} |
1722 |
} |
1723 |
String name = nameDashes.replace('-', '.').intern(); // NOI18N |
1724 |
arr.add(name); |
1725 |
} else { |
1726 |
LOG.fine("Strange file encountered in modules folder: " + f); |
1727 |
} |
1728 |
} |
1729 |
names = arr.toArray(new String[0]); |
1730 |
} |
1731 |
ev.log(Events.MODULES_FILE_SCANNED, names.length); |
1732 |
XMLReader reader = null; |
1733 |
for (int i = 0; i < names.length; i++) { |
1734 |
String name = names[i]; |
1735 |
FileObject f = null; |
1736 |
try { |
1737 |
// OK, read it from disk. |
1738 |
Map<String, Object> props = cache == null ? null : cache.get(name); |
1739 |
if (props == null) { |
1740 |
// Now name is the code name base of the module we expect to find. |
1741 |
// Check its format (throws IllegalArgumentException if bad): |
1742 |
Dependency.create(Dependency.TYPE_MODULE, name); |
1743 |
LOG.log(Level.FINEST, "no cache for {0}", name); |
1744 |
f = folder.getFileObject(name.replace('.', '-') + ".xml"); |
1745 |
InputStream is = f.getInputStream(); |
1746 |
try { |
1747 |
props = readStatus(new BufferedInputStream(is), true); |
1748 |
if (props == null) { |
1749 |
LOG.warning("Note - failed to parse " + f + " the quick way, falling back on XMLReader"); |
1750 |
is.close(); |
1751 |
is = f.getInputStream(); |
1752 |
InputSource src = new InputSource(is); |
1753 |
// Make sure any includes etc. are handled properly: |
1754 |
src.setSystemId(f.getURL().toExternalForm()); |
1755 |
if (reader == null) { |
1756 |
try { |
1757 |
reader = XMLUtil.createXMLReader(); |
1758 |
} catch (SAXException e) { |
1759 |
throw (IllegalStateException) new IllegalStateException(e.toString()).initCause(e); |
1760 |
} |
1761 |
reader.setEntityResolver(listener); |
1762 |
reader.setErrorHandler(listener); |
1763 |
} |
1764 |
props = readStatus(src, reader); |
1765 |
} |
1766 |
} finally { |
1767 |
is.close(); |
1768 |
} |
1769 |
} |
1770 |
if (!name.equals(props.get("name"))) { |
1771 |
throw new IOException("Code name mismatch: " + name + " vs. " + props.get("name")); // NOI18N |
1772 |
} |
1773 |
Boolean enabledB = (Boolean) props.get("enabled"); // NOI18N |
1774 |
String jar = (String) props.get("jar"); // NOI18N |
1775 |
File jarFile; |
1776 |
try { |
1777 |
jarFile = findJarByName(jar, name); |
1778 |
} catch (FileNotFoundException fnfe) { |
1779 |
//LOG.fine("Cannot find: " + fnfe.getMessage()); |
1780 |
ev.log(Events.MISSING_JAR_FILE, new File(fnfe.getMessage()), enabledB); |
1781 |
if (!Boolean.FALSE.equals(enabledB)) { |
1782 |
try { |
1783 |
f.delete(); |
1784 |
} catch (IOException ioe) { |
1785 |
LOG.log(Level.WARNING, null, ioe); |
1786 |
} |
1787 |
} |
1788 |
continue; |
1789 |
} |
1790 |
ModuleHistory history = new ModuleHistory(jar); // NOI18N |
1791 |
Integer prevReleaseI = (Integer) props.get("release"); // NOI18N |
1792 |
int prevRelease = prevReleaseI == null ? -1 : prevReleaseI.intValue(); |
1793 |
SpecificationVersion prevSpec = (SpecificationVersion) props.get("specversion"); // NOI18N |
1794 |
history.upgrade(prevRelease, prevSpec); |
1795 |
Boolean reloadableB = (Boolean) props.get("reloadable"); // NOI18N |
1796 |
boolean reloadable = reloadableB != null ? reloadableB.booleanValue() : false; |
1797 |
boolean enabled = enabledB != null ? enabledB.booleanValue() : false; |
1798 |
Boolean autoloadB = (Boolean) props.get("autoload"); // NOI18N |
1799 |
boolean autoload = autoloadB != null ? autoloadB.booleanValue() : false; |
1800 |
Boolean eagerB = (Boolean) props.get("eager"); // NOI18N |
1801 |
boolean eager = eagerB != null ? eagerB.booleanValue() : false; |
1802 |
String installer = (String) props.get("installer"); // NOI18N |
1803 |
if (installer != null) { |
1804 |
String nameDashes = name.replace('.', '-'); |
1805 |
if (!installer.equals(nameDashes + ".ser")) { |
1806 |
throw new IOException("Incorrect installer ser name: " + installer); // NOI18N |
1807 |
} |
1808 |
// Load from disk in mentioned file. |
1809 |
FileObject installerSer = folder.getFileObject(nameDashes, "ser"); // NOI18N |
1810 |
if (installerSer == null) { |
1811 |
throw new IOException("No such install ser: " + installer + "; I see only: " + Arrays.asList(folder.getChildren())); // NOI18N |
1812 |
} |
1813 |
// Hope the stored state is not >Integer.MAX_INT! :-) |
1814 |
byte[] buf = new byte[(int) installerSer.getSize()]; |
1815 |
InputStream is2 = installerSer.getInputStream(); |
1816 |
try { |
1817 |
is2.read(buf); |
1818 |
} finally { |
1819 |
is2.close(); |
1820 |
} |
1821 |
history.setInstallerState(buf); |
1822 |
// Quasi-prop which is stored separately. |
1823 |
props.put("installerState", buf); // NOI18N |
1824 |
} |
1825 |
NbInstaller.register(name, props.get("deps")); // NOI18N |
1826 |
Module m = mgr.create(jarFile, history, reloadable, autoload, eager); |
1827 |
NbInstaller.register(null, null); |
1828 |
read.add(m); |
1829 |
DiskStatus status = new DiskStatus(); |
1830 |
status.module = m; |
1831 |
status.file = f; |
1832 |
//status.lastApprovedChange = children[i].lastModified().getTime(); |
1833 |
status.pendingInstall = enabled; |
1834 |
// Will only really be flushed if mgr props != disk props, i.e |
1835 |
// if version changed or could not be enabled. |
1836 |
//status.pendingFlush = true; |
1837 |
status.setDiskProps(props); |
1838 |
statuses.put(name, status); |
1839 |
} catch (Exception e) { |
1840 |
LOG.log(Level.WARNING, "Error encountered while reading " + name, e); |
1841 |
} |
1842 |
ev.log(Events.MODULES_FILE_PROCESSED, name); |
1843 |
} |
1844 |
if (LOG.isLoggable(Level.FINE)) { |
1845 |
LOG.fine("read initial XML files: statuses=" + statuses); |
1846 |
} |
1847 |
ev.log(Events.FINISH_READ, read); |
1848 |
// Handle changes in the Modules/ folder on disk by parsing & applying them. |
1849 |
folder.addFileChangeListener(FileUtil.weakFileChangeListener(listener, folder)); |
1850 |
} |
1823 |
} |
1851 |
} |
1824 |
|
1852 |
|
1825 |
} |
1853 |
} |