private <T extends ComponentSpec> void registerImplementation( ComponentSpecFactory components, List<ModelView<?>> inputs) { ServiceRegistry serviceRegistry = ModelViews.assertType(inputs.get(0), ModelType.of(ServiceRegistry.class)).getInstance(); final Instantiator instantiator = serviceRegistry.get(Instantiator.class); final ProjectIdentifier projectIdentifier = ModelViews.assertType(inputs.get(1), ModelType.of(ProjectIdentifier.class)).getInstance(); final ProjectSourceSet projectSourceSet = ModelViews.assertType(inputs.get(2), ModelType.of(ProjectSourceSet.class)).getInstance(); components.registerFactory( Cast.<ModelType<ComponentSpec>>uncheckedCast(publicType), descriptor, new BiFunction<ComponentSpec, String, MutableModelNode>() { @Override public ComponentSpec apply(String name, MutableModelNode modelNode) { ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(projectIdentifier.getPath(), name); return BaseComponentSpec.create( implementationType.getConcreteClass(), id, modelNode, projectSourceSet, instantiator); } }); components.registerImplementation( Cast.<ModelType<T>>uncheckedCast(publicType), descriptor, Cast.<ModelType<? extends T>>uncheckedCast(implementationType)); if (COMPONENT_SPEC_INTERNAL_MODEL_TYPE.isAssignableFrom(implementationType)) { components.registerInternalView(publicType, descriptor, COMPONENT_SPEC_INTERNAL_MODEL_TYPE); } }
public void execute( final MutableModelNode modelNode, final T binary, List<ModelView<?>> inputs) { NamedEntityInstantiator<Task> taskFactory = Cast.uncheckedCast(ModelViews.getInstance(inputs.get(0), ITaskFactory.class)); ModelMap<Task> cast = DomainObjectCollectionBackedModelMap.wrap( Task.class, binary.getTasks(), taskFactory, new Task.Namer(), new Action<Task>() { @Override public void execute(Task task) { binary.getTasks().add(task); binary.builtBy(task); } }); List<ModelView<?>> inputsWithBinary = new ArrayList<ModelView<?>>(inputs.size()); inputsWithBinary.addAll(inputs.subList(1, inputs.size())); inputsWithBinary.add( InstanceModelView.of(getSubject().getPath(), getSubject().getType(), binary)); invoke(inputsWithBinary, cast, binary, binary); }
@Override public void execute(MutableModelNode modelNode, List<ModelView<?>> inputs) { NodeInitializerRegistry nodeInitializerRegistry = ModelViews.assertType(inputs.get(0), NodeInitializerRegistry.class).getInstance(); ManagedChildNodeCreatorStrategy<E> childStrategy = new ManagedChildNodeCreatorStrategy<E>(nodeInitializerRegistry); modelNode.setPrivateData(ChildNodeInitializerStrategy.class, childStrategy); }