01: package ims;
02:
03: import java.io.IOException;
04: import java.io.ObjectInputStream;
05: import java.net.URL;
06: import org.openide.ServiceType;
07: import org.openide.util.HelpCtx;
08: import org.openide.util.Lookup;
09: 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:
18: public Foo() {
19: init();
20: }
21:
22: private void init() {
23: loader = Lookup.getDefault().lookup(ClassLoader.class);
24: if (loader == null) {
25: Thread.dumpStack();
26: System.err.println("Lookup=" + Lookup.getDefault());
27: }
28: loaderToString = loader != null ? loader.toString() : null;
29: resource = loader != null ? loader
30: .getResource("ims/Bundle.properties") : null;
31: text = NbBundle.getMessage(Foo.class, "foo");
32: if (loader == null)
33: throw new NullPointerException("no classloader");
34: if (resource == null)
35: throw new NullPointerException(
36: "no ims/Bundle.properties from " + loaderToString);
37: System.err.println("loader=" + loaderToString + " resource="
38: + resource + " text=" + text);
39: }
40:
41: public String getName() {
42: return "foo";
43: }
44:
45: public HelpCtx getHelpCtx() {
46: return null;
47: }
48:
49: private void readObject(ObjectInputStream ois) throws IOException,
50: ClassNotFoundException {
51: ois.defaultReadObject();
52: //System.err.println("readObject");
53: //Thread.dumpStack();
54: init();
55: }
56: }
|