/** * 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(); }
/** * Returns the invocation chains for a wire in their natural order. * * @param wire the wire * @return the invocation chains */ public static List<InvocationChain> sortChains(Wire wire) { TreeMap<PhysicalOperationDefinition, InvocationChain> map = new TreeMap<PhysicalOperationDefinition, InvocationChain>(); for (InvocationChain chain : wire.getInvocationChains()) { map.put(chain.getPhysicalOperation(), chain); } List<InvocationChain> sorted = new ArrayList<InvocationChain>(); sorted.addAll(map.values()); return sorted; }
private void provision(RsSourceDefinition sourceDefinition, Wire wire, RsContainer container) throws ClassNotFoundException, RsContainerException { ClassLoader classLoader = classLoaderRegistry.getClassLoader(sourceDefinition.getClassLoaderId()); Map<String, InvocationChain> invocationChains = new HashMap<String, InvocationChain>(); for (InvocationChain chain : wire.getInvocationChains()) { PhysicalOperationDefinition operation = chain.getPhysicalOperation(); invocationChains.put(operation.getName(), chain); } Class<?> interfaze = classLoader.loadClass(sourceDefinition.getRsClass()); boolean authenticate = authenticate(sourceDefinition); F3ResourceHandler handler = new F3ResourceHandler(interfaze, invocationChains, authenticate, authenticator); // Set the class loader to the runtime one so Jersey loads the Resource config properly ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); Resource resource = createResource(handler); container.addResource(resource); } finally { Thread.currentThread().setContextClassLoader(old); } }
private void setMessageReceivers(Wire wire, AxisService axisService) throws Exception { Map<String, InvocationChain> interceptors = new HashMap<String, InvocationChain>(); for (InvocationChain chain : wire.getInvocationChains()) { interceptors.put(chain.getPhysicalOperation().getName(), chain); } Utils.fillAxisService(axisService, configurationContext.getAxisConfiguration(), null, null); for (Iterator<?> i = axisService.getOperations(); i.hasNext();) { AxisOperation axisOp = (AxisOperation) i.next(); InvocationChain invocationChain = interceptors.get(axisOp.getName().getLocalPart()); MessageReceiver messageReceiver = null; if (WSDL2Constants.MEP_URI_IN_ONLY.equals(axisOp.getMessageExchangePattern()) || WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(axisOp.getMessageExchangePattern())) { messageReceiver = new InOnlyServiceProxyHandler(invocationChain); } else {//Default MEP is IN-OUT for backward compatibility messageReceiver = new InOutServiceProxyHandler(invocationChain); } axisOp.setMessageReceiver(messageReceiver); } }
public void attachToTarget(PhysicalWireSourceDefinition source, Axis2WireTargetDefinition target, Wire wire) throws WiringException { ClassLoader classLoader = classLoaderRegistry.getClassLoader(source.getClassLoaderId()); List<String> endpointUris = new LinkedList<String>(); String endpointUri = expandUri(target.getUri()); StringTokenizer tok = new StringTokenizer(endpointUri); while (tok.hasMoreElements()) { endpointUris.add(tok.nextToken().trim()); } AxisService axisService = createAxisClientService(target, classLoader); for (InvocationChain chain : wire.getInvocationChains()) { String operation = chain.getPhysicalOperation().getName(); Set<AxisPolicy> policies = target.getPolicies(operation); Map<String, String> opInfo = target.getOperationInfo() != null ? target.getOperationInfo().get(operation) : null; Interceptor interceptor = new Axis2TargetInterceptor(endpointUris, operation, policies, opInfo, target.getConfig(), f3Configurator, policyApplier, axisService, classLoader); chain.addInterceptor(interceptor); } }
public void attach(PhysicalSourceDefinition sourceDefinition, RsTargetDefinition def, Wire wire) throws WiringException { ClassLoader targetClassLoader = classLoaderRegistry.getClassLoader(def.getClassLoaderId()); List<InvocationChain> invocationChains = wire.getInvocationChains(); URI uri = def.getUri(); String interfaze = def.getProxyInterface(); try { Class<?> interfaceClass = targetClassLoader.loadClass(interfaze); for (InvocationChain chain : invocationChains) { PhysicalOperationDefinition operation = chain.getPhysicalOperation(); String operationName = operation.getName(); List<String> targetParameterTypes = operation.getTargetParameterTypes(); Class<?> args[] = new Class<?>[targetParameterTypes.size()]; for (int i = 0; i < args.length; i++) { args[i] = targetClassLoader.loadClass(targetParameterTypes.get(i)); } chain.addInterceptor(new RsClientInterceptor(operationName, interfaceClass, uri, args)); } } catch (Exception e) { throw new WiringException(e); } }
private void addTransformer(List<InvocationChain> chains, ClassLoader loader) throws BrokerException { for (InvocationChain chain : chains) { try { PhysicalOperationDefinition physicalOperation = chain.getPhysicalOperation(); List<DataType<?>> targetTypes = createTypes(physicalOperation, loader); Interceptor interceptor = interceptorFactory.createInterceptor(physicalOperation, TRANSPORT_TYPES, targetTypes, loader, loader); chain.addInterceptor(new WrappingInterceptor()); chain.addInterceptor(interceptor); } catch (InterceptorCreationException e) { throw new BrokerException(e); } } }
public void connectToSender(String id, URI uri, List<InvocationChain> chains, ZeroMQMetadata metadata, ClassLoader loader) throws BrokerException { SenderHolder holder; if (ZMQ.equals(uri.getScheme())) { DelegatingOneWaySender sender = new DelegatingOneWaySender(id, this, metadata); holder = new SenderHolder(sender); } else { holder = senders.get(uri.toString()); } if (holder == null) { boolean oneWay = isOneWay(chains, uri); holder = createSender(uri.toString(), oneWay, metadata); managementService.registerSender(id, holder.getSender()); } for (int i = 0, chainsSize = chains.size(); i < chainsSize; i++) { InvocationChain chain = chains.get(i); try { PhysicalOperationDefinition physicalOperation = chain.getPhysicalOperation(); List<DataType<?>> sourceTypes = createTypes(physicalOperation, loader); Interceptor interceptor = interceptorFactory.createInterceptor(physicalOperation, sourceTypes, TRANSPORT_TYPES, loader, loader); chain.addInterceptor(interceptor); chain.addInterceptor(new UnwrappingInterceptor()); } catch (InterceptorCreationException e) { throw new BrokerException(e); } Interceptor interceptor = createInterceptor(holder, i); chain.addInterceptor(interceptor); } holder.getIds().add(id); }
public void attach(PhysicalSourceDefinition source, SpringTargetDefinition target, Wire wire) throws WiringException { String beanName = target.getBeanName(); ClassLoader loader = classLoaderRegistry.getClassLoader(target.getClassLoaderId()); Class<?> interfaze; try { interfaze = loader.loadClass(target.getBeanInterface()); } catch (ClassNotFoundException e) { throw new WiringException(e); } for (WireListener listener : listeners) { listener.onAttach(wire); } SpringComponent component = getComponent(target); for (InvocationChain chain : wire.getInvocationChains()) { PhysicalOperationDefinition operation = chain.getPhysicalOperation(); Method beanMethod = MethodUtils.findMethod(source, target, operation, interfaze, loader, classLoaderRegistry); SpringInvoker invoker = new SpringInvoker(beanName, beanMethod, component); chain.addInterceptor(invoker); } }
ClassLoader targetLoader = null; for (InvocationChain chain : wire.getInvocationChains()) { if (checkPassByRef && chain.getPhysicalOperation().isAllowsPassByReference()) { continue; targetLoader = classLoaderRegistry.getClassLoader(targetId); PhysicalOperationDefinition operation = chain.getPhysicalOperation(); List<DataType<?>> sourceTypes = sourceDefinition.getPhysicalDataTypes(); List<DataType<?>> targetTypes = targetDefinition.getPhysicalDataTypes();
PhysicalOperationDefinition operation = chain.getPhysicalOperation(); Method method = MethodUtils.findMethod(sourceDefinition, targetDefinition, operation, implementationClass, loader, classLoaderRegistry); ServiceInvoker invoker = reflectionFactory.createServiceInvoker(method);