ClassLoader targetLoader, ClassLoader sourceLoader) throws Fabric3Exception { List<Class<?>> targetTypes = definition.getTargetParameterTypes(); List<Class<?>> sourceTypes = definition.getSourceParameterTypes(); throw new Fabric3Exception("No transformer found for operation: " + definition.getName()); List<Class<?>> sourceOutTypes = Collections.singletonList(definition.getSourceReturnType()); List<Class<?>> targetOutTypes = Collections.singletonList(definition.getTargetReturnType()); Transformer<Object, Object> outTransformer = (Transformer<Object, Object>) registry.getTransformer(selectedTarget, selectedSource,
/** * Determines if the wire is one-way or request-reply. The first operation is used to determine if the contract is one-way as the binding does not support * mixing one-way and request-response operations on a service contract. * * @param chains the wire invocation chains * @param uri thr service URI. * @return true if the wire is one-way */ private boolean isOneWay(List<InvocationChain> chains, URI uri) { if (chains.size() < 1) { throw new AssertionError("Contract must have at least one operation: " + uri); } return chains.get(0).getPhysicalOperation().isOneWay(); }
/** * Generates a PhysicalOperationDefinition when the source reference and target service contracts are the same. * * @param source the logical operation to generate from * @return the PhysicalOperationDefinition */ private PhysicalOperation generate(LogicalOperation source) { Operation o = source.getDefinition(); PhysicalOperation operation = new PhysicalOperation(); operation.setName(o.getName()); operation.setOneWay(o.isOneWay()); operation.setRemotable(o.isRemotable()); // the source and target in-, out- and fault types are the same since the source and target contracts are the same Class<?> returnType = o.getOutputType().getType(); operation.setSourceReturnType(returnType); operation.setTargetReturnType(returnType); for (DataType fault : o.getFaultTypes()) { Class<?> faultType = fault.getType(); operation.addSourceFaultType(faultType); operation.addTargetFaultType(faultType); } List<DataType> params = o.getInputTypes(); for (DataType param : params) { Class<?> paramType = param.getType(); operation.addSourceParameterType(paramType); operation.addTargetParameterType(paramType); } return operation; }
/** * Returns the matching method from the class for a given operation. * * @param clazz the class to introspect * @param operation the operation to match * @return a matching method * @throws NoSuchMethodException if a matching method is not found * @throws ClassNotFoundException if a parameter type specified in the operation is not found */ private Method findMethod(Class<?> clazz, PhysicalOperation operation) throws NoSuchMethodException, ClassNotFoundException { String name = operation.getName(); List<Class<?>> params = operation.getSourceParameterTypes(); return clazz.getMethod(name, params.toArray(new Class[params.size()])); }
/** * Constructor. * * @param chains Invocation chains. */ public JaxbInvoker(List<InvocationChain> chains) { for (InvocationChain chain : chains) { this.chains.put(chain.getPhysicalOperation().getName(), chain); } }
Class<?> implementationClass, ClassLoader loader) throws Fabric3Exception { List<Class<?>> params = operation.getTargetParameterTypes(); Class<?>[] paramTypes = new Class<?>[params.size()]; assert loader != null; if (operation.isRemotable()) { String name = operation.getName(); for (Method entry : methods) { if (name.equals(entry.getName())) { method = implementationClass.getMethod(operation.getName(), paramTypes); } catch (NoSuchMethodException e) { URI sourceUri = source.getUri();
public void attach(PhysicalWireSource source, RsWireTarget target, Wire wire) throws Fabric3Exception { List<InvocationChain> invocationChains = wire.getInvocationChains(); URI uri = target.getUri(); Class<?> interfaceClass = target.getProxyInterface(); try { for (InvocationChain chain : invocationChains) { PhysicalOperation operation = chain.getPhysicalOperation(); String operationName = operation.getName(); List<Class<?>> targetParameterTypes = operation.getTargetParameterTypes(); chain.addInterceptor(new RsClientInterceptor(operationName, interfaceClass, uri, targetParameterTypes)); } } catch (Exception e) { throw new Fabric3Exception(e); } }
private void attachInterceptors(Class<?> seiClass, MetroJavaWireTarget target, Wire wire, Supplier<?> factory) { Method[] methods = seiClass.getMethods(); int retries = target.getRetries(); for (InvocationChain chain : wire.getInvocationChains()) { Method method = null; for (Method m : methods) { if (chain.getPhysicalOperation().getName().equals(m.getName())) { method = m; break; } } boolean oneWay = chain.getPhysicalOperation().isOneWay(); MetroJavaTargetInterceptor targetInterceptor = new MetroJavaTargetInterceptor(factory, method, oneWay, retries, monitor); chain.addInterceptor(targetInterceptor); } }
@SuppressWarnings({"unchecked"}) private List<DataType> createTypes(PhysicalOperation physicalOperation) throws Fabric3Exception { List<DataType> dataTypes = new ArrayList<>(); if (physicalOperation.getSourceParameterTypes().isEmpty()) { // no params dataTypes.add(EMPTY_TYPE); } else { List<Class<?>> types = physicalOperation.getSourceParameterTypes(); dataTypes.addAll(types.stream().map(type -> new JavaType((type))).collect(Collectors.toList())); } return dataTypes; }
/** * Returns the matching method from the class for a given operation. * * @param clazz the class to introspect * @param operation the operation to match * @return a matching method * @throws NoSuchMethodException if a matching method is not found * @throws ClassNotFoundException if a parameter type specified in the operation is not found */ private Method findMethod(Class<?> clazz, PhysicalOperation operation) throws NoSuchMethodException, ClassNotFoundException { String name = operation.getName(); List<Class<?>> params = operation.getSourceParameterTypes(); return clazz.getMethod(name, params.toArray(new Class[params.size()])); }
public ServiceListener(WireHolder wireHolder, Destination defaultResponseDestination, ConnectionFactory responseFactory, SessionType sessionType, ClassLoader classLoader, List<BindingHandler<Message>> handlers, ListenerMonitor monitor) { this.wireHolder = wireHolder; this.defaultResponseDestination = defaultResponseDestination; this.responseFactory = responseFactory; this.sessionType = sessionType; this.classLoader = classLoader; this.handlers = handlers; this.monitor = monitor; invocationChainMap = new HashMap<>(); for (InvocationChainHolder chainHolder : wireHolder.getInvocationChains()) { String name = chainHolder.getChain().getPhysicalOperation().getName(); if ("onMessage".equals(name)) { onMessageHolder = chainHolder; } invocationChainMap.put(name, chainHolder); } }
Class<?> implementationClass, ClassLoader loader) throws Fabric3Exception { List<Class<?>> params = operation.getTargetParameterTypes(); Class<?>[] paramTypes = new Class<?>[params.size()]; assert loader != null; if (operation.isRemotable()) { String name = operation.getName(); for (Method entry : methods) { if (name.equals(entry.getName())) { method = implementationClass.getMethod(operation.getName(), paramTypes); } catch (NoSuchMethodException e) { URI sourceUri = source.getUri();
public void attach(PhysicalWireSource source, RsWireTarget target, Wire wire) throws Fabric3Exception { List<InvocationChain> invocationChains = wire.getInvocationChains(); URI uri = target.getUri(); Class<?> interfaceClass = target.getProxyInterface(); try { for (InvocationChain chain : invocationChains) { PhysicalOperation operation = chain.getPhysicalOperation(); String operationName = operation.getName(); List<Class<?>> targetParameterTypes = operation.getTargetParameterTypes(); chain.addInterceptor(new RsClientInterceptor(operationName, interfaceClass, uri, targetParameterTypes)); } } catch (Exception e) { throw new Fabric3Exception(e); } }
public static List<DataType> createTypes(PhysicalOperation physicalOperation) throws Fabric3Exception { List<DataType> dataTypes = new ArrayList<>(); if (!physicalOperation.getSourceParameterTypes().isEmpty()) { List<Class<?>> types = physicalOperation.getSourceParameterTypes(); dataTypes.addAll(types.stream().map(type -> new JavaType((type))).collect(Collectors.toList())); } return dataTypes; }
/** * Generates a PhysicalOperationDefinition when the source reference and target service contracts are the same. * * @param source the logical operation to generate from * @return the PhysicalOperationDefinition */ private PhysicalOperation generate(LogicalOperation source) { Operation o = source.getDefinition(); PhysicalOperation operation = new PhysicalOperation(); operation.setName(o.getName()); operation.setOneWay(o.isOneWay()); operation.setRemotable(o.isRemotable()); // the source and target in-, out- and fault types are the same since the source and target contracts are the same Class<?> returnType = o.getOutputType().getType(); operation.setSourceReturnType(returnType); operation.setTargetReturnType(returnType); for (DataType fault : o.getFaultTypes()) { Class<?> faultType = fault.getType(); operation.addSourceFaultType(faultType); operation.addTargetFaultType(faultType); } List<DataType> params = o.getInputTypes(); for (DataType param : params) { Class<?> paramType = param.getType(); operation.addSourceParameterType(paramType); operation.addTargetParameterType(paramType); } return operation; }
ClassLoader targetLoader, ClassLoader sourceLoader) throws Fabric3Exception { List<Class<?>> targetTypes = definition.getTargetParameterTypes(); List<Class<?>> sourceTypes = definition.getSourceParameterTypes(); throw new Fabric3Exception("No transformer found for operation: " + definition.getName()); List<Class<?>> sourceOutTypes = Collections.singletonList(definition.getSourceReturnType()); List<Class<?>> targetOutTypes = Collections.singletonList(definition.getTargetReturnType()); Transformer<Object, Object> outTransformer = (Transformer<Object, Object>) registry.getTransformer(selectedTarget, selectedSource,
public void attach(PhysicalWireSource source, SystemWireTarget target, Wire wire) throws Fabric3Exception { URI targetId = UriHelper.getDefragmentedName(target.getUri()); SystemComponent targetComponent = (SystemComponent) manager.getComponent(targetId); Class<?> implementationClass = targetComponent.getImplementationClass(); for (InvocationChain chain : wire.getInvocationChains()) { PhysicalOperation operation = chain.getPhysicalOperation(); List<Class<?>> params = operation.getSourceParameterTypes(); Method method; try { method = implementationClass.getMethod(operation.getName(), params.toArray(new Class[params.size()])); } catch (NoSuchMethodException e) { throw new Fabric3Exception("No matching method found", e); } SystemInvokerInterceptor interceptor = new SystemInvokerInterceptor(method, targetComponent); chain.addInterceptor(interceptor); } }
private Map<Method, InvocationChain> createInterfaceToWireMapping(Class<?> interfaze, Wire wire) { List<InvocationChain> invocationChains = wire.getInvocationChains(); Map<Method, InvocationChain> chains = new HashMap<>(invocationChains.size()); for (InvocationChain chain : invocationChains) { PhysicalOperation operation = chain.getPhysicalOperation(); try { Method method = findMethod(interfaze, operation); chains.put(method, chain); } catch (NoSuchMethodException e) { throw new Fabric3Exception(operation.getName()); } catch (ClassNotFoundException e) { throw new Fabric3Exception(e); } } return chains; }
InvocationChainHolder holder = getHolder(request); Interceptor interceptor = holder.getChain().getHeadInterceptor(); boolean oneWay = holder.getChain().getPhysicalOperation().isOneWay(); OperationPayloadTypes payloadTypes = holder.getPayloadTypes(); PayloadType inputType = payloadTypes.getInputType();