protected boolean isFilteredClass(Object bean) { if (filter != null) { return filter.matches(bean.getClass()); } else { return false; } }
ThreadPoolProfile threadPool = configure(new ThreadPoolProfile(), $camel.getConfig("threads")); ctx.getExecutorServiceManager().setDefaultThreadPoolProfile(threadPool);
@UriEndpoint(firstVersion = "1.4.0", scheme = "spring-event", title = "Spring Event", syntax = "spring-event:name", consumerClass = EventConsumer.class, label = "spring,eventbus") public class EventEndpoint extends DefaultEndpoint implements ApplicationContextAware { private LoadBalancer loadBalancer; private ApplicationContext applicationContext; @UriPath(description = "Name of endpoint") private String name;
/** * Configures a {@link ProducerTemplate} * * @version */ @Metadata(label = "spring,configuration") @XmlRootElement(name = "template") @XmlAccessorType(XmlAccessType.FIELD) public class CamelProducerTemplateFactoryBean extends AbstractCamelProducerTemplateFactoryBean implements FactoryBean<ProducerTemplate>, InitializingBean, DisposableBean, ApplicationContextAware { @XmlTransient private ApplicationContext applicationContext; @Override protected CamelContext getCamelContextWithId(String camelContextId) { return CamelContextResolverHelper.getCamelContextWithId(applicationContext, camelContextId); } public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } }
if (cx.targetException().equals(ec)) { ExceptionHandler h = cx.targetCatchHandler().newInstance(); h.handleException(e); break;
protected RoutesBuilder instantiateBuilder(Class<? extends RoutesBuilder> type) throws IllegalAccessException, InstantiationException { return camelContext.getInjector().newInstance(type); } }
@Override public Object resolve(EvaluationContext context, String beanName) throws AccessException { Object bean = null; try { bean = registry.lookupByName(beanName); } catch (NoSuchBeanException e) { // ignore } if (bean == null) { throw new AccessException("Could not resolve bean reference against Registry"); } return bean; }
@Override public void shutdown() { camelContext.getExecutorServiceManager().shutdownNow(getScheduledExecutor()); } }
/** * Asserts that the given language name and expression evaluates to the * given value on a specific exchange */ protected void assertExpression(Exchange exchange, String languageName, String expressionText, Object expectedValue) { Language language = assertResolveLanguage(languageName); Expression expression = language.createExpression(expressionText); assertNotNull("No Expression could be created for text: " + expressionText + " language: " + language, expression); assertExpression(expression, exchange, expectedValue); }
/** * Asserts that the given language name and predicate expression evaluates * to the expected value on the message exchange */ protected void assertPredicate(String languageName, String expressionText, Exchange exchange, boolean expected) { Language language = assertResolveLanguage(languageName); Predicate predicate = language.createPredicate(expressionText); assertNotNull("No Predicate could be created for text: " + expressionText + " language: " + language, predicate); assertPredicate(predicate, exchange, expected); }
@Override protected void findRouteBuildersByPackageScan(String[] packages, PackageScanFilter filter, List<RoutesBuilder> builders) throws Exception { // add filter to class resolver which then will filter getContext().getPackageScanClassResolver().addFilter(filter); PackageScanRouteBuilderFinder finder = new PackageScanRouteBuilderFinder(getContext(), packages, getContextClassLoaderOnStart(), getBeanPostProcessor(), getContext().getPackageScanClassResolver()); finder.appendBuilders(builders); // and remove the filter getContext().getPackageScanClassResolver().removeFilter(filter); }
@Override protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) { return camelContext.getExecutorServiceManager().newScheduledThreadPool(source, name, poolSize); }
public PackageScanRouteBuilderFinder(SpringCamelContext camelContext, String[] packages, ClassLoader classLoader, BeanPostProcessor postProcessor, PackageScanClassResolver resolver) { this.camelContext = camelContext; this.applicationContext = camelContext.getApplicationContext(); this.packages = packages; this.beanPostProcessor = postProcessor; this.resolver = resolver; // add our provided loader as well resolver.addClassLoader(classLoader); }
@Override public void process(Exchange exchange) throws Exception { // we have to run this synchronously as Spring Transaction does *not* support // using multiple threads to span a transaction if (transactionTemplate.getPropagationBehavior() != TransactionDefinition.PROPAGATION_REQUIRES_NEW && exchange.getUnitOfWork() != null && exchange.getUnitOfWork().isTransactedBy(transactionKey)) { // already transacted by this transaction template // so lets just let the error handler process it processByErrorHandler(exchange); } else { // not yet wrapped in transaction so lets do that // and then have it invoke the error handler from within that transaction processInTransaction(exchange); } }
/** * Configures a {@link org.apache.camel.FluentProducerTemplate} * * @version */ @Metadata(label = "spring,configuration") @XmlRootElement(name = "fluentTemplate") @XmlAccessorType(XmlAccessType.FIELD) public class CamelFluentProducerTemplateFactoryBean extends AbstractCamelFluentProducerTemplateFactoryBean implements FactoryBean<FluentProducerTemplate>, InitializingBean, DisposableBean, ApplicationContextAware { @XmlTransient private ApplicationContext applicationContext; @Override protected CamelContext getCamelContextWithId(String camelContextId) { return CamelContextResolverHelper.getCamelContextWithId(applicationContext, camelContextId); } public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } }
/** * Configuration of redelivery policy. * * @version */ @Metadata(label = "spring,configuration") @XmlRootElement(name = "redeliveryPolicyProfile") @XmlAccessorType(XmlAccessType.FIELD) public class CamelRedeliveryPolicyFactoryBean extends AbstractCamelRedeliveryPolicyFactoryBean implements FactoryBean<RedeliveryPolicy>, ApplicationContextAware { @XmlTransient private ApplicationContext applicationContext; @Override protected CamelContext getCamelContextWithId(String camelContextId) { return CamelContextResolverHelper.getCamelContextWithId(applicationContext, camelContextId); } public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } }
/** * Configuration of thread pools * * @version */ @Metadata(label = "spring,configuration") @XmlRootElement(name = "threadPool") @XmlAccessorType(XmlAccessType.FIELD) public class CamelThreadPoolFactoryBean extends AbstractCamelThreadPoolFactoryBean implements FactoryBean<ExecutorService>, ApplicationContextAware { @XmlTransient private ApplicationContext applicationContext; @Override protected CamelContext getCamelContextWithId(String camelContextId) { return CamelContextResolverHelper.getCamelContextWithId(applicationContext, camelContextId); } public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } }
/** * Configures a {@link ConsumerTemplate} * * @version */ @Metadata(label = "spring,configuration") @XmlRootElement(name = "consumerTemplate") @XmlAccessorType(XmlAccessType.FIELD) public class CamelConsumerTemplateFactoryBean extends AbstractCamelConsumerTemplateFactoryBean implements FactoryBean<ConsumerTemplate>, InitializingBean, DisposableBean, ApplicationContextAware { @XmlTransient private ApplicationContext applicationContext; @Override protected CamelContext getCamelContextWithId(String camelContextId) { return CamelContextResolverHelper.getCamelContextWithId(applicationContext, camelContextId); } public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } }
@Metadata(label = "spring,configuration,rest") @XmlRootElement(name = "restContext") @XmlAccessorType(XmlAccessType.FIELD)
@Metadata(label = "spring,configuration,routing") @XmlRootElement(name = "routeContext") @XmlAccessorType(XmlAccessType.FIELD)