private Interceptor getInterceptor() { // lazy load the interceptor as it may not have been added when the instance was created in the wire attacher if (interceptor == null) { interceptor = wire.getInvocationChains().iterator().next().getHeadInterceptor(); } return interceptor; } }
Wire createWire(PhysicalWireDefinition definition) throws BuilderException { Wire wire = new WireImpl(); for (PhysicalOperationDefinition operation : definition.getOperations()) { InvocationChain chain = new InvocationChainImpl(operation); for (PhysicalInterceptorDefinition interceptorDefinition : operation.getInterceptors()) { InterceptorBuilder<? super PhysicalInterceptorDefinition> builder = getBuilder(interceptorDefinition); Interceptor interceptor = builder.build(interceptorDefinition); chain.addInterceptor(interceptor); } wire.addInvocationChain(chain); } processTransform(wire, definition); return wire; }
/** * 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; }
public void onAttach(Wire wire) { for (InvocationChain chain : wire.getInvocationChains()) { SecurityContextInterceptor interceptor = new SecurityContextInterceptor(); chain.addInterceptor(interceptor); } } }
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 attach(PhysicalSourceDefinition source, FtpTargetDefinition target, Wire wire) throws WiringException { InvocationChain invocationChain = wire.getInvocationChains().iterator().next(); URI uri = target.getUri(); try { String host = uri.getHost(); int port = uri.getPort() == -1 ? 23 : uri.getPort(); InetAddress hostAddress = "localhost".equals(host) ? InetAddress.getLocalHost() : InetAddress.getByName(host); String remotePath = uri.getPath(); String tmpFileSuffix = target.getTmpFileSuffix(); FtpSecurity security = target.getSecurity(); boolean active = target.isActive(); int connectTimeout = target.getConectTimeout(); SocketFactory factory = new ExpiringSocketFactory(connectTimeout); int socketTimeout = target.getSocketTimeout(); List<String> cmds = target.getSTORCommands(); FtpTargetInterceptor targetInterceptor = new FtpTargetInterceptor(hostAddress, port, security, active, socketTimeout, factory, cmds, monitor); targetInterceptor.setTmpFileSuffix(tmpFileSuffix); targetInterceptor.setRemotePath(remotePath); invocationChain.addInterceptor(targetInterceptor); } catch (UnknownHostException e) { throw new WiringException(e); } }
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); } }
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); } }
public void attach(JUnitSourceDefinition source, PhysicalTargetDefinition target, Wire wire) throws WiringException { String testName = source.getTestName(); ContextConfiguration configuration = source.getConfiguration(); if (configuration != null) { if (authenticationService == null) { throw new WiringException("Security information set for the test but a security extension has not been installed in the runtime"); } // configuration an authentication interceptor to set the subject on the work context for (InvocationChain chain : wire.getInvocationChains()) { Interceptor next = chain.getHeadInterceptor(); String username = configuration.getUsername(); String password = configuration.getPassword(); AuthenticatingInterceptor interceptor = new AuthenticatingInterceptor(username, password, authenticationService, next); chain.addInterceptor(0, interceptor); } } holder.add(testName, wire); }
for (InvocationChain chain : wire.getInvocationChains()) { PhysicalOperationDefinition operation = chain.getPhysicalOperation(); Method method = MethodUtils.findMethod(sourceDefinition, targetDefinition, operation, implementationClass, loader, classLoaderRegistry);
ClassLoader sourceLoader = null; ClassLoader targetLoader = null; for (InvocationChain chain : wire.getInvocationChains()) { if (checkPassByRef && chain.getPhysicalOperation().isAllowsPassByReference()) { continue;