| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
V - The type of object to be created.C - The context in which V will be created.  Consider this
               akin to a param or data needed in order to successfully create an
               object.public interface ContextFactoryIfc<V,C>
A factory that defines creating objects based upon a context (a parameter that
    the resulting object needs in order to be created).
    This is a version of the "Gang of Four" Factory pattern:  "Define an
    interface for creating an object, but let subclasses decide which class to
    instantiate.  Factory Method lets a class defer instantiation to subclasses,"
     p107 Design Patterns - Elements of Reusable Object-Oriented Software.
    This interface introduces a parameter that is used when creating the object
    entitled Context.  Also, as a  context factory can create objects,
    it must too be able to clean up those objects (via the destroy()
    method).
    
public final class Person
{
    private String _name;
    private int    _age;
    public Person ( final String name )
    {
        name = _name;
    }
    private Person ()
    {
    }
    public String getName () { return _name; }
    public int getAge () { return _age; }
    public void setAge ( final String age ) { _age = age; }
}
public final class PersonFactory implements ContextFactoryIfc <Person, String>
{
    public Person create ( String name )
    {
        return new Person ( name );
    }
    public void destroy ( Person object )
    {
    }
}
    
    Essentially, to implement a context factory, do the following:
    Person
            above).
        ContextFactoryIfc and
            provde the generic types (the created type and data to use in creation)
            for ContextFactoryIfc (for instance
            implements ContextFactoryIfc <Person, String> above).
        
Modifications:
    $Date: 2008-12-02 12:32:45 -0500 (Tue, 02 Dec 2008) $
    $Revision: 479 $
    $Author: sfloess $
    $HeadURL: https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/src/dev/java/org/jplate/foundation/gof/factory/ContextFactoryIfc.java $
    
| Method Summary | |
|---|---|
 V | 
create(C context)
Creates a new object.  | 
 void | 
destroy(V object)
Destroys (or cleans up) object created by self. | 
| Method Detail | 
|---|
V create(C context)
context - The data needed to create the return value.
void destroy(V object)
object created by self.
object - The object to destroy/clean-up.
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||