public PhysicalWireSourceDefinition generateSource(LogicalReference reference, EffectivePolicy policy) throws GenerationException { String interfaze = reference.getServiceContract().getQualifiedInterfaceName(); return new NonManagedPhysicalWireSourceDefinition(interfaze); }
public PhysicalWireSource generateSource(LogicalReference reference) { Class<?> interfaze = reference.getServiceContract().getInterfaceClass(); return new NonManagedWireSource(reference.getUri(), interfaze); }
public PhysicalWireSource generateSource(LogicalReference reference) { Class<?> interfaze = reference.getServiceContract().getInterfaceClass(); return new NonManagedWireSource(reference.getUri(), interfaze); }
public PhysicalWireSource generateSource(LogicalReference reference) throws Fabric3Exception { ServiceContract contract = reference.getServiceContract(); if (!(contract instanceof JavaServiceContract)) { // Spring reference contracts are always defined by Java interfaces throw new Fabric3Exception("Unexpected interface type for " + reference.getUri() + ": " + contract.getClass().getName()); } String interfaze = contract.getQualifiedInterfaceName(); URI uri = reference.getParent().getUri(); String referenceName = reference.getDefinition().getName(); return new SpringWireSource(referenceName, interfaze, uri); }
private void generateBindings(LogicalReference reference, LogicalComponent<?> component, ConnectionCommand command) { boolean reinjection = isBoundReinjection(reference); for (LogicalBinding<?> logicalBinding : reference.getBindings()) { generateBinding(component, logicalBinding, command, reinjection, false); } if (reference.getServiceContract().getCallbackContract() != null) { boolean bindings = reference.isBound(); if (bindings) { List<LogicalBinding<?>> callbackBindings = reference.getCallbackBindings(); if (callbackBindings.isEmpty()) { // generate callback bindings as some transports do not require an explicit callback binding configuration on the reference generateCallbackBindings(reference); } if (callbackBindings.size() != 1) { // if the reference is explicitly bound, it must have one callback binding String uri = reference.getUri().toString(); throw new UnsupportedOperationException("The runtime requires exactly one callback binding to be specified on reference: " + uri); } LogicalBinding<?> callbackBinding = callbackBindings.get(0); generateBinding(component, callbackBinding, command, reinjection, true); } } }
private void generateBindings(LogicalReference reference, LogicalComponent<?> component, ConnectionCommand command) { boolean reinjection = isBoundReinjection(reference); for (LogicalBinding<?> logicalBinding : reference.getBindings()) { generateBinding(component, logicalBinding, command, reinjection, false); } if (reference.getServiceContract().getCallbackContract() != null) { boolean bindings = reference.isBound(); if (bindings) { List<LogicalBinding<?>> callbackBindings = reference.getCallbackBindings(); if (callbackBindings.isEmpty()) { // generate callback bindings as some transports do not require an explicit callback binding configuration on the reference generateCallbackBindings(reference); } if (callbackBindings.size() != 1) { // if the reference is explicitly bound, it must have one callback binding String uri = reference.getUri().toString(); throw new UnsupportedOperationException("The runtime requires exactly one callback binding to be specified on reference: " + uri); } LogicalBinding<?> callbackBinding = callbackBindings.get(0); generateBinding(component, callbackBinding, command, reinjection, true); } } }
public PhysicalWireSource generateSource(LogicalReference reference) throws Fabric3Exception { ServiceContract contract = reference.getServiceContract(); if (!(contract instanceof JavaServiceContract)) { // Spring reference contracts are always defined by Java interfaces throw new Fabric3Exception("Unexpected interface type for " + reference.getUri() + ": " + contract.getClass().getName()); } String interfaze = contract.getQualifiedInterfaceName(); URI uri = reference.getParent().getUri(); String referenceName = reference.getDefinition().getName(); return new SpringWireSource(referenceName, interfaze, uri); }
public PhysicalSourceDefinition generateSource(LogicalReference reference, EffectivePolicy policy) throws GenerationException { ServiceContract contract = reference.getLeafReference().getServiceContract(); if (!(contract instanceof JavaServiceContract)) { // Spring reference contracts are always defined by Java interfaces throw new GenerationException("Unexpected interface type for " + reference.getUri() + ": " + contract.getClass().getName()); } String interfaze = contract.getQualifiedInterfaceName(); URI uri = reference.getParent().getUri(); String referenceName = reference.getDefinition().getName(); return new SpringSourceDefinition(referenceName, interfaze, uri); }
private void generateBindings(LogicalReference reference, LogicalComponent<?> component, boolean incremental, ConnectionCommand command) throws GenerationException { boolean reinjection = isBoundReinjection(reference, incremental); for (LogicalBinding<?> logicalBinding : reference.getBindings()) { if (logicalBinding.getDefinition() instanceof SCABinding) { // skip SCA binding continue; } generateBinding(component, logicalBinding, command, incremental, reinjection, false); } if (reference.getServiceContract().getCallbackContract() != null) { boolean bindings = reference.isConcreteBound(); if (bindings) { List<LogicalBinding<?>> callbackBindings = reference.getCallbackBindings(); if (callbackBindings.isEmpty()) { // generate callback bindings as some transports do not require an explicit callback binding configuration on the reference generateCallbackBindings(reference); } if (callbackBindings.size() != 1) { // if the reference is explicitly bound, it must have one callback binding String uri = reference.getUri().toString(); throw new UnsupportedOperationException("The runtime requires exactly one callback binding to be specified on reference: " + uri); } LogicalBinding<?> callbackBinding = callbackBindings.get(0); generateBinding(component, callbackBinding, command, incremental, reinjection, true); } } }
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); }
public List<LogicalService> resolve(LogicalReference reference, LogicalCompositeComponent composite) { List<LogicalService> candidates = new ArrayList<>(); ServiceContract contract = reference.getServiceContract(); Multiplicity refMultiplicity = reference.getDefinition().getMultiplicity(); boolean multiplicity = Multiplicity.ZERO_N.equals(refMultiplicity) || Multiplicity.ONE_N.equals(refMultiplicity);
/** * Validates the reference and service contracts match. * * @param reference the reference * @param service the service * @param context the logical context */ private void validateContracts(LogicalReference reference, LogicalService service, InstantiationContext context) { ServiceContract referenceContract = reference.getServiceContract(); ServiceContract serviceContract = service.getServiceContract(); MatchResult result = matcher.isAssignableFrom(referenceContract, serviceContract, true); if (!result.isAssignable()) { URI serviceUri = service.getUri(); String message = result.getError(); IncompatibleContracts error = new IncompatibleContracts(reference, serviceUri, message); context.addError(error); } }
/** * Validates the reference and service contracts match. * * @param reference the reference * @param service the service * @param context the logical context */ private void validateContracts(LogicalReference reference, LogicalService service, InstantiationContext context) { ServiceContract referenceContract = reference.getServiceContract(); ServiceContract serviceContract = service.getServiceContract(); MatchResult result = matcher.isAssignableFrom(referenceContract, serviceContract, true); if (!result.isAssignable()) { URI serviceUri = service.getUri(); String message = result.getError(); IncompatibleContracts error = new IncompatibleContracts(reference, serviceUri, message); context.addError(error); } }
/** * Validates the reference and service contracts match. * * @param reference the reference * @param service the service * @param context the logical context */ private void validateContracts(LogicalReference reference, LogicalService service, InstantiationContext context) { ServiceContract referenceContract = reference.getServiceContract(); ServiceContract serviceContract = service.getServiceContract(); MatchResult result = matcher.isAssignableFrom(referenceContract, serviceContract, true); if (!result.isAssignable()) { URI serviceUri = service.getUri(); String message = result.getError(); IncompatibleContracts error = new IncompatibleContracts(reference, serviceUri, message); context.addError(error); } }
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); }
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; }
public <T extends Binding> PhysicalWire generateReferenceCallback(LogicalBinding<T> binding) { checkReference(binding); LogicalReference reference = (LogicalReference) binding.getParent(); LogicalComponent<?> component = reference.getParent(); ServiceContract contract = reference.getServiceContract(); ServiceContract callbackContract = contract.getCallbackContract(); LogicalService callbackService = component.getService(callbackContract.getInterfaceName()); List<LogicalOperation> operations = reference.getCallbackOperations(); // generate the metadata used to attach the physical callback wire to the source transport WireBindingGenerator<T> sourceGenerator = getGenerator(binding); PhysicalWireSource source = sourceGenerator.generateSource(binding, callbackContract, operations); URI sourceUri = binding.getParent().getParent().getDefinition().getContributionUri(); source.setClassLoader(classLoaderRegistry.getClassLoader(sourceUri)); // generate the metadata used to attach the physical callback wire to the target component ComponentGenerator targetGenerator = getGenerator(component); PhysicalWireTarget target = targetGenerator.generateTarget(callbackService); URI targetUri = callbackService.getParent().getDefinition().getContributionUri(); target.setClassLoader(classLoaderRegistry.getClassLoader(targetUri)); target.setCallback(true); Set<PhysicalOperation> operation = operationGenerator.generateOperations(operations); return new PhysicalWire(source, target, operation); }
public <T extends Binding> PhysicalWire generateReferenceCallback(LogicalBinding<T> binding) { checkReference(binding); LogicalReference reference = (LogicalReference) binding.getParent(); LogicalComponent<?> component = reference.getParent(); ServiceContract contract = reference.getServiceContract(); ServiceContract callbackContract = contract.getCallbackContract(); LogicalService callbackService = component.getService(callbackContract.getInterfaceName()); List<LogicalOperation> operations = reference.getCallbackOperations(); // generate the metadata used to attach the physical callback wire to the source transport WireBindingGenerator<T> sourceGenerator = getGenerator(binding); PhysicalWireSource source = sourceGenerator.generateSource(binding, callbackContract, operations); URI sourceUri = binding.getParent().getParent().getDefinition().getContributionUri(); source.setClassLoader(classLoaderRegistry.getClassLoader(sourceUri)); // generate the metadata used to attach the physical callback wire to the target component ComponentGenerator targetGenerator = getGenerator(component); PhysicalWireTarget target = targetGenerator.generateTarget(callbackService); URI targetUri = callbackService.getParent().getDefinition().getContributionUri(); target.setClassLoader(classLoaderRegistry.getClassLoader(targetUri)); target.setCallback(true); Set<PhysicalOperation> operation = operationGenerator.generateOperations(operations); return new PhysicalWire(source, target, operation); }
public <T extends BindingDefinition> PhysicalWireDefinition generateBoundReferenceCallback(LogicalBinding<T> binding) throws GenerationException { checkReference(binding); LogicalReference reference = (LogicalReference) binding.getParent(); LogicalComponent<?> component = reference.getParent(); ServiceContract contract = reference.getServiceContract(); ServiceContract callbackContract = contract.getCallbackContract(); LogicalService callbackService = component.getService(callbackContract.getInterfaceName()); List<LogicalOperation> operations = reference.getCallbackOperations(); // resolve policies PolicyResult policyResult = policyResolver.resolveCallbackPolicies(binding); EffectivePolicy sourcePolicy = policyResult.getSourcePolicy(); EffectivePolicy targetPolicy = policyResult.getTargetPolicy(); // generate the metadata used to attach the physical callback wire to the source transport BindingGenerator<T> sourceGenerator = getGenerator(binding); PhysicalSourceDefinition sourceDefinition = sourceGenerator.generateSource(binding, callbackContract, operations, targetPolicy); sourceDefinition.setClassLoaderId(binding.getParent().getParent().getDefinition().getContributionUri()); // generate the metadata used to attach the physical callback wire to the target component ComponentGenerator targetGenerator = getGenerator(component); PhysicalTargetDefinition targetDefinition = targetGenerator.generateTarget(callbackService, sourcePolicy); targetDefinition.setClassLoaderId(callbackService.getParent().getDefinition().getContributionUri()); targetDefinition.setCallback(true); Set<PhysicalOperationDefinition> operation = operationGenerator.generateOperations(operations, true, policyResult); return new PhysicalWireDefinition(sourceDefinition, targetDefinition, operation); }