/** * Create the context */ protected SpringCamelContext createContext() { SpringCamelContext ctx = newCamelContext(); ctx.setName(getId()); return ctx; }
@Override protected void findRouteBuildersByContextScan(PackageScanFilter filter, boolean includeNonSingletons, List<RoutesBuilder> builders) throws Exception { ContextScanRouteBuilderFinder finder = new ContextScanRouteBuilderFinder(getContext(), filter, includeNonSingletons); finder.appendBuilders(builders); }
public ContextScanRouteBuilderFinder(SpringCamelContext camelContext, PackageScanFilter filter, boolean includeNonSingletons) { this.applicationContext = camelContext.getApplicationContext(); this.filter = filter; this.includeNonSingletons = includeNonSingletons; }
protected void doProcess(String arg, String parameter, LinkedList<String> remainingArgs) { setApplicationContextUri(parameter); } });
protected SpringCamelContext newCamelContext() { return new SpringCamelContext(getApplicationContext()); }
@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); }
public JAXBContext getJaxbContext() throws JAXBException { if (jaxbContext == null) { jaxbContext = new SpringModelJAXBContextFactory().newJAXBContext(); } return jaxbContext; }
protected void initCustomRegistry(SpringCamelContext context) { Registry registry = getBeanForType(Registry.class); if (registry != null) { LOG.info("Using custom Registry: {}", registry); context.setRegistry(registry); } }
@Override public void start() { try { setupRoutes(); } catch (Exception e) { throw wrapRuntimeCamelException(e); } // when the routes are setup we need to start the Camel context context.start(); }
public SpringCamelContext getContext(boolean create) { if (context == null && create) { context = createContext(); configure(context); } return context; }
@Override public void stop() { if (context != null) { context.stop(); } }
@Override protected ModelJAXBContextFactory createModelJAXBContextFactory() { return new SpringModelJAXBContextFactory(); }
@Override public boolean isRunning() { return !isStopping() && !isStopped(); }
protected void initBeanPostProcessor(SpringCamelContext context) { if (beanPostProcessor != null) { if (beanPostProcessor instanceof ApplicationContextAware) { ((ApplicationContextAware) beanPostProcessor).setApplicationContext(applicationContext); } if (beanPostProcessor instanceof CamelBeanPostProcessor) { ((CamelBeanPostProcessor) beanPostProcessor).setCamelContext(getContext()); } } }
@Override public void onApplicationEvent(final ContextRefreshedEvent event) { // start the CamelContext when the Spring ApplicationContext is // done initializing, as the last step in ApplicationContext // being started/refreshed, there could be a race condition with // other ApplicationListeners that react to // ContextRefreshedEvent but this is the best that we can do start(); }
protected void doProcess(String arg, String parameter, LinkedList<String> remainingArgs) { setFileApplicationContextUri(parameter); } });
@Override public boolean isRunning() { return context != null && context.isRunning(); }
public SpringCamelContext(ApplicationContext applicationContext) { setApplicationContext(applicationContext); }
protected EventEndpoint createEventEndpoint() { return getEndpoint("spring-event:default", EventEndpoint.class); }