|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.beanlib.hibernate.HibernateBeanReplicator
@NotThreadSafe public abstract class HibernateBeanReplicator
Hibernate Bean Replicator.
This class can be used to conveniently replicate Hibernate objects that follow the JavaBean getter/setter convention on a best attempt basis. The replication is typically recursive in that the whole object graph of the input object is replicated into an equivalent output object graph, resolving circular references, and eagerly fetching proxied instances as necessary. However, the exact behavior of the replication process including
BeanPopulatorBaseSpi
are available, as
the replication of JavaBean properties inevitably involves bean population.
HibernatePropertyFilter
is used,
vetoer
used to veto the propagation of a property
initCustomTransformerFactory(net.sf.beanlib.spi.CustomBeanTransformerSpi.Factory...)
.
This was originally the base class for both the Hibernate 2.x and Hibernate 3.x replicators, but now Hibernate 2 is no longer supported.
CustomBeanTransformerSpi
,
Hibernate3BeanReplicator
Field Summary | |
---|---|
private BeanTransformerSpi |
hibernateBeanTransformer
Used to do the heavy lifting of Hibernate object transformation and replication. |
Constructor Summary | |
---|---|
protected |
HibernateBeanReplicator(BeanTransformerSpi hibernateBeanTransformer)
You probably want to construct a Hibernate3BeanReplicator
directly instead of this ? |
Method Summary | ||
---|---|---|
|
copy(Object from,
Class<T> toClass)
Returns an instance of the given class with values copied from the given object. |
|
|
copy(T from)
Returns a copy of the given object. |
|
|
deepCopy(Object from,
Class<T> toClass)
Convenient method to deep copy the given object to an instance of the given class using the default behavior. |
|
|
deepCopy(T from)
Convenient method to deep copy the given object using the default behavior. |
|
BeanPopulationExceptionHandler |
getBeanPopulationExceptionHandler()
Returns the exception handler configured for bean population. |
|
BeanPopulatorBaseConfig |
getBeanPopulatorBaseConfig()
Notes if the returned base config is modified, a subsequent BeanPopulator.initBeanPopulatorBaseConfig(BeanPopulatorBaseConfig)
needs to be invoked to keep the configuration in sync. |
|
BeanSourceHandler |
getBeanSourceHandler()
Returns the call-back configured that would be invoked after the property value has been retrieved from the source bean, but before being propagated across to the target bean. |
|
DetailedPropertyFilter |
getDetailedPropertyFilter()
Returns the detailed property filter configured. |
|
HibernatePropertyFilter |
getHibernatePropertyFilter()
Convenient method to return the current property filter as HibernatePropertyFilter if the type matches; or null otherwise. |
|
PropertyFilter |
getPropertyFilter()
Returns the property filter that is used to control what properties get propagated across and what get skipped. |
|
BeanMethodFinder |
getReaderMethodFinder()
Returns the finder configured to find the property getter methods of a source JavaBean. |
|
BeanMethodCollector |
getSetterMethodCollector()
Returns the collector configured to collect the property setter methods of a target JavaBean. |
|
HibernateBeanReplicator |
initBeanPopulationExceptionHandler(BeanPopulationExceptionHandler beanPopulationExceptionHandler)
Used to configure a handler to handle any exception thrown. |
|
BeanPopulatorBaseSpi |
initBeanPopulatorBaseConfig(BeanPopulatorBaseConfig baseConfig)
Used to conveniently provide the bean population related configuration options as a single configuration object. |
|
HibernateBeanReplicator |
initBeanSourceHandler(BeanSourceHandler beanSourceHandler)
Used to configure a call-back (to produce whatever side-effects deemed necessary) that is invoked after the property value has been retrieved from the source bean, but before being propagated across to the target bean. |
|
HibernateBeanReplicator |
initCustomTransformerFactory(CustomBeanTransformerSpi.Factory... customBeanTransformerFactories)
Initializes with one or more custom bean transformer factories that will be chained together. |
|
HibernateBeanReplicator |
initDebug(boolean debug)
Used to control whether debug messages should be logged. |
|
HibernateBeanReplicator |
initDetailedPropertyFilter(DetailedPropertyFilter detailedPropertyFilter)
Note this method is only applicable if either the copy(Object)
or copy(Object, Class) is directly invoked,
and is ignored otherwise (ie ignored if deep or shallow copy is invoked instead). |
|
HibernateBeanReplicator |
initPropertyFilter(PropertyFilter propertyFilter)
Note this method is only applicable if either the copy(Object)
or copy(Object, Class) is directly invoked,
and is ignored otherwise (ie ignored if deep or shallow copy is invoked instead). |
|
HibernateBeanReplicator |
initReaderMethodFinder(BeanMethodFinder readerMethodFinder)
Used to configure a finder to find the property getter methods of a source JavaBean. |
|
HibernateBeanReplicator |
initSetterMethodCollector(BeanMethodCollector setterMethodCollector)
Used to configure a collector to collect the property setter methods of a target JavaBean. |
|
boolean |
isDebug()
Returns true if debug message logging is on; false otherwise. |
|
|
shallowCopy(Object from,
Class<T> toClass)
Convenient method to shallow copy the given object to an instance of the given class using the default behavior. |
|
|
shallowCopy(T from)
Convenient method to shallow copy the given object using the default behavior. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final BeanTransformerSpi hibernateBeanTransformer
Constructor Detail |
---|
protected HibernateBeanReplicator(BeanTransformerSpi hibernateBeanTransformer)
Hibernate3BeanReplicator
directly instead of this ?
Method Detail |
---|
public final <T> T copy(T from)
In the case when none of the init* methods is invoked, this method behaves
like deepCopy(Object)
, but without using the HibernatePropertyFilter
.
T
- type of the given object.from
- given object.public final <T> T copy(Object from, Class<T> toClass)
In the case when none of the init* methods is invoked, this method behaves
exactly like deepCopy(Object, Class)
.
T
- type of the given object.from
- given object.toClass
- target class of the returned object.public final <T> T deepCopy(T from)
Notes:
copy(Object, Class)
instead of this method
if you want to plug in a different (detailed) property filter.
T
- from object type.from
- given object to be copied.
public final <T> T deepCopy(Object from, Class<T> toClass)
Notes:
copy(Object, Class)
instead of this method
if you want to plug in a different (detailed) property filter.
T
- to object type.from
- given object to be copied.toClass
- target class of the returned object.
public final <T> T shallowCopy(T from)
Notes:
copy(Object, Class)
instead of this method
if you want to plug in a different (detailed) property filter.
T
- from object type.from
- given object to be copied.
HibernatePropertyFilter
public final <T> T shallowCopy(Object from, Class<T> toClass)
Notes:
copy(Object, Class)
instead of this method
if you want to plug in a different (detailed) property filter.
T
- to object type.from
- given object to be copied.
public final HibernateBeanReplicator initCustomTransformerFactory(CustomBeanTransformerSpi.Factory... customBeanTransformerFactories)
ChainedCustomBeanTransformer
public final PropertyFilter getPropertyFilter()
getPropertyFilter
in interface BeanPopulatorBaseSpi
public final HibernateBeanReplicator initPropertyFilter(PropertyFilter propertyFilter)
copy(Object)
or copy(Object, Class)
is directly invoked,
and is ignored otherwise (ie ignored if deep or shallow copy is invoked instead).
initPropertyFilter
in interface BeanPopulatorBaseSpi
propertyFilter
- is similar to DetailedPropertyFilter
but with a simpler API
that is used to control whether a specific JavaBean property should be propagated
from a source bean to a target bean.
public final HibernateBeanReplicator initDetailedPropertyFilter(DetailedPropertyFilter detailedPropertyFilter)
copy(Object)
or copy(Object, Class)
is directly invoked,
and is ignored otherwise (ie ignored if deep or shallow copy is invoked instead).
initDetailedPropertyFilter
in interface BeanPopulatorBaseSpi
detailedPropertyFilter
- is used to control whether a specific JavaBean property
should be propagated from the source bean to the target bean.
public final HibernateBeanReplicator initBeanSourceHandler(BeanSourceHandler beanSourceHandler)
initBeanSourceHandler
in interface BeanPopulatorBaseSpi
beanSourceHandler
- can be used to act as a call-back
(to produce whatever side-effects deemed necessary)
after the property value has been retrieved from the source bean,
but before being propagated across to the target bean.
public final HibernateBeanReplicator initDebug(boolean debug)
initDebug
in interface BeanPopulatorBaseSpi
public final HibernateBeanReplicator initReaderMethodFinder(BeanMethodFinder readerMethodFinder)
initReaderMethodFinder
in interface BeanPopulatorBaseSpi
readerMethodFinder
- can be used to find the property getter methods of a source JavaBean.
public final HibernateBeanReplicator initSetterMethodCollector(BeanMethodCollector setterMethodCollector)
initSetterMethodCollector
in interface BeanPopulatorBaseSpi
setterMethodCollector
- can be used to collect the property setter methods
of a target JavaBean.
public HibernateBeanReplicator initBeanPopulationExceptionHandler(BeanPopulationExceptionHandler beanPopulationExceptionHandler)
BeanPopulatorBaseSpi
initBeanPopulationExceptionHandler
in interface BeanPopulatorBaseSpi
beanPopulationExceptionHandler
- can be used to handle any exception thrown.
public BeanPopulatorBaseSpi initBeanPopulatorBaseConfig(BeanPopulatorBaseConfig baseConfig)
initBeanPopulatorBaseConfig
in interface BeanPopulatorBaseSpi
baseConfig
- is used to conveniently group all the other initializable options into a single unit.
public BeanPopulationExceptionHandler getBeanPopulationExceptionHandler()
BeanPopulatorBaseSpi
getBeanPopulationExceptionHandler
in interface BeanPopulatorBaseSpi
public BeanPopulatorBaseConfig getBeanPopulatorBaseConfig()
BeanPopulator.initBeanPopulatorBaseConfig(BeanPopulatorBaseConfig)
needs to be invoked to keep the configuration in sync.
getBeanPopulatorBaseConfig
in interface BeanPopulatorBaseSpi
public BeanSourceHandler getBeanSourceHandler()
BeanPopulatorBaseSpi
getBeanSourceHandler
in interface BeanPopulatorBaseSpi
public boolean isDebug()
BeanPopulatorBaseSpi
isDebug
in interface BeanPopulatorBaseSpi
public DetailedPropertyFilter getDetailedPropertyFilter()
BeanPopulatorBaseSpi
getDetailedPropertyFilter
in interface BeanPopulatorBaseSpi
public BeanMethodFinder getReaderMethodFinder()
BeanPopulatorBaseSpi
getReaderMethodFinder
in interface BeanPopulatorBaseSpi
public BeanMethodCollector getSetterMethodCollector()
BeanPopulatorBaseSpi
getSetterMethodCollector
in interface BeanPopulatorBaseSpi
public HibernatePropertyFilter getHibernatePropertyFilter()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |