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 org.bookmodule;

import org.openide.cookies.InstanceCookie;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject;
import org.openide.loaders.Environment;
import org.openide.util.Lookup;
import org.openide.util.lookup.Lookups;

import java.io.IOException;


public class BookFactory implements Environment.Provider {
    public BookFactory() {
    }

    public static Book createBook() {
        return new Book();
    }


    public static Book createBookWithParams(FileObject fo) {
        String author = (String) fo.getAttribute("author");
        String title = (String) fo.getAttribute("title");
        return new Book(author, title);
    }

    public Lookup getEnvironment(DataObject obj) {
        return Lookups.fixed(new Object[]{new InstanceCookie() {
            Book book = new Book();

            public String instanceName() {
                return book.getClass().getName();
            }

            public Class instanceClass()
                    throws IOException, ClassNotFoundException {
                return book.getClass();
            }

            public Object instanceCreate()
                    throws IOException, ClassNotFoundException {
                return book;
            }
        }});
    }

}

... 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.