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); }
for (LogicalWire wire : reference.getWires()) { LogicalService target = wire.getTarget(); newTargets.add(target);
/** * 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 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); }
List<BindingMatchResult> results = new ArrayList<BindingMatchResult>(); LogicalReference source = wire.getSource(); LogicalService target = wire.getTarget(); for (BindingProvider provider : providers) { BindingMatchResult result = provider.canBind(wire);
private boolean isWireReinjection(LogicalReference logicalReference) { Multiplicity multiplicity = logicalReference.getDefinition().getMultiplicity(); if (multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) { for (LogicalWire wire : logicalReference.getWires()) { LogicalComponent<?> targetComponent = wire.getTarget().getParent(); // 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; }
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; }
private boolean isWireReinjection(LogicalReference logicalReference) { Multiplicity multiplicity = logicalReference.getDefinition().getMultiplicity(); if (multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) { for (LogicalWire wire : logicalReference.getWires()) { LogicalComponent<?> targetComponent = wire.getTarget().getParent(); // 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; }
public PolicyResult resolveLocalCallbackPolicies(LogicalWire wire) throws PolicyResolutionException { LogicalReference reference = wire.getSource(); LogicalService service = wire.getTarget(); LogicalComponent<?> targetComponent = reference.getParent(); ServiceContract referenceCallbackContract = reference.getServiceContract().getCallbackContract(); LogicalService callbackService = targetComponent.getService(referenceCallbackContract.getInterfaceName()); LogicalBinding<LocalBindingDefinition> sourceBinding = new LogicalBinding<>(LocalBindingDefinition.INSTANCE, callbackService); LogicalBinding<LocalBindingDefinition> targetBinding = new LogicalBinding<>(LocalBindingDefinition.INSTANCE, reference); LogicalComponent sourceComponent = service.getLeafComponent(); return resolvePolicies(service.getCallbackOperations(), sourceBinding, targetBinding, sourceComponent, targetComponent); }
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); } }
private PhysicalWireDefinition generateLocalWireCallback(LogicalWire wire) throws GenerationException { LogicalReference reference = wire.getSource(); LogicalService service = wire.getTarget(); LogicalComponent<?> targetComponent = reference.getParent(); ServiceContract referenceCallbackContract = reference.getServiceContract().getCallbackContract();
public void bind(LogicalWire wire) throws BindingSelectionException { LogicalReference source = wire.getSource().getLeafReference(); LogicalService target = wire.getTarget().getLeafService(); QName deployable = source.getParent().getDeployable();
public void bind(LogicalWire wire) throws BindingSelectionException { LogicalReference source = wire.getSource().getLeafReference(); LogicalService target = wire.getTarget().getLeafService(); QName deployable = source.getParent().getDeployable();
private PhysicalWire generateLocalWireCallback(LogicalWire wire) { LogicalReference reference = wire.getSource(); LogicalService service = wire.getTarget(); LogicalComponent<?> targetComponent = reference.getParent(); ServiceContract referenceCallbackContract = reference.getServiceContract().getCallbackContract(); LogicalService callbackService = targetComponent.getService(referenceCallbackContract.getInterfaceName()); LogicalComponent sourceComponent = service.getParent(); List<LogicalOperation> targetOperations = callbackService.getOperations(); List<LogicalOperation> sourceOperations = service.getCallbackOperations(); Set<PhysicalOperation> callbackOperations = operationGenerator.generateOperations(targetOperations, sourceOperations, false); // generate the metadata used to attach the physical callback wire to the source component (the component providing the forward service) ComponentGenerator sourceGenerator = getGenerator(sourceComponent); PhysicalWireSource source = sourceGenerator.generateCallbackSource(service); URI sourceUri = sourceComponent.getDefinition().getContributionUri(); source.setClassLoader(classLoaderRegistry.getClassLoader(sourceUri)); // generate the metadata used to attach the physical callback wire to the target component (the client of the forward service) ComponentGenerator targetGenerator = getGenerator(targetComponent); PhysicalWireTarget target = targetGenerator.generateTarget(callbackService); URI targetUri = targetComponent.getDefinition().getContributionUri(); target.setClassLoader(classLoaderRegistry.getClassLoader(targetUri)); target.setCallback(true); PhysicalWire physicalWire = new PhysicalWire(source, target, callbackOperations); physicalWire.setOptimizable(false); return physicalWire; }
private PhysicalWire generateLocalWireCallback(LogicalWire wire) { LogicalReference reference = wire.getSource(); LogicalService service = wire.getTarget(); LogicalComponent<?> targetComponent = reference.getParent(); ServiceContract referenceCallbackContract = reference.getServiceContract().getCallbackContract(); LogicalService callbackService = targetComponent.getService(referenceCallbackContract.getInterfaceName()); LogicalComponent sourceComponent = service.getParent(); List<LogicalOperation> targetOperations = callbackService.getOperations(); List<LogicalOperation> sourceOperations = service.getCallbackOperations(); Set<PhysicalOperation> callbackOperations = operationGenerator.generateOperations(targetOperations, sourceOperations, false); // generate the metadata used to attach the physical callback wire to the source component (the component providing the forward service) ComponentGenerator sourceGenerator = getGenerator(sourceComponent); PhysicalWireSource source = sourceGenerator.generateCallbackSource(service); URI sourceUri = sourceComponent.getDefinition().getContributionUri(); source.setClassLoader(classLoaderRegistry.getClassLoader(sourceUri)); // generate the metadata used to attach the physical callback wire to the target component (the client of the forward service) ComponentGenerator targetGenerator = getGenerator(targetComponent); PhysicalWireTarget target = targetGenerator.generateTarget(callbackService); URI targetUri = targetComponent.getDefinition().getContributionUri(); target.setClassLoader(classLoaderRegistry.getClassLoader(targetUri)); target.setCallback(true); PhysicalWire physicalWire = new PhysicalWire(source, target, callbackOperations); physicalWire.setOptimizable(false); return physicalWire; }
LogicalService service = wire.getTarget(); LogicalComponent<?> targetComponent = service.getLeafComponent(); if (!reinjection && (wire.getState() == LogicalState.PROVISIONED && targetComponent.getState() != LogicalState.MARKED && incremental)) {
LogicalReference reference = wire.getSource(); LogicalService service = wire.getTarget(); LogicalComponent sourceComponent = reference.getParent(); LogicalComponent targetComponent = service.getParent();
LogicalReference reference = wire.getSource(); LogicalService service = wire.getTarget(); LogicalComponent sourceComponent = reference.getParent(); LogicalComponent targetComponent = service.getParent();