#363 - API CHANGE - BeanPersistController postLoad() ... moved to new/separate BeanPostLoad interface

This commit is contained in:
Robin Bygrave
2015-08-02 21:56:56 +12:00
parent 40ab3c81dc
commit 8f12442ac7
17 changed files with 617 additions and 72 deletions
@@ -262,6 +262,7 @@ public class ServerConfig {
private List<BeanFindController> findControllers = new ArrayList<BeanFindController>();
private List<BeanPersistController> persistControllers = new ArrayList<BeanPersistController>();
private List<BeanPostLoad> postLoaders = new ArrayList<BeanPostLoad>();
private List<BeanPersistListener> persistListeners = new ArrayList<BeanPersistListener>();
private List<BeanQueryAdapter> queryAdapters = new ArrayList<BeanQueryAdapter>();
private List<BulkTableEventListener> bulkTableEventListeners = new ArrayList<BulkTableEventListener>();
@@ -1660,14 +1661,45 @@ public class ServerConfig {
persistControllers.add(beanPersistController);
}
/**
* Register a BeanPostLoad instance.
* <p>
* Note alternatively you can use {@link #setPostLoaders(List)} to set
* all the BeanPostLoad instances.
* </p>
*/
public void add(BeanPostLoad postLoad) {
postLoaders.add(postLoad);
}
/**
* Return the list of BeanFindController instances.
*/
public List<BeanFindController> getFindControllers() {
return findControllers;
}
/**
* Set the list of BeanFindController instances.
*/
public void setFindControllers(List<BeanFindController> findControllers) {
this.findControllers = findControllers;
}
/**
* Return the list of BeanPostLoader instances.
*/
public List<BeanPostLoad> getPostLoaders() {
return postLoaders;
}
/**
* Set the list of BeanPostLoader instances.
*/
public void setPostLoaders(List<BeanPostLoad> postLoaders) {
this.postLoaders = postLoaders;
}
/**
* Return the BeanPersistController instances.
*/
@@ -66,10 +66,4 @@ public abstract class BeanPersistAdapter implements BeanPersistController {
public void postUpdate(BeanPersistRequest<?> request) {
}
/**
* Does nothing by default.
*/
public void postLoad(Object bean, Set<String> includedProperties) {
}
}
@@ -106,10 +106,4 @@ public interface BeanPersistController {
*/
void postDelete(BeanPersistRequest<?> request);
/**
* Called after every each bean is fetched and loaded from the database. You
* can override this to derive some information to set to the bean.
*/
void postLoad(Object bean, Set<String> includedProperties);
}
@@ -0,0 +1,24 @@
package com.avaje.ebean.event;
/**
* Fired after a bean is fetched and loaded from the database.
* <p>
* Note that if want to totally change the finding, you need to use a BeanQueryAdapter
* rather than using postLoad().
* </p>
*/
public interface BeanPostLoad {
/**
* Return true if this BeanPostLoad instance should be registered
* for post load on this entity type.
*/
boolean isRegisterFor(Class<?> cls);
/**
* Called after every each bean is loaded from the database. You
* can implement this to derive some information to set to the bean.
*/
void postLoad(Object bean);
}
@@ -39,6 +39,8 @@ public class BootupClasses implements ClassPathSearchMatcher {
private final List<Class<?>> beanControllerList = new ArrayList<Class<?>>();
private final List<Class<?>> beanPostLoadList = new ArrayList<Class<?>>();
private final List<Class<?>> transactionEventListenerList = new ArrayList<Class<?>>();
private final List<Class<?>> beanFindControllerList = new ArrayList<Class<?>>();
@@ -51,6 +53,7 @@ public class BootupClasses implements ClassPathSearchMatcher {
private final List<BeanFindController> findControllerInstances = new ArrayList<BeanFindController>();
private final List<BeanPersistController> persistControllerInstances = new ArrayList<BeanPersistController>();
private final List<BeanPostLoad> beanPostLoadInstances = new ArrayList<BeanPostLoad>();
private final List<BeanPersistListener> persistListenerInstances = new ArrayList<BeanPersistListener>();
private final List<BeanQueryAdapter> queryAdapterInstances = new ArrayList<BeanQueryAdapter>();
private final List<TransactionEventListener> transactionEventListenerInstances = new ArrayList<TransactionEventListener>();
@@ -113,6 +116,19 @@ public class BootupClasses implements ClassPathSearchMatcher {
}
}
/**
* Add BeanPostLoad instances.
*/
public void addPostLoaders(List<BeanPostLoad> postLoadInstances) {
if (postLoadInstances != null) {
for (BeanPostLoad c : postLoadInstances) {
this.beanPostLoadInstances.add(c);
// don't automatically instantiate
this.beanPostLoadList.remove(c.getClass());
}
}
}
/**
* Add BeanFindController instances.
*/
@@ -223,6 +239,21 @@ public class BootupClasses implements ClassPathSearchMatcher {
return persistControllerInstances;
}
public List<BeanPostLoad> getBeanPostLoaders() {
// add class registered BeanPostLoad to the already created instances
for (Class<?> cls : beanPostLoadList) {
try {
BeanPostLoad newInstance = (BeanPostLoad) cls.newInstance();
beanPostLoadInstances.add(newInstance);
} catch (Exception e) {
String msg = "Error creating BeanPersistController " + cls;
logger.error(msg, e);
}
}
return beanPostLoadInstances;
}
public List<TransactionEventListener> getTransactionEventListeners() {
// add class registered TransactionEventListener to the
// already created instances
@@ -309,6 +340,11 @@ public class BootupClasses implements ClassPathSearchMatcher {
interesting = true;
}
if (BeanPostLoad.class.isAssignableFrom(cls)) {
beanPostLoadList.add(cls);
interesting = true;
}
if (TransactionEventListener.class.isAssignableFrom(cls)) {
transactionEventListenerList.add(cls);
interesting = true;
@@ -242,6 +242,7 @@ public class DefaultContainer implements SpiContainer {
BootupClasses bootupClasses = getBootupClasses1(serverConfig);
bootupClasses.addPersistControllers(serverConfig.getPersistControllers());
bootupClasses.addPostLoaders(serverConfig.getPostLoaders());
bootupClasses.addFindControllers(serverConfig.getFindControllers());
bootupClasses.addTransactionEventListeners(serverConfig.getTransactionEventListeners());
bootupClasses.addPersistListeners(serverConfig.getPersistListeners());
@@ -13,6 +13,7 @@ import com.avaje.ebean.config.dbplatform.IdType;
import com.avaje.ebean.event.BeanFindController;
import com.avaje.ebean.event.BeanPersistController;
import com.avaje.ebean.event.BeanPersistListener;
import com.avaje.ebean.event.BeanPostLoad;
import com.avaje.ebean.event.BeanQueryAdapter;
import com.avaje.ebean.meta.MetaBeanInfo;
import com.avaje.ebean.meta.MetaQueryPlanStatistic;
@@ -151,14 +152,14 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
private final String[] properties;
private final int propertyCount;
/**
* Intercept pre post on insert,update,delete and postLoad(). Server side
* only.
* Intercept pre post on insert,update, and delete .
*/
private volatile BeanPersistController persistController;
private final BeanPostLoad beanPostLoad;
/**
* Listens for post commit insert update and delete events.
*/
@@ -185,6 +186,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
* Derived list of properties that make up the unique id.
*/
protected final BeanProperty idProperty;
private final int idPropertyIndex;
/**
@@ -330,6 +332,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
this.beanFinder = deploy.getBeanFinder();
this.persistController = deploy.getPersistController();
this.persistListener = deploy.getPersistListener();
this.beanPostLoad = deploy.getPostLoad();
this.queryAdapter = deploy.getQueryAdapter();
this.defaultSelectClause = deploy.getDefaultSelectClause();
@@ -934,12 +937,11 @@ public class BeanDescriptor<T> implements MetaBeanInfo {
}
/**
* Execute the postLoad if a BeanPersistController exists for this bean.
* Execute the postLoad if a BeanPostLoad exists for this bean.
*/
public void postLoad(Object bean, Set<String> includedProperties) {
BeanPersistController c = persistController;
if (c != null) {
c.postLoad(bean, includedProperties);
public void postLoad(Object bean) {
if (beanPostLoad != null) {
beanPostLoad.postLoad(bean);
}
}
@@ -88,6 +88,8 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
private final PersistControllerManager persistControllerManager;
private final PostLoadManager postLoadManager;
private final BeanFinderManager beanFinderManager;
private final PersistListenerManager persistListenerManager;
@@ -188,6 +190,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
this.beanLifecycleAdapterFactory = new BeanLifecycleAdapterFactory();
this.persistControllerManager = new PersistControllerManager(bootupClasses);
this.postLoadManager = new PostLoadManager(bootupClasses);
this.persistListenerManager = new PersistListenerManager(bootupClasses);
this.beanQueryAdapterManager = new BeanQueryAdapterManager(bootupClasses);
this.beanFinderManager = new BeanFinderManager(bootupClasses);
@@ -443,10 +446,11 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
int qa = beanQueryAdapterManager.getRegisterCount();
int cc = persistControllerManager.getRegisterCount();
int pl = postLoadManager.getRegisterCount();
int lc = persistListenerManager.getRegisterCount();
int fc = beanFinderManager.getRegisterCount();
logger.debug("BeanPersistControllers[" + cc + "] BeanFinders[" + fc + "] BeanPersistListeners[" + lc + "] BeanQueryAdapters[" + qa + "]");
logger.debug("BeanPersistControllers[" + cc + "] BeanFinders[" + fc + "] BeanPersistListeners[" + lc + "] BeanQueryAdapters[" + qa + "] BeanPostLoaders[" + pl + "]");
}
private void logStatus() {
@@ -973,6 +977,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
private <T> void setBeanControllerFinderListener(DeployBeanDescriptor<T> descriptor) {
persistControllerManager.addPersistControllers(descriptor);
postLoadManager.addPostLoad(descriptor);
persistListenerManager.addPersistListeners(descriptor);
beanQueryAdapterManager.addQueryAdapter(descriptor);
beanFinderManager.addFindControllers(descriptor);
@@ -4,7 +4,6 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.persistence.PersistenceException;
import javax.persistence.PostLoad;
@@ -17,6 +16,7 @@ import javax.persistence.PreUpdate;
import com.avaje.ebean.event.BeanPersistAdapter;
import com.avaje.ebean.event.BeanPersistRequest;
import com.avaje.ebean.event.BeanPostLoad;
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
/**
@@ -35,14 +35,20 @@ public class BeanLifecycleAdapterFactory {
Method[] methods = deployDesc.getBeanType().getMethods();
// look for annotated methods
MethodsHolder methodHolder = new MethodsHolder();
for (Method m : methods) {
methodHolder.checkMethod(m);
}
if (methodHolder.hasListener()) {
deployDesc.addPersistController(new Adapter(methodHolder));
if (methodHolder.hasPersistMethods()) {
// has pre/post persist annotated methods
deployDesc.addPersistController(new PersistAdapter(new PersistMethodsHolder(methodHolder)));
}
if (!methodHolder.postLoads.isEmpty()) {
// has postLoad methods
deployDesc.addPostLoad(new PostLoadAdapter(methodHolder.postLoads));
}
}
@@ -51,7 +57,7 @@ public class BeanLifecycleAdapterFactory {
*/
private static class MethodsHolder {
private boolean hasListener;
private boolean hasPersistMethods;
private final List<Method> preInserts = new ArrayList<Method>();
private final List<Method> postInserts = new ArrayList<Method>();
private final List<Method> preUpdates = new ArrayList<Method>();
@@ -60,53 +66,88 @@ public class BeanLifecycleAdapterFactory {
private final List<Method> postDeletes = new ArrayList<Method>();
private final List<Method> postLoads = new ArrayList<Method>();
private boolean hasListener() {
return hasListener;
/**
* Has one of the pre or post insert update delete annotated methods.
*/
private boolean hasPersistMethods() {
return hasPersistMethods;
}
/**
* Check the method for all the annotations we are interested in.
*/
private void checkMethod(Method method) {
if (method.isAnnotationPresent(PrePersist.class)) {
preInserts.add(method);
hasListener = true;
hasPersistMethods = true;
}
if (method.isAnnotationPresent(PostPersist.class)) {
postInserts.add(method);
hasListener = true;
hasPersistMethods = true;
}
if (method.isAnnotationPresent(PreUpdate.class)) {
preUpdates.add(method);
hasListener = true;
hasPersistMethods = true;
}
if (method.isAnnotationPresent(PostUpdate.class)) {
postUpdates.add(method);
hasListener = true;
hasPersistMethods = true;
}
if (method.isAnnotationPresent(PreRemove.class)) {
preDeletes.add(method);
hasListener = true;
hasPersistMethods = true;
}
if (method.isAnnotationPresent(PostRemove.class)) {
postDeletes.add(method);
hasListener = true;
hasPersistMethods = true;
}
if (method.isAnnotationPresent(PostLoad.class)) {
postLoads.add(method);
hasListener = true;
}
}
}
/**
* Utility method to covert List of Method into array (because we care about performance here).
*/
static Method[] toArray(List<Method> methodList) {
return methodList.toArray(new Method[methodList.size()]);
}
/**
* Holds Methods for the lifecycle events.s
*/
private static class PersistMethodsHolder {
private final Method[] preInserts;
private final Method[] postInserts;
private final Method[] preUpdates;
private final Method[] postUpdates;
private final Method[] preDeletes;
private final Method[] postDeletes;
PersistMethodsHolder(MethodsHolder methodsHolder) {
this.preInserts = toArray(methodsHolder.preInserts);
this.preUpdates = toArray(methodsHolder.preUpdates);
this.preDeletes = toArray(methodsHolder.preDeletes);
this.postInserts = toArray(methodsHolder.postInserts);
this.postUpdates = toArray(methodsHolder.postUpdates);
this.postDeletes = toArray(methodsHolder.postDeletes);
}
}
/**
* BeanPersistAdapter using reflection to invoke lifecycle methods.
*/
private static class Adapter extends BeanPersistAdapter {
private static class PersistAdapter extends BeanPersistAdapter {
private final MethodsHolder methodHolder;
private final PersistMethodsHolder methodHolder;
private Adapter(MethodsHolder methodHolder) {
private PersistAdapter(PersistMethodsHolder methodHolder) {
this.methodHolder = methodHolder;
}
@@ -126,10 +167,9 @@ public class BeanLifecycleAdapterFactory {
}
}
private void invoke(List<Method> methods, BeanPersistRequest<?> request) {
if (methods.isEmpty()) return;
for (Method method : methods) {
invoke(method, request.getBean());
private void invoke(Method[] methods, BeanPersistRequest<?> request) {
for (int i = 0; i < methods.length; i++) {
invoke(methods[i], request.getBean());
}
}
@@ -165,12 +205,39 @@ public class BeanLifecycleAdapterFactory {
public void postUpdate(BeanPersistRequest<?> request) {
invoke(methodHolder.postUpdates, request);
}
}
/**
* BeanPostLoad using reflection to invoke lifecycle methods.
*/
private static class PostLoadAdapter implements BeanPostLoad {
private final Method[] postLoadMethods;
private PostLoadAdapter(List<Method> postLoadMethods) {
this.postLoadMethods = toArray(postLoadMethods);
}
@Override
public void postLoad(Object bean, Set<String> includedProperties) {
if (methodHolder.postLoads.isEmpty()) return;
for (Method method : methodHolder.postLoads) {
invoke(method, bean);
public boolean isRegisterFor(Class<?> cls) {
// Not used
return false;
}
private void invoke(Method method, Object bean) {
try {
method.invoke(bean);
} catch (InvocationTargetException e) {
throw new PersistenceException("Error invoking lifecycle method", e);
} catch (IllegalAccessException e) {
throw new PersistenceException("Error invoking lifecycle method", e);
}
}
@Override
public void postLoad(Object bean) {
for (int i = 0; i < postLoadMethods.length; i++) {
invoke(postLoadMethods[i], bean);
}
}
}
@@ -1,13 +1,12 @@
package com.avaje.ebeaninternal.server.deploy;
import com.avaje.ebean.event.BeanPersistController;
import com.avaje.ebean.event.BeanPersistRequest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import com.avaje.ebean.event.BeanPersistController;
import com.avaje.ebean.event.BeanPersistRequest;
/**
* Chains multiple BeanPersistController's together.
@@ -19,6 +18,7 @@ public class ChainedBeanPersistController implements BeanPersistController {
private static final Sorter SORTER = new Sorter();
private final List<BeanPersistController> list;
private final BeanPersistController[] chain;
/**
@@ -88,6 +88,7 @@ public class ChainedBeanPersistController implements BeanPersistController {
/**
* Always returns 0 (not used for this object).
*/
@Override
public int getExecutionOrder() {
return 0;
}
@@ -95,34 +96,33 @@ public class ChainedBeanPersistController implements BeanPersistController {
/**
* Always returns false (not used for this object).
*/
@Override
public boolean isRegisterFor(Class<?> cls) {
return false;
}
@Override
public void postDelete(BeanPersistRequest<?> request) {
for (int i = 0; i < chain.length; i++) {
chain[i].postDelete(request);
}
}
@Override
public void postInsert(BeanPersistRequest<?> request) {
for (int i = 0; i < chain.length; i++) {
chain[i].postInsert(request);
}
}
public void postLoad(Object bean, Set<String> includedProperties) {
for (int i = 0; i < chain.length; i++) {
chain[i].postLoad(bean, includedProperties);
}
}
@Override
public void postUpdate(BeanPersistRequest<?> request) {
for (int i = 0; i < chain.length; i++) {
chain[i].postUpdate(request);
}
}
@Override
public boolean preDelete(BeanPersistRequest<?> request) {
for (int i = 0; i < chain.length; i++) {
if (!chain[i].preDelete(request)) {
@@ -132,6 +132,7 @@ public class ChainedBeanPersistController implements BeanPersistController {
return true;
}
@Override
public boolean preInsert(BeanPersistRequest<?> request) {
for (int i = 0; i < chain.length; i++) {
if (!chain[i].preInsert(request)) {
@@ -141,6 +142,7 @@ public class ChainedBeanPersistController implements BeanPersistController {
return true;
}
@Override
public boolean preUpdate(BeanPersistRequest<?> request) {
for (int i = 0; i < chain.length; i++) {
if (!chain[i].preUpdate(request)) {
@@ -0,0 +1,77 @@
package com.avaje.ebeaninternal.server.deploy;
import com.avaje.ebean.event.BeanPostLoad;
import java.util.ArrayList;
import java.util.List;
/**
* Handles multiple BeanPostLoad's for a given entity type.
*/
public class ChainedBeanPostLoad implements BeanPostLoad {
private final List<BeanPostLoad> list;
private final BeanPostLoad[] chain;
/**
* Construct given the list of BeanPersistController's.
*/
public ChainedBeanPostLoad(List<BeanPostLoad> list) {
this.list = list;
this.chain = list.toArray(new BeanPostLoad[list.size()]);
}
/**
* Register a new BeanPersistController and return the resulting chain.
*/
public ChainedBeanPostLoad register(BeanPostLoad c) {
if (list.contains(c)){
return this;
} else {
List<BeanPostLoad> newList = new ArrayList<BeanPostLoad>();
newList.addAll(list);
newList.add(c);
return new ChainedBeanPostLoad(newList);
}
}
/**
* De-register a BeanPersistController and return the resulting chain.
*/
public ChainedBeanPostLoad deregister(BeanPostLoad c) {
if (!list.contains(c)){
return this;
} else {
ArrayList<BeanPostLoad> newList = new ArrayList<BeanPostLoad>();
newList.addAll(list);
newList.remove(c);
return new ChainedBeanPostLoad(newList);
}
}
/**
* Return the size of the chain.
*/
protected int size() {
return chain.length;
}
@Override
public boolean isRegisterFor(Class<?> cls) {
// never called
return false;
}
/**
* Fire postLoad on all registered BeanPostLoad implementations.
*/
@Override
public void postLoad(Object bean) {
for (int i = 0; i < chain.length; i++) {
chain[i].postLoad(bean);
}
}
}
@@ -0,0 +1,42 @@
package com.avaje.ebeaninternal.server.deploy;
import com.avaje.ebean.event.BeanPostLoad;
import com.avaje.ebeaninternal.server.core.BootupClasses;
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* Default implementation for creating BeanControllers.
*/
public class PostLoadManager {
private static final Logger logger = LoggerFactory.getLogger(PostLoadManager.class);
private final List<BeanPostLoad> list;
public PostLoadManager(BootupClasses bootupClasses) {
this.list = bootupClasses.getBeanPostLoaders();
}
public int getRegisterCount() {
return list.size();
}
/**
* Register BeanPostLoad listeners for a given entity type.
*/
public void addPostLoad(DeployBeanDescriptor<?> deployDesc) {
for (int i = 0; i < list.size(); i++) {
BeanPostLoad c = list.get(i);
if (c.isRegisterFor(deployDesc.getBeanType())) {
logger.debug("BeanPostLoad on[" + deployDesc.getFullName() + "] " + c.getClass().getName());
deployDesc.addPostLoad(c);
}
}
}
}
@@ -4,15 +4,35 @@ import com.avaje.ebean.annotation.ConcurrencyMode;
import com.avaje.ebean.config.TableName;
import com.avaje.ebean.config.dbplatform.IdGenerator;
import com.avaje.ebean.config.dbplatform.IdType;
import com.avaje.ebean.event.*;
import com.avaje.ebean.event.BeanFindController;
import com.avaje.ebean.event.BeanPersistController;
import com.avaje.ebean.event.BeanPersistListener;
import com.avaje.ebean.event.BeanPostLoad;
import com.avaje.ebean.event.BeanQueryAdapter;
import com.avaje.ebeaninternal.server.core.CacheOptions;
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
import com.avaje.ebeaninternal.server.deploy.*;
import com.avaje.ebeaninternal.server.deploy.ChainedBeanPersistController;
import com.avaje.ebeaninternal.server.deploy.ChainedBeanPersistListener;
import com.avaje.ebeaninternal.server.deploy.ChainedBeanPostLoad;
import com.avaje.ebeaninternal.server.deploy.ChainedBeanQueryAdapter;
import com.avaje.ebeaninternal.server.deploy.CompoundUniqueContraint;
import com.avaje.ebeaninternal.server.deploy.DRawSqlMeta;
import com.avaje.ebeaninternal.server.deploy.DeployNamedQuery;
import com.avaje.ebeaninternal.server.deploy.DeployNamedUpdate;
import com.avaje.ebeaninternal.server.deploy.InheritInfo;
import javax.persistence.Entity;
import javax.persistence.MappedSuperclass;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Describes Beans including their deployment information.
@@ -101,9 +121,10 @@ public class DeployBeanDescriptor<T> {
*/
private final Class<T> beanType;
private final List<BeanPersistController> persistControllers = new ArrayList<BeanPersistController>(2);
private final List<BeanPersistListener> persistListeners = new ArrayList<BeanPersistListener>(2);
private final List<BeanQueryAdapter> queryAdapters = new ArrayList<BeanQueryAdapter>(2);
private final List<BeanPersistController> persistControllers = new ArrayList<BeanPersistController>();
private final List<BeanPersistListener> persistListeners = new ArrayList<BeanPersistListener>();
private final List<BeanQueryAdapter> queryAdapters = new ArrayList<BeanQueryAdapter>();
private final List<BeanPostLoad> postLoaders = new ArrayList<BeanPostLoad>();
private final CacheOptions cacheOptions = new CacheOptions();
@@ -402,8 +423,18 @@ public class DeployBeanDescriptor<T> {
}
/**
* Set the Controller.
* Return the BeanPostLoad (could be a chain of them, 1 or null).
*/
public BeanPostLoad getPostLoad() {
if (postLoaders.size() == 0) {
return null;
} else if (postLoaders.size() == 1) {
return postLoaders.get(0);
} else {
return new ChainedBeanPostLoad(postLoaders);
}
}
public void addPersistController(BeanPersistController controller) {
persistControllers.add(controller);
}
@@ -416,6 +447,10 @@ public class DeployBeanDescriptor<T> {
queryAdapters.add(queryAdapter);
}
public void addPostLoad(BeanPostLoad postLoad) {
postLoaders.add(postLoad);
}
/**
* Return the base table. Only properties mapped to the base table are by
* default persisted.
@@ -301,7 +301,7 @@ public class SqlTreeNodeBean implements SqlTreeNode {
if (readId && !temporalVersions) {
createListProxies(localDesc, ctx, localBean);
}
localDesc.postLoad(localBean, null);
localDesc.postLoad(localBean);
EntityBeanIntercept ebi = localBean._ebean_getIntercept();
ebi.setPersistenceContext(persistenceContext);