/** * Constructor. * * @param chains Invocation chains. */ public JaxbInvoker(List<InvocationChain> chains) { for (InvocationChain chain : chains) { this.chains.put(chain.getPhysicalOperation().getName(), chain); } }
private void attachInterceptors(Class<?> seiClass, MetroJavaWireTargetDefinition target, Wire wire, ObjectFactory<?> 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); } }
PhysicalOperationDefinition operation = new PhysicalOperationDefinition(); operation.setName(o.getName()); if (o.getIntents().contains(OASIS_ONEWAY)) { operation.setOneWay(true); operation.setRemotable(remotable); if (remotable && !useByReference(source, remote)) { operation.setAllowsPassByReference(false); operation.setSourceReturnType(returnName); operation.setTargetReturnType(returnName); operation.addSourceFaultType(faultName); operation.addTargetFaultType(faultName); Class<?> paramType = param.getPhysical(); String paramName = paramType.getName(); operation.addSourceParameterType(paramName); operation.addTargetParameterType(paramName);
ClassLoader loader, ClassLoaderRegistry classLoaderRegistry) throws WireAttachException { List<String> 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 = sourceDefinition.getUri();
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); } }
/** * 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(); }
public void attach(PhysicalWireSourceDefinition source, MetroWsdlWireTargetDefinition target, Wire wire) throws ContainerException { ReferenceEndpointDefinition endpointDefinition = target.getEndpointDefinition(); List<QName> requestedIntents = target.getIntents(); WebServiceFeature[] features = resolver.getFeatures(requestedIntents); String wsdl = target.getWsdl(); URL wsdlLocation; try { URI servicePath = target.getEndpointDefinition().getUrl().toURI(); wsdlLocation = cache.cache(servicePath, new ByteArrayInputStream(wsdl.getBytes())); } catch (CacheException | URISyntaxException e) { throw new ContainerException(e); } SecurityConfiguration securityConfiguration = target.getSecurityConfiguration(); ConnectionConfiguration connectionConfiguration = target.getConnectionConfiguration(); List<Handler> handlers = createHandlers(target); MetroDispatchObjectFactory proxyFactory = new MetroDispatchObjectFactory(endpointDefinition, wsdlLocation, null, securityConfiguration, connectionConfiguration, handlers, features, executorService, securityEnvironment); for (InvocationChain chain : wire.getInvocationChains()) { boolean oneWay = chain.getPhysicalOperation().isOneWay(); MetroDispatchTargetInterceptor targetInterceptor = new MetroDispatchTargetInterceptor(proxyFactory, oneWay); chain.addInterceptor(targetInterceptor); } }
PhysicalOperationDefinition operation = new PhysicalOperationDefinition(); operation.setName(o.getName()); boolean remotable = o.isRemotable(); operation.setRemotable(remotable); if (remotable && (!useByReference(source, remote) || !useByReference(target, remote))) { operation.setAllowsPassByReference(false); operation.setOneWay(true); operation.setSourceReturnType(returnType.getName()); operation.addSourceFaultType(faultType.getName()); for (DataType<?> param : params) { Class<?> paramType = param.getPhysical(); operation.addSourceParameterType(paramType.getName()); operation.setTargetReturnType(targetReturnType.getName()); operation.addTargetFaultType(faultType.getName()); for (DataType<?> param : targetParams) { Class<?> paramType = param.getPhysical(); operation.addTargetParameterType(paramType.getName());
/** * Constructor. * * @param chains the invocation chains for the wire. */ public DocumentInvoker(List<InvocationChain> chains) { for (InvocationChain chain : chains) { this.chains.put(chain.getPhysicalOperation().getName(), chain); } ClassLoader old = Thread.currentThread().getContextClassLoader(); try { // set classloader to pick up correct SAAJ implementation Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); factory = MessageFactory.newInstance(); } catch (SOAPException e) { // programming error throw new AssertionError(e); } finally { Thread.currentThread().setContextClassLoader(old); } }
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); } }
throw new NoInterceptorException("No transformer found for operation: " + definition.getName());