| 1 package ims; 2 3 import java.io.IOException ; 4 import java.io.ObjectInputStream ; 5 import java.net.URL ; 6 import org.openide.ServiceType; 7 import org.openide.util.HelpCtx; 8 import org.openide.util.Lookup; 9 import org.openide.util.NbBundle; 10 11 public class Foo extends ServiceType { 12 private static final long serialVersionUID = 54629387456L; 13 public transient ClassLoader loader; 14 public transient String loaderToString; 15 public transient URL resource; 16 public transient String text; 17 public Foo() { 18 init(); 19 } 20 private void init() { 21 loader = Lookup.getDefault().lookup(ClassLoader .class); 22 if (loader == null) { 23 Thread.dumpStack(); 24 System.err.println("Lookup=" + Lookup.getDefault()); 25 } 26 loaderToString = loader != null ? loader.toString() : null; 27 resource = loader != null ? loader.getResource("ims/Bundle.properties") : null; 28 text = NbBundle.getMessage(Foo.class, "foo"); 29 if (loader == null) throw new NullPointerException ("no classloader"); 30 if (resource == null) throw new NullPointerException ("no ims/Bundle.properties from " + loaderToString); 31 System.err.println("loader=" + loaderToString + " resource=" + resource + " text=" + text); 32 } 33 public String getName() { 34 return "foo"; 35 } 36 public HelpCtx getHelpCtx() { 37 return null; 38 } 39 private void readObject(ObjectInputStream ois) throws IOException , ClassNotFoundException { 40 ois.defaultReadObject(); 41 init(); 44 } 45 } 46 | Popular Tags |