private void instantiateReferenceWires(LogicalReference reference, InstantiationContext context) { LogicalCompositeComponent parent = reference.getParent().getParent(); Reference componentReference = reference.getComponentReference(); Reference<ComponentType> definition = reference.getDefinition(); if (componentReference == null && definition.getTargets().isEmpty()) { // the reference is not configured on the component definition in the composite or in the component type so there are no wires return; } List<Target> serviceTargets = componentReference != null ? componentReference.getTargets() : definition.getTargets(); if (serviceTargets.isEmpty()) { serviceTargets = definition.getTargets(); } if (serviceTargets.isEmpty()) { // no targets are specified return; } List<LogicalWire> wires = new ArrayList<>(); // resolve the reference targets and create logical wires for (Target target : serviceTargets) { LogicalWire wire = createWire(target, reference, null, parent, context); if (wire == null) { continue; } wires.add(wire); } if (!wires.isEmpty()) { parent.addWires(reference, wires); } reference.setResolved(true); }
private void instantiateReferenceWires(LogicalReference reference, InstantiationContext context) { LogicalCompositeComponent parent = reference.getParent().getParent(); Reference componentReference = reference.getComponentReference(); Reference<ComponentType> definition = reference.getDefinition(); if (componentReference == null && definition.getTargets().isEmpty()) { // the reference is not configured on the component definition in the composite or in the component type so there are no wires return; } List<Target> serviceTargets = componentReference != null ? componentReference.getTargets() : definition.getTargets(); if (serviceTargets.isEmpty()) { serviceTargets = definition.getTargets(); } if (serviceTargets.isEmpty()) { // no targets are specified return; } List<LogicalWire> wires = new ArrayList<>(); // resolve the reference targets and create logical wires for (Target target : serviceTargets) { LogicalWire wire = createWire(target, reference, null, parent, context); if (wire == null) { continue; } wires.add(wire); } if (!wires.isEmpty()) { parent.addWires(reference, wires); } reference.setResolved(true); }
promotedReference.setResolved(true); } else { LogicalReference promotedReference = promotedComponent.getReference(promotedReferenceName); promotedReference.setResolved(true);
for (LogicalWire wire : existingWires) { if (wire.isReplaces()) { reference.setResolved(true); return; parent.addWires(reference, wires); reference.setResolved(true);
private void resolveReferences(LogicalComponent<?> component, InstantiationContext context) { for (LogicalReference reference : component.getReferences()) { Multiplicity multiplicityValue = reference.getDefinition().getMultiplicity(); boolean refMultiplicity = multiplicityValue.equals(Multiplicity.ZERO_N) || multiplicityValue.equals(Multiplicity.ONE_N); if (refMultiplicity || !reference.isResolved()) { // Only resolve references that have not been resolved or ones that are multiplicities since the latter may be reinjected. // Explicitly set the reference to unresolved, since if it was a multiplicity it may have been previously resolved. reference.setResolved(false); resolve(reference, context); } } }
context.addError(error); } else if (targeted) { logicalReference.setResolved(true);
context.addError(error); } else if (targeted) { logicalReference.setResolved(true);
private void resolveReferences(LogicalComponent<?> component, InstantiationContext context) { LogicalCompositeComponent parent = component.getParent(); for (LogicalReference reference : component.getReferences()) { if (reference.isBound()) { // reference is targeted using binding.sca or is explicitly bound so it should not be autowired continue; } Multiplicity multiplicityValue = reference.getDefinition().getMultiplicity(); boolean refMultiplicity = multiplicityValue.equals(Multiplicity.ZERO_N) || multiplicityValue.equals(Multiplicity.ONE_N); if (refMultiplicity || !reference.isResolved()) { // Only resolve references that have not been resolved or ones that are multiplicities since the latter may be reinjected. // Explicitly set the reference to unresolved, since if it was a multiplicity it may have been previously resolved. reference.setResolved(false); resolveReference(reference, parent, context); } } }
private void resolveReferences(LogicalComponent<?> component, InstantiationContext context) { LogicalCompositeComponent parent = component.getParent(); for (LogicalReference reference : component.getReferences()) { if (reference.isBound()) { // reference is targeted using binding.sca or is explicitly bound so it should not be autowired continue; } Multiplicity multiplicityValue = reference.getDefinition().getMultiplicity(); boolean refMultiplicity = multiplicityValue.equals(Multiplicity.ZERO_N) || multiplicityValue.equals(Multiplicity.ONE_N); if (refMultiplicity || !reference.isResolved()) { // Only resolve references that have not been resolved or ones that are multiplicities since the latter may be reinjected. // Explicitly set the reference to unresolved, since if it was a multiplicity it may have been previously resolved. reference.setResolved(false); resolveReference(reference, parent, context); } } }
private void resolveReferences(LogicalComponent<?> component, InstantiationContext context) { LogicalCompositeComponent parent = component.getParent(); for (LogicalReference reference : component.getReferences()) { boolean scaTarget = isScaTarget(reference); if (scaTarget || reference.isConcreteBound()) { // reference is targeted using binding.sca or is explicitly bound so it should not be autowired continue; } Multiplicity multiplicityValue = reference.getDefinition().getMultiplicity(); boolean refMultiplicity = multiplicityValue.equals(Multiplicity.ZERO_N) || multiplicityValue.equals(Multiplicity.ONE_N); if (refMultiplicity || !reference.isResolved()) { // Only resolve references that have not been resolved or ones that are multiplicities since the latter may be reinjected. // Explicitly set the reference to unresolved, since if it was a multiplicity it may have been previously resolved. reference.setResolved(false); resolve(reference, parent, context); } } }
private <S, I extends S> LogicalComponent<?> createLogicalComponent(String name, Class<S> type, I instance, boolean introspect) throws InvalidServiceContractException, AssemblyException { LogicalCompositeComponent domain = lcm.getDomainComposite(); Component<Implementation<?>> definition = createDefinition(name, type, instance, introspect); InstantiationContext context = new InstantiationContext(); LogicalComponent<?> logical = instantiator.instantiate(definition, domain, context); if (context.hasErrors()) { throw new AssemblyException(context.getErrors()); } // mark singleton components as provisioned since instances are not created logical.setState(LogicalState.PROVISIONED); // all references are initially resolved since they are manually injected for (LogicalReference reference : logical.getReferences()) { reference.setResolved(true); for (LogicalWire wire : reference.getWires()) { wire.setState(LogicalState.PROVISIONED); } } return logical; }
private <S, I extends S> LogicalComponent<?> createLogicalComponent(String name, Class<S> type, I instance, boolean introspect) throws InvalidServiceContractException, AssemblyException { LogicalCompositeComponent domain = lcm.getDomainComposite(); Component<Implementation<?>> definition = createDefinition(name, type, instance, introspect); InstantiationContext context = new InstantiationContext(); LogicalComponent<?> logical = instantiator.instantiate(definition, domain, context); if (context.hasErrors()) { throw new AssemblyException(context.getErrors()); } // mark singleton components as provisioned since instances are not created logical.setState(LogicalState.PROVISIONED); // all references are initially resolved since they are manually injected for (LogicalReference reference : logical.getReferences()) { reference.setResolved(true); for (LogicalWire wire : reference.getWires()) { wire.setState(LogicalState.PROVISIONED); } } return logical; }
context.addError(error); } else if (targeted) { logicalReference.setResolved(true);
private <S, I extends S> LogicalComponent<?> createLogicalComponent(String name, Class<S> type, I instance, boolean introspect) throws InvalidServiceContractException, AssemblyException { LogicalCompositeComponent domain = lcm.getRootComponent(); ComponentDefinition<Implementation<?>> definition = createDefinition(name, type, instance, introspect); InstantiationContext context = new InstantiationContext(); LogicalComponent<?> logical = instantiator.instantiate(definition, domain, context); logical.setAutowire(domain.getAutowire()); if (context.hasErrors()) { throw new AssemblyException(context.getErrors()); } // mark singleton components as provisioned since instances are not created logical.setState(LogicalState.PROVISIONED); // all references are initially resolved since they are manually injected for (LogicalReference reference : logical.getReferences()) { reference.setResolved(true); for (LogicalWire wire : reference.getWires()) { wire.setState(LogicalState.PROVISIONED); } } return logical; }