public void detach(PhysicalWireSource source, ZeroMQWireTarget target) { String id = source.getUri().toString(); URI uri = target.getUri(); broker.releaseSender(id, uri); }
private void addJAXBInterceptor(PhysicalWireSource source, PhysicalOperation op, InvocationChain chain, ClassLoader targetClassLoader) { ClassLoader sourceClassLoader = source.getClassLoader(); List<DataType> jaxTypes = DataTypeHelper.createTypes(op); Interceptor jaxbInterceptor = interceptorFactory.createInterceptor(op, jaxTypes, DataTypeHelper.JAXB_TYPES, targetClassLoader, sourceClassLoader); chain.addInterceptor(jaxbInterceptor); }
PhysicalWireSource source = sourceGenerator.generateSource(reference); URI sourceUri = sourceComponent.getDefinition().getContributionUri(); source.setClassLoader(classLoaderRegistry.getClassLoader(sourceUri)); source.setKey(key); source.setOrder(order); boolean optimizable = source.isOptimizable() && target.isOptimizable() && checkOptimization(referenceContract, operations); physicalWire.setOptimizable(optimizable); return physicalWire;
public <T extends ResourceReference> PhysicalWire generateResource(LogicalResourceReference<T> logicalReference) { T reference = logicalReference.getDefinition(); LogicalComponent<?> component = logicalReference.getParent(); // Generates the wire source metadata ComponentGenerator sourceGenerator = getGenerator(component); @SuppressWarnings("unchecked") PhysicalWireSource source = sourceGenerator.generateResourceSource(logicalReference); URI sourceUri = component.getDefinition().getContributionUri(); source.setClassLoader(classLoaderRegistry.getClassLoader(sourceUri)); // Generates the wire target metadata ResourceReferenceGenerator<T> targetGenerator = getGenerator(reference); PhysicalWireTarget target = targetGenerator.generateWireTarget(logicalReference); URI targetUri = logicalReference.getParent().getDefinition().getContributionUri(); target.setClassLoader(classLoaderRegistry.getClassLoader(targetUri)); boolean optimizable = target.isOptimizable(); // Create the wire from the component to the resource List<LogicalOperation> sourceOperations = logicalReference.getOperations(); Set<PhysicalOperation> operations = operationGenerator.generateOperations(sourceOperations); PhysicalWire physicalWire = new PhysicalWire(source, target, operations); physicalWire.setOptimizable(optimizable); return physicalWire; }
public <T extends Binding> PhysicalWire generateService(LogicalBinding<T> binding, URI callbackUri) { checkService(binding); LogicalService service = (LogicalService) binding.getParent(); LogicalComponent<?> component = service.getParent(); ServiceContract contract = service.getServiceContract(); List<LogicalOperation> operations = service.getOperations(); // generate the metadata used to attach the physical wire to the target component ComponentGenerator targetGenerator = getGenerator(component); PhysicalWireTarget target = targetGenerator.generateTarget(service); URI targetUri = service.getParent().getDefinition().getContributionUri(); target.setClassLoader(classLoaderRegistry.getClassLoader(targetUri)); target.setCallbackUri(callbackUri); // generate the metadata used to attach the physical wire to the source transport WireBindingGenerator<T> sourceGenerator = getGenerator(binding); PhysicalWireSource source = sourceGenerator.generateSource(binding, contract, operations); URI sourceUri = service.getParent().getDefinition().getContributionUri(); source.setClassLoader(classLoaderRegistry.getClassLoader(sourceUri)); // generate the metadata for interceptors that are attached to wire invocation chains, e.g. policy implemented by an interceptor Set<PhysicalOperation> physicalOperations = operationGenerator.generateOperations(operations); PhysicalWire physicalWire = new PhysicalWire(source, target, physicalOperations); boolean optimizable = source.isOptimizable() && target.isOptimizable() && checkOptimization(contract, physicalOperations); physicalWire.setOptimizable(optimizable); return physicalWire; }
source.setKey(key); source.setClassLoader(sourceLoader);
PhysicalWireSource source = sourceGenerator.generateSource(reference); URI sourceUri = sourceComponent.getDefinition().getContributionUri(); source.setClassLoader(classLoaderRegistry.getClassLoader(sourceUri)); source.setKey(key); source.setOrder(order); boolean optimizable = source.isOptimizable() && target.isOptimizable() && checkOptimization(referenceContract, operations); physicalWire.setOptimizable(optimizable); return physicalWire;
public <T extends ResourceReference> PhysicalWire generateResource(LogicalResourceReference<T> logicalReference) { T reference = logicalReference.getDefinition(); LogicalComponent<?> component = logicalReference.getParent(); // Generates the wire source metadata ComponentGenerator sourceGenerator = getGenerator(component); @SuppressWarnings("unchecked") PhysicalWireSource source = sourceGenerator.generateResourceSource(logicalReference); URI sourceUri = component.getDefinition().getContributionUri(); source.setClassLoader(classLoaderRegistry.getClassLoader(sourceUri)); // Generates the wire target metadata ResourceReferenceGenerator<T> targetGenerator = getGenerator(reference); PhysicalWireTarget target = targetGenerator.generateWireTarget(logicalReference); URI targetUri = logicalReference.getParent().getDefinition().getContributionUri(); target.setClassLoader(classLoaderRegistry.getClassLoader(targetUri)); boolean optimizable = target.isOptimizable(); // Create the wire from the component to the resource List<LogicalOperation> sourceOperations = logicalReference.getOperations(); Set<PhysicalOperation> operations = operationGenerator.generateOperations(sourceOperations); PhysicalWire physicalWire = new PhysicalWire(source, target, operations); physicalWire.setOptimizable(optimizable); return physicalWire; }
public <T extends Binding> PhysicalWire generateService(LogicalBinding<T> binding, URI callbackUri) { checkService(binding); LogicalService service = (LogicalService) binding.getParent(); LogicalComponent<?> component = service.getParent(); ServiceContract contract = service.getServiceContract(); List<LogicalOperation> operations = service.getOperations(); // generate the metadata used to attach the physical wire to the target component ComponentGenerator targetGenerator = getGenerator(component); PhysicalWireTarget target = targetGenerator.generateTarget(service); URI targetUri = service.getParent().getDefinition().getContributionUri(); target.setClassLoader(classLoaderRegistry.getClassLoader(targetUri)); target.setCallbackUri(callbackUri); // generate the metadata used to attach the physical wire to the source transport WireBindingGenerator<T> sourceGenerator = getGenerator(binding); PhysicalWireSource source = sourceGenerator.generateSource(binding, contract, operations); URI sourceUri = service.getParent().getDefinition().getContributionUri(); source.setClassLoader(classLoaderRegistry.getClassLoader(sourceUri)); // generate the metadata for interceptors that are attached to wire invocation chains, e.g. policy implemented by an interceptor Set<PhysicalOperation> physicalOperations = operationGenerator.generateOperations(operations); PhysicalWire physicalWire = new PhysicalWire(source, target, physicalOperations); boolean optimizable = source.isOptimizable() && target.isOptimizable() && checkOptimization(contract, physicalOperations); physicalWire.setOptimizable(optimizable); return physicalWire; }
source.setKey(key); source.setClassLoader(sourceLoader);
public void attach(PhysicalWireSource source, ZeroMQWireTarget target, Wire wire) { URI sourceUri = source.getUri(); String id = sourceUri.getPath().substring(1) + "/" + sourceUri.getFragment(); // strip leading '/' URI targetUri = target.getUri(); ClassLoader loader = target.getClassLoader(); List<InvocationChain> chains = ZeroMQAttacherHelper.sortChains(wire); broker.connectToSender(id, targetUri, chains, target.getMetadata(), loader); }
public <T extends Binding> PhysicalWire generateServiceCallback(LogicalBinding<T> binding) { checkService(binding); LogicalService service = (LogicalService) binding.getParent(); LogicalComponent<?> component = service.getParent(); ServiceContract contract = service.getServiceContract(); ServiceContract callbackContract = contract.getCallbackContract(); List<LogicalOperation> operations = service.getCallbackOperations(); // generate the metadata used to attach the physical callback wire to the source component ComponentGenerator sourceGenerator = getGenerator(component); PhysicalWireSource source = sourceGenerator.generateCallbackSource(service); URI sourceUri = component.getDefinition().getContributionUri(); source.setClassLoader(classLoaderRegistry.getClassLoader(sourceUri)); // generate the metadata used to attach the physical callback wire to the target transport WireBindingGenerator<T> bindingGenerator = getGenerator(binding); PhysicalWireTarget target = bindingGenerator.generateTarget(binding, callbackContract, operations); target.setCallback(true); URI targetUri = binding.getParent().getParent().getDefinition().getContributionUri(); target.setClassLoader(classLoaderRegistry.getClassLoader(targetUri)); // generate the metadata for interceptors that are attached to wire invocation chains, e.g. policy implemented by an interceptor Set<PhysicalOperation> physicalOperations = operationGenerator.generateOperations(operations); return new PhysicalWire(source, target, physicalOperations); }
public void attach(PhysicalWireSource source, JavaWireTarget target, Wire wire) { URI targetName = UriHelper.getDefragmentedName(target.getUri()); Component component = manager.getComponent(targetName); if (component == null) { throw new Fabric3Exception("Target not found: " + targetName); } JavaComponent javaComponent = (JavaComponent) component; Class<?> implementationClass = javaComponent.getImplementationClass(); ClassLoader loader = target.getClassLoader(); // attach the invoker interceptor to forward invocation chains for (InvocationChain chain : wire.getInvocationChains()) { PhysicalOperation operation = chain.getPhysicalOperation(); Method method = MethodUtils.findMethod(source, target, operation, implementationClass, loader); ServiceInvoker invoker = reflectionFactory.createServiceInvoker(method); InvokerInterceptor interceptor; if (source instanceof PojoWireSource && target.getClassLoader().equals(source.getClassLoader())) { // if the source is Java and target classloaders are equal, do not set the TCCL interceptor = new InvokerInterceptor(invoker, javaComponent); } else { // If the source and target classloaders are not equal, configure the interceptor to set the TCCL to the target classloader // when dispatching to a target instance. This guarantees when application code executes, it does so with the TCCL set to the // target component's classloader. interceptor = new InvokerInterceptor(invoker, javaComponent, loader); } chain.addInterceptor(interceptor); } }
URI sourceUri = source.getUri(); URI targetUri = target.getUri(); throw new Fabric3Exception("No matching method found when wiring " + sourceUri + " to " + targetUri); method = implementationClass.getMethod(operation.getName(), paramTypes); } catch (NoSuchMethodException e) { URI sourceUri = source.getUri(); URI targetUri = target.getUri(); throw new Fabric3Exception("No matching method found when wiring " + sourceUri + " to " + targetUri, e);
public <T extends Binding> PhysicalWire generateServiceCallback(LogicalBinding<T> binding) { checkService(binding); LogicalService service = (LogicalService) binding.getParent(); LogicalComponent<?> component = service.getParent(); ServiceContract contract = service.getServiceContract(); ServiceContract callbackContract = contract.getCallbackContract(); List<LogicalOperation> operations = service.getCallbackOperations(); // generate the metadata used to attach the physical callback wire to the source component ComponentGenerator sourceGenerator = getGenerator(component); PhysicalWireSource source = sourceGenerator.generateCallbackSource(service); URI sourceUri = component.getDefinition().getContributionUri(); source.setClassLoader(classLoaderRegistry.getClassLoader(sourceUri)); // generate the metadata used to attach the physical callback wire to the target transport WireBindingGenerator<T> bindingGenerator = getGenerator(binding); PhysicalWireTarget target = bindingGenerator.generateTarget(binding, callbackContract, operations); target.setCallback(true); URI targetUri = binding.getParent().getParent().getDefinition().getContributionUri(); target.setClassLoader(classLoaderRegistry.getClassLoader(targetUri)); // generate the metadata for interceptors that are attached to wire invocation chains, e.g. policy implemented by an interceptor Set<PhysicalOperation> physicalOperations = operationGenerator.generateOperations(operations); return new PhysicalWire(source, target, physicalOperations); }
URI sourceUri = source.getUri(); URI targetUri = target.getUri(); throw new Fabric3Exception("No matching method found when wiring " + sourceUri + " to " + targetUri); method = implementationClass.getMethod(operation.getName(), paramTypes); } catch (NoSuchMethodException e) { URI sourceUri = source.getUri(); URI targetUri = target.getUri(); throw new Fabric3Exception("No matching method found when wiring " + sourceUri + " to " + targetUri, e);
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); }
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; }