public void onAttach(Wire wire) { for (InvocationChain chain : wire.getInvocationChains()) { SecurityContextInterceptor interceptor = new SecurityContextInterceptor(); chain.addInterceptor(interceptor); } } }
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, 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); } }
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; }
if (!expected.equals(Test.None.class)) { ExpectedExceptionInterceptor exceptionInterceptor = new ExpectedExceptionInterceptor(expected); chain.addInterceptor(exceptionInterceptor); chain.addInterceptor(interceptor);
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); }
try { Interceptor interceptor = transformerFactory.createInterceptor(operation, sourceTypes, targetTypes, targetLoader, sourceLoader); chain.addInterceptor(interceptor); } catch (InterceptorCreationException e) { throw new WiringException(e);