alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

package ims;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.URL;
import org.openide.ServiceType;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;

public class Foo extends ServiceType {
    private static final long serialVersionUID = 54629387456L;
    public transient ClassLoader loader;
    public transient String loaderToString;
    public transient URL resource;
    public transient String text;
    public Foo() {
        init();
    }
    private void init() {
        loader = (ClassLoader)Lookup.getDefault().lookup(ClassLoader.class);
        if (loader == null) {
            Thread.dumpStack();
            System.err.println("Lookup=" + Lookup.getDefault());
        }
        loaderToString = loader != null ? loader.toString() : null;
        resource = loader != null ? loader.getResource("ims/Bundle.properties") : null;
        text = NbBundle.getMessage(Foo.class, "foo");
        if (loader == null) throw new NullPointerException("no classloader");
        if (resource == null) throw new NullPointerException("no ims/Bundle.properties from " + loaderToString);
        System.err.println("loader=" + loaderToString + " resource=" + resource + " text=" + text);
    }
    public String getName() {
        return "foo";
    }
    public HelpCtx getHelpCtx() {
        return null;
    }
    private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
        ois.defaultReadObject();
        //System.err.println("readObject");
        //Thread.dumpStack();
        init();
    }
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.