public static DomainMetaClass readDomainMetaClass(Class<? extends DomainObject> domainClass) { return DomainFenixFrameworkRoot.getInstance().getDomainMetaClass(domainClass); }
/** * Creates a {@link DomainRoot} for the {@link DomainFenixFrameworkRoot} and then initializes the * {@link DomainFenixFrameworkRoot}. */ @Atomic public static void bootstrap() { if (getInstance() == null) { DomainFenixFrameworkRoot fenixFrameworkRoot = new DomainFenixFrameworkRoot(); FenixFramework.getDomainRoot().setDomainFenixFrameworkRoot(fenixFrameworkRoot); } getInstance().initialize(FenixFramework.getDomainModel()); }
/** * Entry point of the initialization of the {@link DomainFenixFrameworkRoot}, which initializes the {@link DomainMetaClass}es * and the {@link DomainConsistencyPredicate}s. If * the framework was configured not to create meta objects, it deletes all {@link DomainMetaClass}es and * {@link DomainConsistencyPredicate}s * instead. */ public void initialize(DomainModel domainModel) { checkFrameworkNotInitialized(); if (ConsistencyPredicatesConfig.canCreateDomainMetaObjects()) { logger.trace("Starting initialization of the DomainMetaClasses"); initializeDomainMetaClasses(domainModel); logger.trace("Finished the initialization of the DomainMetaClasses"); logger.trace("Starting initialization of the DomainConsistencyPredicates"); initializeDomainConsistencyPredicates(); logger.trace("Finished the initialization of the DomainConsistencyPredicates"); checkAllMethodsOverridingPredicates(); } else { deleteAllMetaObjectsAndClasses(); } }
/** * Deletes all the {@link DomainMetaClass}es and {@link DomainMetaObject}s, * and any associated {@link DomainConsistencyPredicate}s and {@link DomainDependenceRecord}s. This method should be * invoked when the {@link FenixFramework} is configured not to create meta objects. * * @see JvstmOJBConfig#canCreateMetaObjects */ private void deleteAllMetaObjectsAndClasses() { if (!getDomainMetaClassSet().isEmpty()) { logger.info("Deleting all DomainMetaObjects, DomainMetaClasses, DomainConsistencyPredicates and DomainDependenceRecords"); for (DomainMetaClass metaClass : getDomainMetaClassSet()) { // Commits the current, and starts a new write transaction. // This is necessary to split the load of the mass deletion of objects among several transactions. // Each transaction fully processes one DomainMetaClass. metaClass.delete(); checkpointTransaction(); } } }
public DomainMetaClass(Class<? extends DomainObject> domainClass) { super(); checkFrameworkNotInitialized(); setDomainClass(domainClass); DomainFenixFrameworkRoot.getInstance().addDomainMetaClass(this); setExistingDomainMetaObjects(new DomainBPlusTreeJVSTM<DomainMetaObject>()); setInitialized(false); logger.info("Creating new a DomainMetaClass: " + domainClass); }
/** * Creates a {@link DomainMetaClass} for each new class. For each new {@link DomainMetaClass}, initializes its * meta-superclass and creates a {@link DomainMetaObject} for each existing object of the new {@link DomainMetaClass}. * * @param newClassesToAddTopDown * the <code>Collection</code> of Classes for which to create {@link DomainMetaClass}es, in top-down * order */ private void createNewMetaClasses(Collection<Class<? extends DomainObject>> newClassesToAddTopDown) { for (Class<? extends DomainObject> domainClass : newClassesToAddTopDown) { DomainMetaClass newDomainMetaClass = new DomainMetaClass(domainClass); if (hasSuperclassInDML(newDomainMetaClass)) { newDomainMetaClass.initDomainMetaSuperclass(getDomainMetaSuperclassFromDML(newDomainMetaClass)); } newDomainMetaClass.initExistingDomainObjects(); newDomainMetaClass.executeInheritedPredicates(); // Because the initExistingDomainObjects method is split among several transactions, // the creation of the DomainMetaClass and its full initialization may not run atomically. // In case of a system failure during the execution of the initExistingDomainObjects() method, // the DomainMetaClass was already created, but not yet fully initialized. // The init is only considered completed when finalized is set to true. newDomainMetaClass.setInitialized(true); checkpointTransaction(); } }
/** * Deletes the old {@link DomainConsistencyPredicate}s that no longer exist * in this metaClass. * * @param metaClass * the {@link DomainMetaClass} of the domain class that used to * declare the predicates to process. * * @param oldPredicatesToProcess * the <code>Set</code> of {@link DomainConsistencyPredicate}s, * that are no longer being declared inside the domain class of * the given metaClass. */ private void deleteOldPredicates(Set<DomainConsistencyPredicate> oldPredicatesToRemove, DomainMetaClass metaClass) { for (DomainConsistencyPredicate domainConsistencyPredicate : oldPredicatesToRemove) { // Commits the current, and starts a new write transaction. // This is necessary to split the load of the mass deletion of DomainDependenceRecords among several transactions. // Each transaction fully processes one DomainConsistencyPredicate. domainConsistencyPredicate.delete(); checkpointTransaction(); } }
/** * Adds a {@link DomainMetaClass} to the domain relation of existing meta classes. */ @Override public void addDomainMetaClass(DomainMetaClass metaClass) { checkFrameworkNotInitialized(); existingDomainMetaClasses.put(metaClass.getDomainClass(), metaClass); // The metaClass for the base class is the same as the regular domain class existingDomainMetaClasses.put((Class<? extends DomainObject>) metaClass.getDomainClass().getSuperclass(), metaClass); super.addDomainMetaClass(metaClass); }
public DomainFenixFrameworkRoot() { super(); checkIfIsSingleton(); }
/** * Processes the new consistency predicates that did not exist before in * this metaClass, and invokes the creation and execution of new {@link DomainConsistencyPredicate}s. * * @param metaClass * the {@link DomainMetaClass} of the domain class that declares * the predicates to process. * * @param newPredicatesToProcess * the <code>Set</code> of <code>Methods</code> annotated with {@link ConsistencyPredicate}, declared * inside the domain class * of the given metaClass. */ private void processNewPredicates(Set<Method> newPredicatesToProcess, DomainMetaClass metaClass) { createAndExecuteNewPredicates(newPredicatesToProcess, metaClass); }
@Override public void run() { backEnd.setNewInstance(RepositoryBootstrap.updateDataRepositoryStructureIfNeeded(JvstmOJBConfig.this, getConnection())); ServerId.ensureServerId(); DomainClassInfo.initializeClassInfos(); DomainClassInfo.ensureDomainRoot(); TransactionSupport.setupJVSTM(); DomainFenixFrameworkRoot.bootstrap(); } });
/** * Finishes the initialization of any {@link DomainConsistencyPredicate} that was not yet finalized.<br> * * @param existingPredicatesToProcess * the <code>Collection</code> of {@link DomainConsistencyPredicate}s to be finalized * @param metaClass * the {@link DomainMetaClass} that declares the {@link DomainConsistencyPredicate}s to be finalized */ private void finishInitializingConsistencyPredicates(Collection<DomainConsistencyPredicate> existingPredicatesToProcess, DomainMetaClass metaClass) { for (DomainConsistencyPredicate consistencyPredicate : existingPredicatesToProcess) { if (consistencyPredicate.isInitialized()) { continue; } logger.info("Resuming the initialization of the consistency predicate: " + consistencyPredicate.getPredicate().getName()); consistencyPredicate.executeConsistencyPredicateForMetaClassAndSubclasses(metaClass); // Because the executeConsistencyPredicateForMetaClassAndSubclasses method is split among several transactions, // the creation of the DomainConsistencyPredicate and its full initialization may not run atomically. // In case of a system failure during the execution of the executeConsistencyPredicateForMetaClassAndSubclasses method, // the DomainConsistencyPredicate was already created, but not yet fully initialized. // The init is only considered completed when finalized is set to true. consistencyPredicate.setInitialized(true); checkpointTransaction(); } }
/** * Removes a {@link DomainMetaClass} from the domain relation of existing * meta classes. */ @Override public void removeDomainMetaClass(DomainMetaClass metaClass) { checkFrameworkNotInitialized(); Class<? extends DomainObject> domainClass = metaClass.getDomainClass(); if (domainClass != null) { existingDomainMetaClasses.remove(metaClass.getDomainClass()); existingDomainMetaClasses.remove(metaClass.getDomainClass().getSuperclass()); } super.removeDomainMetaClass(metaClass); }
private DomainMetaClass getDomainMetaClass() { return DomainFenixFrameworkRoot.getInstance().getDomainMetaClass(this.getClass()); }
/** * Finishes the initialization of any {@link DomainMetaClass} that was not * yet finalized.<br> * * @param existingMetaClassesToFinalize * the <code>Collection</code> of {@link DomainMetaClass}es to be * finalized */ private void finishInitializingMetaClasses(Collection<DomainMetaClass> existingMetaClassesToFinalize) { for (DomainMetaClass metaClass : existingMetaClassesToFinalize) { if (metaClass.isInitialized()) { continue; } logger.info("Resuming the initialization of the DomainMetaClass: " + metaClass.getDomainClass().getSimpleName()); metaClass.initExistingDomainObjects(); metaClass.executeInheritedPredicates(); // Because the initExistingDomainObjects method is split among several transactions, // the creation of the DomainMetaClass and its full initialization may not run atomically. // In case of a system failure during the execution of the initExistingDomainObjects() method, // the DomainMetaClass was already created, but not yet fully initialized. // The init is only considered completed when finalized is set to true. metaClass.setInitialized(true); checkpointTransaction(); } }
DomainFenixFrameworkRoot.checkpointTransaction();
DomainFenixFrameworkRoot.checkpointTransaction(); DomainFenixFrameworkRoot.checkpointTransaction();
DomainFenixFrameworkRoot.checkpointTransaction();