1 19 20 package org.netbeans; 21 22 import java.util.HashSet ; 23 import java.util.List ; 24 import java.util.Set ; 25 import java.util.SortedMap ; 26 import java.util.SortedSet ; 27 import java.util.TreeMap ; 28 import java.util.TreeSet ; 29 import java.util.jar.Manifest ; 30 31 36 public class ConsistencyVerifier { 37 38 private ConsistencyVerifier() {} 39 40 48 public static SortedMap <String ,SortedSet <String >> findInconsistencies(Set <Manifest > modules) throws IllegalArgumentException { 49 ModuleManager mgr = new ModuleManager(new DummyInstaller(), new DummyEvents()); 50 mgr.mutexPrivileged().enterWriteAccess(); 51 Manifest dummy = new Manifest (); 52 dummy.getMainAttributes().putValue("OpenIDE-Module", "__dummy__"); dummy.getMainAttributes().putValue("OpenIDE-Module-Provides", "org.openide.modules.ModuleFormat1, " + "org.openide.modules.os.Unix, " + "org.openide.modules.os.PlainUnix, " + "org.openide.modules.os.Windows, " + "org.openide.modules.os.MacOSX, " + "org.openide.modules.os.OS2"); dummy.getMainAttributes().putValue("OpenIDE-Module-Public-Packages", "-"); try { 61 mgr.createFixed(dummy, null, ClassLoader.getSystemClassLoader()); 62 } catch (Exception x) { 63 throw new AssertionError (x); 64 } 65 Set <Module> mods = new HashSet <Module>(); 66 for (Manifest m : modules) { 67 try { 68 m.getMainAttributes().putValue("OpenIDE-Module-Public-Packages", "-"); mods.add(mgr.createFixed(m, null, ClassLoader.getSystemClassLoader())); 70 } catch (Exception x) { 71 throw new IllegalArgumentException (x); 72 } 73 } 74 SortedMap <String ,SortedSet <String >> problems = new TreeMap <String ,SortedSet <String >>(); 75 for (Module m : mods) { 76 Set <Object > probs = m.getProblems(); 77 if (probs.isEmpty()) { 78 continue; 79 } 80 SortedSet <String > probnames = new TreeSet <String >(); 81 for (Object prob : probs) { 82 probnames.add(prob.toString()); 83 } 84 problems.put(m.getCodeNameBase(), probnames); 85 } 86 return problems; 87 } 88 89 private static final class DummyInstaller extends ModuleInstaller { 90 public void prepare(Module m) throws InvalidException { 91 throw new AssertionError (); 92 } 93 public void dispose(Module m) { 94 throw new AssertionError (); 95 } 96 public void load(List <Module> modules) { 97 throw new AssertionError (); 98 } 99 public void unload(List <Module> modules) { 100 throw new AssertionError (); 101 } 102 public boolean closing(List <Module> modules) { 103 throw new AssertionError (); 104 } 105 public void close(List <Module> modules) { 106 throw new AssertionError (); 107 } 108 } 109 110 private static final class DummyEvents extends Events { 111 protected void logged(String message, Object [] args) {} 112 } 113 114 } 115 | Popular Tags |