try {
// First initialize basic properties (things that do not depend on anything else)
for (Enumeration descriptorEnum = descriptors.elements();
descriptorEnum.hasMoreElements();) {
try {
ClassDescriptor descriptor = (ClassDescriptor)descriptorEnum.nextElement();
AbstractSession session = getSessionForClass(descriptor.getJavaClass());
if (descriptor.requiresInitialization()) {
descriptor.preInitialize(session);
}
//check if inheritance is involved in aggregate relationship, and let the parent know the child descriptor
if (descriptor.isAggregateDescriptor() && descriptor.isChildDescriptor()) {
descriptor.initializeAggregateInheritancePolicy(session);
}
} catch (RuntimeException exception) {
getIntegrityChecker().handleError(exception);
}
}
// Second basic initialize mappings
for (Enumeration descriptorEnum = descriptors.elements();
descriptorEnum.hasMoreElements();) {
try {
ClassDescriptor descriptor = (ClassDescriptor)descriptorEnum.nextElement();
AbstractSession session = getSessionForClass(descriptor.getJavaClass());
if (descriptor.requiresInitialization()) {
descriptor.initialize(session);
}
} catch (RuntimeException exception) {
getIntegrityChecker().handleError(exception);
}
}
// Third initialize child dependencies
for (Enumeration descriptorEnum = descriptors.elements();
descriptorEnum.hasMoreElements();) {
try {
ClassDescriptor descriptor = (ClassDescriptor)descriptorEnum.nextElement();
AbstractSession session = getSessionForClass(descriptor.getJavaClass());
if (descriptor.requiresInitialization()) {
descriptor.postInitialize(session);
}
} catch (RuntimeException exception) {
getIntegrityChecker().handleError(exception);
}
}