public void instantiateReferenceWires(LogicalComponent<?> component, InstantiationContext context) { for (LogicalReference logicalReference : component.getReferences()) { instantiateReferenceWires(logicalReference, context); } }
public void instantiateReferenceWires(LogicalComponent<?> component, InstantiationContext context) { for (LogicalReference logicalReference : component.getReferences()) { instantiateReferenceWires(logicalReference, context); } }
public void instantiateReferenceWires(LogicalComponent<?> component, InstantiationContext context) { for (LogicalReference logicalReference : component.getReferences()) { instantiateReferenceWires(logicalReference, context); } }
private void normalizeReferenceAndWirePromotions(LogicalComponent<?> component, InstantiationContext context) { for (LogicalReference reference : component.getReferences()) { LinkedList<LogicalReference> references = new LinkedList<LogicalReference>(); // add the leaf (promoted) reference as the last element references.add(reference); getPromotionHierarchy(reference, references); if (references.isEmpty()) { continue; } processReferencePromotions(references, context); processWirePromotions(references, context); } }
private void processComponent(LogicalComponent<?> component, QName policySet, boolean incremental) { // do not mark the component as new, just the wires since the implementation does not need to be reprovisioned for (LogicalReference reference : component.getReferences()) { processReference(reference, policySet, incremental); } for (LogicalService service : component.getServices()) { processService(service, policySet, incremental); } }
private void processDetachComponent(LogicalComponent<?> component, QName policySet, boolean incremental) { // do not mark the component as new, just the wires since the implementation does not need to be reprovisioned for (LogicalReference reference : component.getReferences()) { processDetachReference(reference, policySet, incremental); } for (LogicalService service : component.getServices()) { processDetachService(service, policySet, incremental); } }
public Optional<ConnectionCommand> generate(LogicalComponent<?> component) { if (component instanceof LogicalCompositeComponent) { return Optional.empty(); } ConnectionCommand command = new ConnectionCommand(component.getUri()); for (LogicalReference reference : component.getReferences()) { if (!reference.getWires().isEmpty()) { generateWires(reference, command); } else { generateBindings(reference, component, command); } } if (command.getAttachCommands().isEmpty() && command.getDetachCommands().isEmpty()) { return Optional.empty(); } return Optional.of(command); }
public Optional<ConnectionCommand> generate(LogicalComponent<?> component) { if (component instanceof LogicalCompositeComponent) { return Optional.empty(); } ConnectionCommand command = new ConnectionCommand(component.getUri()); for (LogicalReference reference : component.getReferences()) { if (!reference.getWires().isEmpty()) { generateWires(reference, command); } else { generateBindings(reference, component, command); } } if (command.getAttachCommands().isEmpty() && command.getDetachCommands().isEmpty()) { return Optional.empty(); } return Optional.of(command); }
public ConnectionCommand generate(LogicalComponent<?> component, boolean incremental) throws GenerationException { if (component instanceof LogicalCompositeComponent) { return null; } ConnectionCommand command = new ConnectionCommand(component.getUri()); for (LogicalReference reference : component.getReferences()) { if (!reference.getWires().isEmpty()) { generateWires(reference, command, incremental); } else { generateBindings(reference, component, incremental, command); } } if (command.getAttachCommands().isEmpty() && command.getDetachCommands().isEmpty()) { return null; } return command; }
/** * Selects and configures bindings for wires sourced from the given component. * * @param component the component * @throws BindingSelectionException if an error occurs selecting a binding */ private void selectBindings(LogicalComponent<?> component) throws BindingSelectionException { for (LogicalReference reference : component.getReferences()) { for (LogicalWire wire : reference.getWires()) { LogicalService targetService = wire.getTarget(); if (targetService != null) { LogicalComponent<?> targetComponent = targetService.getParent(); if ((LOCAL_ZONE.equals(component.getZone()) && LOCAL_ZONE.equals(targetComponent.getZone()))) { // components are local, no need for a binding continue; } else if (!LOCAL_ZONE.equals(component.getZone()) && component.getZone().equals(targetComponent.getZone())) { // components are local, no need for a binding continue; } selectBinding(wire); } } } }
URI referenceUri = reference.getUri(); LogicalComponent<CompositeImplementation> parent = reference.getParent().getParent(); for (LogicalReference promotion : parent.getReferences()) { List<URI> promotedUris = promotion.getPromotedUris(); for (URI promotedUri : promotedUris) {
service.getCallbackBindings().stream().filter(binding -> NEW == binding.getState()).forEach(binding -> binding.setState(PROVISIONED)); for (LogicalReference reference : component.getReferences()) { reference.getBindings().stream().filter(binding -> NEW == binding.getState()).forEach(binding -> binding.setState(PROVISIONED)); reference.getCallbackBindings().stream().filter(binding -> NEW == binding.getState()).forEach(binding -> binding.setState(PROVISIONED));
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); } } }
private void containsIntents(List<String> intentArgs, LogicalComponent<?> component, Set<LogicalScaArtifact> artifacts) { if (containsIntents(intentArgs, component.getDefinition().getImplementation().getIntents())) { artifacts.add(component); } if (containsIntents(intentArgs, component.getDefinition().getIntents())) { artifacts.add(component); } if (containsIntents(intentArgs, component.getIntents())) { artifacts.add(component); } for (LogicalService service : component.getServices()) { if (containsIntents(intentArgs, service.getIntents())) { artifacts.add(service); } } for (LogicalReference reference : component.getReferences()) { if (containsIntents(intentArgs, reference.getIntents())) { artifacts.add(reference); } } if (component instanceof LogicalCompositeComponent) { LogicalCompositeComponent composite = (LogicalCompositeComponent) component; for (LogicalComponent<?> childComponent : composite.getComponents()) { containsIntents(intentArgs, childComponent, artifacts); } } }
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; }
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; }