net.walend.lyophil
Class GenericMother

java.lang.Object
  |
  +--net.walend.lyophil.GenericMother
All Implemented Interfaces:
Mother, java.io.Serializable

public class GenericMother
extends java.lang.Object
implements Mother, java.io.Serializable

This class implemetns Mother. It uses the role-to-class and role-to-interface defined in lyophil.properties

It uses introspection to call the concrete class's constructors. This Mother immediately freezes a new Freezable in the Director's Freezer.

Since:
20001230
Author:
David Walend

Field Summary
protected  Map classesToInterfaces
           
protected  Map interfacesToRoles
           
protected  Map rolesToClasses
           
protected  Map rolesToInterfaces
           
 
Fields inherited from interface net.walend.lyophil.Mother
BEAN, INTERFACE, PREFIX, ROLE
 
Constructor Summary
GenericMother()
           
 
Method Summary
private  java.lang.String arrayToString(java.lang.Object[] array)
           
 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()
           
protected  PropertySource getPropertySource()
           
 java.lang.String getRoleForInterface(java.lang.Class interf)
           
 void postCreate(Freezable freezable, Mother caller)
          Freezes the new Freezable immediately
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rolesToInterfaces

protected Map rolesToInterfaces

interfacesToRoles

protected Map interfacesToRoles

rolesToClasses

protected Map rolesToClasses

classesToInterfaces

protected Map classesToInterfaces
Constructor Detail

GenericMother

public GenericMother()
Method Detail

getPropertySource

protected PropertySource getPropertySource()

getInterfaceForRole

public java.lang.Class getInterfaceForRole(java.lang.String role)
Specified by:
getInterfaceForRole in interface Mother

getRoleForInterface

public java.lang.String getRoleForInterface(java.lang.Class interf)
Specified by:
getRoleForInterface in interface Mother

getInterfaceForBeanClass

public java.lang.Class getInterfaceForBeanClass(java.lang.Class beanClass)
Specified by:
getInterfaceForBeanClass in interface Mother

getInterfaces

public Set getInterfaces()
Specified by:
getInterfaces in interface Mother

createNewInstance

public Freezable createNewInstance(java.lang.String role)
Description copied from interface: Mother
Create a new instance of a class for the given role wanted. Freeze that instance immediately.

implementations should call postCreate(new freezable,this);

Specified by:
createNewInstance in interface Mother
Following copied from interface: net.walend.lyophil.Mother
Parameters:
role - the role that the Freezable should implement

arrayToString

private java.lang.String arrayToString(java.lang.Object[] array)

postCreate

public void postCreate(Freezable freezable,
                       Mother caller)
Freezes the new Freezable immediately

Specified by:
postCreate in interface Mother

createNewInstance

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

implementations should call postCreate(new freezable,this);

Specified by:
createNewInstance in interface Mother
Following copied from interface: net.walend.lyophil.Mother
Parameters:
role - the role that the Freezable should implement
parameters - for the object's constructor.

createEvilClone

public Freezable createEvilClone(Freezable freezy,
                                 java.lang.String role)
Description copied from interface: Mother
Create a copy as a new instance with a new identifier. Freeze that instance immediately.

implementations should call postCreate(new freezable,this);

Specified by:
createEvilClone in interface Mother
Following copied from interface: net.walend.lyophil.Mother
Parameters:
freezy - the Freezable to copy.

restoreNewInstance

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

Specified by:
restoreNewInstance in interface Mother
Following copied from interface: net.walend.lyophil.Mother
Parameters:
role - the role that the Freezable should implement

restoreNewInstance

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

Specified by:
restoreNewInstance in interface Mother
Following copied from interface: net.walend.lyophil.Mother
Parameters:
role - the role that the Freezable should implement
id - the identifier of this Freezable
parameters - for the object's constructor.


Copyright (c) 2000, 2001, David Walend