public PolicyResult resolveLocalPolicies(LogicalWire wire) throws PolicyResolutionException { LogicalReference reference = wire.getSource(); // use the leaf service to optimize data paths - e.g. a promoted service may use a different service contract and databinding than the leaf LogicalService service = wire.getTarget().getLeafService(); LogicalComponent source = reference.getParent(); LogicalComponent target = service.getLeafComponent(); LogicalBinding<LocalBindingDefinition> sourceBinding = new LogicalBinding<>(LocalBindingDefinition.INSTANCE, reference); LogicalBinding<LocalBindingDefinition> targetBinding = new LogicalBinding<>(LocalBindingDefinition.INSTANCE, service); return resolvePolicies(reference.getOperations(), sourceBinding, targetBinding, source, target); }
if (target.equals(existingWire.getTarget())) { skip = true; break; LogicalWire wire = new LogicalWire(parentComposite, logicalReference, target, contributionUri); parentComposite.addWire(logicalReference, wire); for (LogicalWire existingWire : existingWires) { if (LogicalState.PROVISIONED == existingWire.getTarget().getParent().getState()) { existingWire.setState(LogicalState.NEW);
LogicalService service = wire.getTarget(); LogicalComponent<?> targetComponent = service.getParent(); if (!reinjection && (wire.getState() == LogicalState.PROVISIONED && targetComponent.getState() != LogicalState.MARKED)) { continue; if (targetComponent.getState() == LogicalState.MARKED || wire.getState() == LogicalState.MARKED) { attach = false; PhysicalWire physicalWire; if (wire.getSourceBinding() != null && wire.getTargetBinding() == null) { physicalWire = wireGenerator.generateReference(wire.getSourceBinding()); } else { physicalWire = wireGenerator.generateWire(wire); detachCommand.setPhysicalWireDefinition(physicalWire); command.add(detachCommand); } else if ((reinjection && targetComponent.getState() == LogicalState.NEW) || wire.getState() == LogicalState.NEW || targetComponent.getState() == LogicalState.NEW) { PhysicalWire physicalWire; if (wire.getSourceBinding() != null && wire.getTargetBinding() == null) { physicalWire = wireGenerator.generateReference(wire.getSourceBinding()); } else { physicalWire = wireGenerator.generateWire(wire); if (wire.getSourceBinding() != null && wire.getTargetBinding() == null) {
private boolean isLocal(LogicalWire wire) { // at this point an SCA binding can only exist for local wires since SCA bindings for remote wires will have been replaced // with concrete bindings return (wire.getSourceBinding() == null || wire.getSourceBinding().getDefinition() instanceof SCABinding) && (wire.getTargetBinding() == null || wire.getTargetBinding().getDefinition() instanceof SCABinding); }
public PolicyResult resolveRemotePolicies(LogicalWire wire) throws PolicyResolutionException { LogicalReference reference = wire.getSource(); LogicalService service = wire.getTarget(); LogicalComponent source = reference.getParent(); LogicalComponent target = service.getLeafComponent(); LogicalBinding<?> serviceBinding = wire.getTargetBinding(); List<LogicalOperation> sourceOperations = reference.getOperations(); return resolvePolicies(sourceOperations, serviceBinding, serviceBinding, source, target); }
private boolean isWireReinjection(LogicalReference logicalReference, boolean incremental) { Multiplicity multiplicity = logicalReference.getDefinition().getMultiplicity(); if (incremental && multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) { for (LogicalWire wire : logicalReference.getWires()) { LogicalComponent<?> targetComponent = wire.getTarget().getLeafComponent(); // check the source and target sides since a target may have been added or removed if (wire.getState() == LogicalState.NEW || wire.getState() == LogicalState.MARKED || targetComponent.getState() == LogicalState.NEW || targetComponent.getState() == LogicalState.MARKED) { return true; } } } return false; }
LogicalReference source = wire.getSource(); LogicalService target = wire.getTarget(); for (BindingProvider provider : providers) { BindingMatchResult result = provider.canBind(wire); throw new BindingSelectionException("Binding provider error. Provider did not set a binding for the service: " + type); wire.setSourceBinding(source.getBindings().get(0)); if (!target.getBindings().isEmpty()) { wire.setTargetBinding(target.getBindings().get(0)); } else { wire.setTargetBinding(target.getLeafService().getBindings().get(0));
public <T> T resolve(Class<T> interfaze) throws ResolverException { LogicalWire wire = createWire(interfaze); try { boolean remote = !wire.getSource().getParent().getZone().equals(wire.getTarget().getParent().getZone()); PhysicalWireDefinition pwd; if (remote) { bindingSelector.selectBinding(wire); pwd = wireGenerator.generateBoundReference(wire.getSourceBinding()); pwd.getSource().setUri(wire.getSource().getParent().getUri()); } else { pwd = wireGenerator.generateWire(wire); } NonManagedPhysicalWireSourceDefinition source = (NonManagedPhysicalWireSourceDefinition) pwd.getSource(); URI uri = ContributionResolver.getContribution(interfaze); pwd.getTarget().setClassLoaderId(uri); source.setClassLoaderId(uri); connector.connect(pwd); return interfaze.cast(source.getProxy()); } catch (GenerationException | ContainerException e) { throw new ResolverException(e); } }
wire.setState(MARKED); if (MARKED == wire.getState()) { continue; if (contributionUri.equals(wire.getTargetContribution())) { wire.setState(MARKED);
for (LogicalWire wire : reference.getWires()) { LogicalService target = wire.getTarget(); newTargets.add(target); for (LogicalService target : newTargets) { QName deployable = composite.getDeployable(); LogicalWire newWire = new LogicalWire(reference.getParent(), reference, target, deployable); newWires.add(newWire);
private <T> LogicalWire createWire(Class<T> interfaze) throws Fabric3Exception { LogicalReference logicalReference = createReference(interfaze); LogicalCompositeComponent domainComponent = lcm.getDomainComposite(); List<LogicalService> services = autowireResolver.resolve(logicalReference, domainComponent); if (services.isEmpty()) { throw new NotFoundException("Service not found for type: " + interfaze.getName()); } LogicalService targetService = services.get(0); return new LogicalWire(domainComponent, logicalReference, targetService, SYNTHETIC_CONTRIBUTION); }
wire.setSourceBinding(referenceBinding); wire.setTargetBinding(serviceBinding); if (serviceBinding != null && referenceBinding != null && !referenceBinding.getDefinition().getType().equals(serviceBinding.getDefinition().getType())) { raiseIncompatibleBindings(reference, service, referenceBindingName, context);
public PolicyResult resolveRemoteCallbackPolicies(LogicalWire wire) throws PolicyResolutionException { LogicalReference reference = wire.getSource(); LogicalComponent target = reference.getParent(); ServiceContract referenceContract = reference.getServiceContract(); ServiceContract referenceCallbackContract = referenceContract.getCallbackContract(); LogicalBinding<?> referenceBinding = reference.getCallbackBindings().get(0); LogicalService callbackService = target.getService(referenceCallbackContract.getInterfaceName()); List<LogicalOperation> operations = reference.getCallbackOperations(); LogicalBinding<LocalBindingDefinition> sourceBinding = new LogicalBinding<>(LocalBindingDefinition.INSTANCE, callbackService); return resolvePolicies(operations, sourceBinding, referenceBinding, null, target); }
private void processReference(LogicalReference reference, QName policySet, boolean incremental) { for (LogicalWire wire : reference.getWires()) { wire.setState(LogicalState.NEW); } for (LogicalBinding<?> binding : reference.getBindings()) { if (incremental && binding.getPolicySets().contains(policySet)) { continue; } binding.setState(LogicalState.NEW); } }
wire.setState(LogicalState.MARKED); if (LogicalState.MARKED == wire.getState()) { continue; if (deployable.equals(wire.getTargetDeployable())) { wire.setState(LogicalState.MARKED);
/** * 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); } } } }
public void instantiateCompositeWires(Composite composite, LogicalCompositeComponent parent, InstantiationContext context) { // instantiate wires held directly in the composite and in included composites for (WireDefinition definition : composite.getWires()) { // resolve the source reference Target referenceTarget = definition.getReferenceTarget(); LogicalReference reference = resolveReference(referenceTarget, parent, context); if (reference == null) { // error resolving, continue processing other targets so all errors are collated continue; } // resolve the target service Target serviceTarget = definition.getServiceTarget(); LogicalService service = resolveService(reference, serviceTarget, parent, context); if (service == null) { // error resolving, continue processing other targets so all errors are collated continue; } // create the wire QName deployable = parent.getDeployable(); LogicalWire wire = new LogicalWire(parent, reference, service, deployable); wire.setReplaces(definition.isReplace()); String referenceBindingName = referenceTarget.getBinding(); String serviceBindingName = serviceTarget.getBinding(); resolveBindings(reference, referenceBindingName, service, wire, serviceBindingName, context); parent.addWire(reference, wire); } }
for (Iterator<LogicalWire> it = wires.getValue().iterator(); it.hasNext(); ) { LogicalWire wire = it.next(); if (MARKED == wire.getState()) { it.remove();
LogicalReference reference = wire.getSource(); LogicalService service = wire.getTarget(); LogicalComponent source = reference.getParent(); LogicalComponent target = service.getLeafComponent(); sourceDefinition.setOrder(order); LogicalBinding<BD> serviceBinding = wire.getTargetBinding(); BindingGenerator<BD> targetGenerator = getGenerator(serviceBinding);