public static BeanPopulator newBeanPopulator(Object from, Object to,
IClassMapper classMapper,
IPersistenceUtil persistenceUtil,
IProxyStore proxyStore)
{
BeanPopulator replicator = BeanPopulator.newBeanPopulator(from, to);
// Change bean class replicator
//
BeanTransformerSpi transformer = (BeanTransformerSpi) replicator.getTransformer();
transformer.initBeanReplicatable(MergeClassBeanReplicator.factory);
((MergeClassBeanReplicator) transformer.getBeanReplicatable()).setClassMapper(classMapper);
((MergeClassBeanReplicator) transformer.getBeanReplicatable()).setPersistenceUtil(persistenceUtil);
((MergeClassBeanReplicator) transformer.getBeanReplicatable()).setProxyStore(proxyStore);
transformer.initCollectionReplicatable(MergeCollectionReplicator.factory);
((MergeCollectionReplicator) transformer.getCollectionReplicatable()).setPersistenceUtil(persistenceUtil);
transformer.initMapReplicatable(MergeMapReplicator.factory);
((MergeMapReplicator) transformer.getMapReplicatable()).setPersistenceUtil(persistenceUtil);
// Custom transformers (timestamp handling)
//
transformer.initCustomTransformerFactory(new CustomBeanTransformerSpi.Factory()
{
public CustomBeanTransformerSpi newCustomBeanTransformer(final BeanTransformerSpi beanTransformer)
{
return CustomTransformersFactory.getInstance().createUnionCustomBeanTransformer(beanTransformer);
}
});
// Lazy properties handling
//
DetailedBeanPopulatable hibernatePopulatable = new MergeBeanPopulatable(persistenceUtil, proxyStore);
replicator.initDetailedBeanPopulatable(hibernatePopulatable);
// Merge based on protected and private setters
//
replicator.initSetterMethodCollector(PrivateSetterMethodCollector.inst);
replicator.initReaderMethodFinder(PrivateReaderMethodFinder.inst);
return replicator;
}