// this is a very critical section :)
synchronized (SchemaService.class) {
final Set<String> dynamicViews = new LinkedHashSet<>();
final NodeExtender nodeExtender = new NodeExtender();
try (final Tx tx = StructrApp.getInstance().tx()) {
SchemaService.ensureBuiltinTypesExist();
// collect node classes
for (final SchemaNode schemaNode : StructrApp.getInstance().nodeQuery(SchemaNode.class).getAsList()) {
nodeExtender.addClass(schemaNode.getClassName(), schemaNode.getSource(errorBuffer));
final String auxSource = schemaNode.getAuxiliarySource();
if (auxSource != null) {
nodeExtender.addClass("_" + schemaNode.getClassName() + "Helper", auxSource);
}
dynamicViews.addAll(schemaNode.getViews());
}
// collect relationship classes
for (final SchemaRelationship schemaRelationship : StructrApp.getInstance().relationshipQuery(SchemaRelationship.class).getAsList()) {
nodeExtender.addClass(schemaRelationship.getClassName(), schemaRelationship.getSource(errorBuffer));
final String auxSource = schemaRelationship.getAuxiliarySource();
if (auxSource != null) {
nodeExtender.addClass("_" + schemaRelationship.getClassName() + "Helper", auxSource);
}
dynamicViews.addAll(schemaRelationship.getViews());
}
// compile all classes at once and register
Map<String, Class> newTypes = nodeExtender.compile(errorBuffer);
for (final Class newType : newTypes.values()) {
config.registerEntityType(newType);
// instantiate classes to execute