KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ims > Foo


1 package ims;
2
3 import java.io.IOException JavaDoc;
4 import java.io.ObjectInputStream JavaDoc;
5 import java.net.URL JavaDoc;
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 JavaDoc loader;
14     public transient String JavaDoc loaderToString;
15     public transient URL JavaDoc resource;
16     public transient String JavaDoc text;
17     public Foo() {
18         init();
19     }
20     private void init() {
21         loader = Lookup.getDefault().lookup(ClassLoader JavaDoc.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 JavaDoc("no classloader");
30         if (resource == null) throw new NullPointerException JavaDoc("no ims/Bundle.properties from " + loaderToString);
31         System.err.println("loader=" + loaderToString + " resource=" + resource + " text=" + text);
32     }
33     public String JavaDoc getName() {
34         return "foo";
35     }
36     public HelpCtx getHelpCtx() {
37         return null;
38     }
39     private void readObject(ObjectInputStream JavaDoc ois) throws IOException JavaDoc, ClassNotFoundException JavaDoc {
40         ois.defaultReadObject();
41         //System.err.println("readObject");
42
//Thread.dumpStack();
43
init();
44     }
45 }
46
Popular Tags