/** Invoked by transformed DSL creation rules */ public <T> void create(String modelPathString, Class<T> type, Closure<?> closure) { SourceLocation sourceLocation = ruleLocationExtractor.transform(closure); ModelPath modelPath = ModelPath.path(modelPathString); ModelRuleDescriptor descriptor = toDescriptor(sourceLocation, modelPath); try { NodeInitializerRegistry nodeInitializerRegistry = modelRegistry.realize( DefaultNodeInitializerRegistry.DEFAULT_REFERENCE.getPath(), DefaultNodeInitializerRegistry.DEFAULT_REFERENCE.getType()); NodeInitializer nodeInitializer = nodeInitializerRegistry.getNodeInitializer(ModelType.of(type)); modelRegistry.create( ModelCreators.of(modelPath, nodeInitializer).descriptor(descriptor).build()); } catch (ModelTypeInitializationException e) { throw new InvalidModelRuleDeclarationException(descriptor, e); } registerAction(modelPath, type, descriptor, ModelActionRole.Initialize, closure); }
/** Invoked by transformed DSL configuration rules */ public void configure(String modelPathString, Closure<?> closure) { SourceLocation sourceLocation = ruleLocationExtractor.transform(closure); ModelPath modelPath = ModelPath.path(modelPathString); ModelRuleDescriptor descriptor = toDescriptor(sourceLocation, modelPath); registerAction(modelPath, Object.class, descriptor, ModelActionRole.Mutate, closure); }