/** * Does the pattern match the endpoint? * * @param uri the uri * @param endpoint the endpoint * @param pattern the pattern * @return <tt>true</tt> to match and therefore intercept, <tt>false</tt> if not matched and should not intercept */ protected boolean matchPattern(String uri, Endpoint endpoint, String pattern) { return uri == null || pattern == null || EndpointHelper.matchEndpoint(endpoint.getCamelContext(), uri, pattern); }
/** * Does the pattern match the endpoint? * * @param uri the uri * @param endpoint the endpoint * @param pattern the pattern * @return <tt>true</tt> to match and therefore intercept, <tt>false</tt> if not matched and should not intercept */ protected boolean matchPattern(String uri, Endpoint endpoint, String pattern) { return uri == null || pattern == null || EndpointHelper.matchEndpoint(endpoint.getCamelContext(), uri, pattern); }
public ErpProducer(Endpoint endpoint) { super(endpoint); // use Camel to create the thread pool for us this.executor = endpoint.getCamelContext().getExecutorServiceManager().newFixedThreadPool(this, "ERP", 10); }
@Override protected void doStop() throws Exception { super.doStop(); if (executor != null) { if (getEndpoint() != null && getEndpoint().getCamelContext() != null) { getEndpoint().getCamelContext().getExecutorServiceManager().shutdownNow(executor); } else { executor.shutdownNow(); } } executor = null; }
/** * Helper method which lookup for BindingDataCreatorResolver and uses returned * instance to create new CamelBindingData. * * @param camelExchange Camel exchange. * @return Binding data creator. */ private BindingDataCreator<?> getBindingDataCreator(org.apache.camel.Exchange camelExchange) { BindingDataCreatorResolver resolver = ((SwitchYardEndpoint) getEndpoint()).getBindingDataCreatorResolver(); String resolverKey = camelExchange.getFromEndpoint().getClass().getSimpleName(); return resolver.resolveBindingCreator(resolverKey, getEndpoint().getCamelContext()); }
/** * Get the LdapConnection. Since the object is a factory, we'll just call * that. A future enhancement is to use the ApacheDS LdapConnectionPool * object to keep a pool of working connections that avoids the connection * pause. * * @return The created LDAP connection. */ protected LdapConnection getLdapConnection() throws CamelException { return (LdapConnection)getEndpoint().getCamelContext().getRegistry().lookupByName(ldapConnectionName); }
/** * Helper method which lookup for BindingDataCreatorResolver and uses returned * instance to create new CamelBindingData. * * @param camelExchange Camel exchange. * @return Binding data creator. */ private BindingDataCreator<?> getBindingDataCreator(org.apache.camel.Exchange camelExchange) { BindingDataCreatorResolver resolver = ((SwitchYardEndpoint) getEndpoint()).getBindingDataCreatorResolver(); String resolverKey = camelExchange.getFromEndpoint().getClass().getSimpleName(); return resolver.resolveBindingCreator(resolverKey, getEndpoint().getCamelContext()); }
@Override protected Object doInvokeMethod(ApiMethod method, Map<String, Object> properties) throws RuntimeCamelException { AbstractGoogleClientRequest request = (AbstractGoogleClientRequest) super.doInvokeMethod(method, properties); try { TypeConverter typeConverter = getEndpoint().getCamelContext().getTypeConverter(); for (Entry<String, Object> p : properties.entrySet()) { IntrospectionSupport.setProperty(typeConverter, request, p.getKey(), p.getValue()); } return request.execute(); } catch (Exception e) { throw new RuntimeCamelException(e); } }
@Override protected Object doInvokeMethod(Map<String, Object> properties) throws RuntimeCamelException { AbstractGoogleClientRequest request = (AbstractGoogleClientRequest) super.doInvokeMethod(properties); try { TypeConverter typeConverter = getEndpoint().getCamelContext().getTypeConverter(); for (Entry<String, Object> p : properties.entrySet()) { IntrospectionSupport.setProperty(typeConverter, request, p.getKey(), p.getValue()); } return request.execute(); } catch (Exception e) { throw new RuntimeCamelException(e); } }
@Override protected void doStop() throws Exception { super.doStop(); shuttingDown = true; if (log.isTraceEnabled()) { log.trace(String.format("Shutting down zookeeper consumer of '%s'", configuration.getPath())); } getEndpoint().getCamelContext().getExecutorServiceManager().shutdown(executor); zkm.shutdown(); }
@Override protected Object doInvokeMethod(Map<String, Object> properties) throws RuntimeCamelException { AbstractGoogleClientRequest<?> request = (AbstractGoogleClientRequest) super.doInvokeMethod(properties); try { TypeConverter typeConverter = getEndpoint().getCamelContext().getTypeConverter(); for (Entry<String, Object> p : properties.entrySet()) { IntrospectionSupport.setProperty(typeConverter, request, p.getKey(), p.getValue()); } return request.execute(); } catch (Exception e) { throw new RuntimeCamelException(e); } } }
@Override protected void doStop() throws Exception { super.doStop(); localLog.info("Stopping Google PubSub consumer for {}/{}", endpoint.getProjectId(), endpoint.getDestinationName()); if (executor != null) { if (getEndpoint() != null && getEndpoint().getCamelContext() != null) { getEndpoint().getCamelContext().getExecutorServiceManager().shutdownNow(executor); } else { executor.shutdownNow(); } } executor = null; }
@Override protected Object doInvokeMethod(ApiMethod method, Map<String, Object> properties) throws RuntimeCamelException { AbstractGoogleClientRequest<?> request = (AbstractGoogleClientRequest)super.doInvokeMethod(method, properties); try { TypeConverter typeConverter = getEndpoint().getCamelContext().getTypeConverter(); for (Entry<String, Object> p : properties.entrySet()) { IntrospectionSupport.setProperty(typeConverter, request, p.getKey(), p.getValue()); } return request.execute(); } catch (Exception e) { throw new RuntimeCamelException(e); } }
@Override protected void doStart() throws Exception { super.doStart(); connection = zkm.getConnection(); if (log.isDebugEnabled()) { log.debug(String.format("Connected to Zookeeper cluster %s", configuration.getConnectString())); } initializeConsumer(); executor = getEndpoint().getCamelContext().getExecutorServiceManager().newFixedThreadPool(this, "Camel-Zookeeper OperationsExecutor", 1); OperationsExecutor opsService = new OperationsExecutor(); executor.submit(opsService); }
private String[] prepareArgs(Exchange exchange) { final TalendEndpoint talendEndpoint = (TalendEndpoint) getEndpoint(); final String context = talendEndpoint.getContext(); final Collection<String> args = new ArrayList<String>(); if (context != null) { args.add("--context=" + context); } if (propagateHeader && exchange != null) { getParamsFromHeaders(exchange, args); } getParamsFromProperties(getEndpoint().getCamelContext().getProperties(), args); getParamsFromProperties(talendEndpoint.getEndpointProperties(), args); return args.toArray(new String[args.size()]); }
@Override protected void doStop() throws Exception { super.doStop(); // shutdown thread pool when we stop getEndpoint().getCamelContext().getExecutorServiceManager().shutdown(executor); }
@Override protected void doStart() throws Exception { super.doStart(); // use Camel to create the thread pool for us this.executor = getEndpoint().getCamelContext().getExecutorServiceManager().newFixedThreadPool(this, "ERP", 10); }
@Override public void onInit(Consumer consumer) { this.consumer = consumer; // find the route of the consumer for (Route route : consumer.getEndpoint().getCamelContext().getRoutes()) { if (route.getConsumer() == consumer) { this.routeId = route.getId(); break; } } }
private void updateExchangeWithResult(ProductionContext context, OperationResult result) { ZooKeeperMessage out = new ZooKeeperMessage(getEndpoint().getCamelContext(), context.node, result.getStatistics(), context.in.getHeaders()); if (result.isOk()) { out.setBody(result.getResult()); } else { context.exchange.setException(result.getException()); } context.exchange.setOut(out); }
private Exchange createExchange(String path, OperationResult result, WatchedEvent watchedEvent) { Exchange exchange = getEndpoint().createExchange(); ZooKeeperMessage in = new ZooKeeperMessage(getEndpoint().getCamelContext(), path, result.getStatistics(), watchedEvent); exchange.setIn(in); if (result.isOk()) { in.setBody(result.getResult()); } else { exchange.setException(result.getException()); } return exchange; }