net.sf.gilead.core
Class PersistentBeanManager

java.lang.Object
  extended by net.sf.gilead.core.PersistentBeanManager

public class PersistentBeanManager
extends java.lang.Object

Manager for Persistent POJO handling

Author:
bruno.marchesson

Field Summary
protected  IClassMapper _classMapper
          The Class mapper
protected  LazyKiller _lazyKiller
          The POJO lazy killer
protected  IPersistenceUtil _persistenceUtil
          The associated persistence util implementation
protected  IProxyStore _proxyStore
          The associated Proxy informations store
 
Constructor Summary
PersistentBeanManager()
          Empty Constructor
 
Method Summary
 java.lang.Object clone(java.lang.Object object)
          Clone and store the Hibernate POJO(s)
 java.lang.Object clone(java.lang.Object object, boolean assignable)
          Clone and store the Hibernate POJO
protected  java.util.Collection<?> cloneCollection(java.util.Collection<?> hibernatePojoList, boolean assignable)
          Clone and store a collection of Hibernate POJO
protected  java.util.Map<?,?> cloneMap(java.util.Map<?,?> hibernatePojoMap, boolean assignable)
          Clone and store a map of Hibernate POJO
protected  java.lang.Object clonePojo(java.lang.Object pojo, boolean assignable)
          Clone and store the Hibernate POJO
protected  java.util.Collection<java.lang.Object> createNewCollection(java.util.Collection<?> pojoCollection)
          Create a new collection with the same behavior than the argument one
protected  java.util.Map<java.lang.Object,java.lang.Object> createNewMap(java.util.Map<?,?> pojoMap)
          Create a new map with the same behavior than the argument one
 IClassMapper getClassMapper()
           
static PersistentBeanManager getInstance()
           
 IPersistenceUtil getPersistenceUtil()
           
 IProxyStore getProxyStore()
           
protected  boolean holdPersistentObject(java.lang.Object pojo)
          In deep persistent association checking.
protected  boolean holdPersistentObject(java.lang.Object pojo, java.util.List<java.lang.Object> alreadyChecked)
          In deep persistent association checking.
 java.lang.Object merge(java.lang.Object object)
          Merge the clone POJO to its Hibernate counterpart
 java.lang.Object merge(java.lang.Object object, boolean assignable)
          Merge the clone POJO to its Hibernate counterpart
protected  java.util.Collection<?> mergeCollection(java.util.Collection<?> clonePojoList, boolean assignable)
          Retrieve the Hibernate Pojo List and merge the modification from GWT
protected  java.util.Map<?,?> mergeMap(java.util.Map<?,?> cloneMap, boolean assignable)
          Fill copy map with Hibernate merged POJO
protected  java.lang.Object mergePojo(java.lang.Object clonePojo, boolean assignable)
          Retrieve the Hibernate Pojo and merge the modification from GWT
 void setClassMapper(IClassMapper mapper)
           
 void setPersistenceUtil(IPersistenceUtil util)
           
 void setProxyStore(IProxyStore proxyStore)
          set the used pojo store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_proxyStore

protected IProxyStore _proxyStore
The associated Proxy informations store


_classMapper

protected IClassMapper _classMapper
The Class mapper


_lazyKiller

protected LazyKiller _lazyKiller
The POJO lazy killer


_persistenceUtil

protected IPersistenceUtil _persistenceUtil
The associated persistence util implementation

Constructor Detail

PersistentBeanManager

public PersistentBeanManager()
Empty Constructor

Method Detail

getInstance

public static PersistentBeanManager getInstance()
Returns:
the unique instance of the singleton

getProxyStore

public IProxyStore getProxyStore()
Returns:
the proxy store

setProxyStore

public void setProxyStore(IProxyStore proxyStore)
set the used pojo store


getClassMapper

public IClassMapper getClassMapper()
Returns:
the class mapper

setClassMapper

public void setClassMapper(IClassMapper mapper)
Parameters:
mapper - the class Mapper to set

getPersistenceUtil

public IPersistenceUtil getPersistenceUtil()
Returns:
the _persistenceUtil

setPersistenceUtil

public void setPersistenceUtil(IPersistenceUtil util)
Parameters:
util - the _persistenceUtil to set

clone

public java.lang.Object clone(java.lang.Object object)
Clone and store the Hibernate POJO(s)


clone

public java.lang.Object clone(java.lang.Object object,
                              boolean assignable)
Clone and store the Hibernate POJO

Parameters:
object - the object to store
assignable - if the assignation from source to target class (via ClassMapper) must be checked
Returns:
the clone

merge

public java.lang.Object merge(java.lang.Object object)
Merge the clone POJO to its Hibernate counterpart


merge

public java.lang.Object merge(java.lang.Object object,
                              boolean assignable)
Merge the clone POJO to its Hibernate counterpart


clonePojo

protected java.lang.Object clonePojo(java.lang.Object pojo,
                                     boolean assignable)
Clone and store the Hibernate POJO

Parameters:
pojo - the pojo to store
assignable - does the source and target class must be assignable?
Throws:
NotAssignableException - if source and target class are not assignable

cloneMap

protected java.util.Map<?,?> cloneMap(java.util.Map<?,?> hibernatePojoMap,
                                      boolean assignable)
Clone and store a map of Hibernate POJO


cloneCollection

protected java.util.Collection<?> cloneCollection(java.util.Collection<?> hibernatePojoList,
                                                  boolean assignable)
Clone and store a collection of Hibernate POJO


mergePojo

protected java.lang.Object mergePojo(java.lang.Object clonePojo,
                                     boolean assignable)
Retrieve the Hibernate Pojo and merge the modification from GWT

Parameters:
clonePojo - the clone pojo
assignable - does the source and target class must be assignable
Returns:
the merged Hibernate POJO
Throws:
java.lang.UnsupportedOperationException - if the clone POJO does not implements ILightEntity and the POJO store is stateless
NotAssignableException - if source and target class are not assignable

mergeCollection

protected java.util.Collection<?> mergeCollection(java.util.Collection<?> clonePojoList,
                                                  boolean assignable)
Retrieve the Hibernate Pojo List and merge the modification from GWT

Parameters:
clonePojoList - the clone pojo list
Returns:
a list of merged Hibernate POJO
Throws:
java.lang.UnsupportedOperationException - if a POJO from the list does not implements ILightEntity and the POJO store is stateless

mergeMap

protected java.util.Map<?,?> mergeMap(java.util.Map<?,?> cloneMap,
                                      boolean assignable)
Fill copy map with Hibernate merged POJO

Parameters:
cloneMap -
Returns:
a map with merge Hibernate POJO

createNewCollection

protected java.util.Collection<java.lang.Object> createNewCollection(java.util.Collection<?> pojoCollection)
Create a new collection with the same behavior than the argument one

Parameters:
pojoCollection - the source collection
Returns:
a newly created, empty collection

createNewMap

protected java.util.Map<java.lang.Object,java.lang.Object> createNewMap(java.util.Map<?,?> pojoMap)
Create a new map with the same behavior than the argument one

Parameters:
pojoMap - the source map
Returns:
a newly created, empty map

holdPersistentObject

protected boolean holdPersistentObject(java.lang.Object pojo)
In deep persistent association checking. This method is used to detect wrapping object (ie not persistent class holding persistent associations)

Parameters:
pojo - the wrapping pojo
Returns:
true if the pojo contains persistent member, false otherwise

holdPersistentObject

protected boolean holdPersistentObject(java.lang.Object pojo,
                                       java.util.List<java.lang.Object> alreadyChecked)
In deep persistent association checking. This method is used to detect wrapping object (ie not persistent class holding persistent associations)

Parameters:
pojo - the wrapping pojo
alreadyChecked - list of already checked pojos
Returns:
true if the pojo contains persistent member, false otherwise