net.walend.lyophil
Interface Mother

All Known Implementing Classes:
FreezableCollectionMother, FreezableStringMother, GenericMother

public interface Mother

This interface creates new Freezable objects that fulfil a given named role and interface.

An instance of Mother will let you easily swap the implementation of the Freezable.

Implementations of Mother should freeze the Freezable they create immediately after they create it. This step will allow Diggers and Freezers to find the Freezable.

Since:
20001125
Author:
David Walend

Field Summary
static java.lang.String BEAN
           
static java.lang.String INTERFACE
           
static java.lang.String PREFIX
           
static java.lang.String ROLE
           
 
Method Summary
 Freezable createEvilClone(Freezable freezy, java.lang.String role)
          Create a copy as a new instance with a new identifier.
 Freezable createNewInstance(java.lang.String role)
          Create a new instance of a class for the given role wanted.
 Freezable createNewInstance(java.lang.String role, java.lang.Object[] parameters)
          Create a new instance of a class for the given role wanted.
 java.lang.Class getInterfaceForBeanClass(java.lang.Class beanClass)
           
 java.lang.Class getInterfaceForRole(java.lang.String role)
           
 Set getInterfaces()
           
 java.lang.String getRoleForInterface(java.lang.Class interf)
           
 void postCreate(Freezable freezable, Mother caller)
          Mothers should call this method after creating a new instance of a Freezable.
 Freezable restoreNewInstance(java.lang.String role, java.io.Serializable id)
          Only call this method from inside a Freezer.
 Freezable restoreNewInstance(java.lang.String role, java.io.Serializable id, java.lang.Object[] parameters)
          Only call this method from inside a Freezer.
 

Field Detail

ROLE

public static final java.lang.String ROLE

PREFIX

public static final java.lang.String PREFIX

BEAN

public static final java.lang.String BEAN

INTERFACE

public static final java.lang.String INTERFACE
Method Detail

getInterfaceForBeanClass

public java.lang.Class getInterfaceForBeanClass(java.lang.Class beanClass)

getInterfaces

public Set getInterfaces()

getInterfaceForRole

public java.lang.Class getInterfaceForRole(java.lang.String role)

getRoleForInterface

public java.lang.String getRoleForInterface(java.lang.Class interf)

createNewInstance

public Freezable createNewInstance(java.lang.String role)
Create a new instance of a class for the given role wanted. Freeze that instance immediately.

implementations should call postCreate(new freezable,this);

Parameters:
role - the role that the Freezable should implement
Throws:
CannotCreateException

createNewInstance

public Freezable createNewInstance(java.lang.String role,
                                   java.lang.Object[] parameters)
Create a new instance of a class for the given role wanted. Freeze that instance immediately.

implementations should call postCreate(new freezable,this);

Parameters:
role - the role that the Freezable should implement
parameters - for the object's constructor.
Throws:
CannotCreateException

createEvilClone

public Freezable createEvilClone(Freezable freezy,
                                 java.lang.String role)
Create a copy as a new instance with a new identifier. Freeze that instance immediately.

implementations should call postCreate(new freezable,this);

Parameters:
freezy - the Freezable to copy.
Throws:
CannotCreateException

postCreate

public void postCreate(Freezable freezable,
                       Mother caller)
Mothers should call this method after creating a new instance of a Freezable. It will normally freeze the new Freezable for the first time.


restoreNewInstance

public Freezable restoreNewInstance(java.lang.String role,
                                    java.io.Serializable id)
Only call this method from inside a Freezer. Restore a persisted instance from a Freezer.

Parameters:
role - the role that the Freezable should implement
Throws:
CannotThawException

restoreNewInstance

public Freezable restoreNewInstance(java.lang.String role,
                                    java.io.Serializable id,
                                    java.lang.Object[] parameters)
Only call this method from inside a Freezer. Restore a persisted instance from a Freezer.

Parameters:
role - the role that the Freezable should implement
id - the identifier of this Freezable
parameters - for the object's constructor.
Throws:
CannotThawException


Copyright (c) 2000, 2001, David Walend