use of org.apache.cayenne.exp.ValueInjector in project cayenne by apache.
the class BaseContext method injectInitialValue.
/**
* If ObjEntity qualifier is set, asks it to inject initial value to an
* object. Also performs all Persistent initialization operations
*/
protected void injectInitialValue(Object obj) {
// must follow this exact order of property initialization per CAY-653,
// i.e. have
// the id and the context in place BEFORE setPersistence is called
Persistent object = (Persistent) obj;
object.setObjectContext(this);
object.setPersistenceState(PersistenceState.NEW);
GraphManager graphManager = getGraphManager();
synchronized (graphManager) {
graphManager.registerNode(object.getObjectId(), object);
graphManager.nodeCreated(object.getObjectId());
}
ObjEntity entity;
try {
entity = getEntityResolver().getObjEntity(object.getClass());
} catch (CayenneRuntimeException ex) {
// ObjEntity cannot be fetched, ignored
entity = null;
}
if (entity != null) {
if (entity.getDeclaredQualifier() instanceof ValueInjector) {
((ValueInjector) entity.getDeclaredQualifier()).injectValue(object);
}
}
// invoke callbacks
getEntityResolver().getCallbackRegistry().performCallbacks(LifecycleEvent.POST_ADD, object);
}
Aggregations