protected Map<String, CamelContext> getCamelContextMap() { Map<String, CamelContext> answer = new HashMap<String, CamelContext>(); CamelContext camelContext = createContext(); if (registry.size() > 0) { // set the registry through which we've already bound some beans if (DefaultCamelContext.class.isAssignableFrom(camelContext.getClass())) { CompositeRegistry compositeRegistry = new CompositeRegistry(); // make sure camel look up the Object from the registry first compositeRegistry.addRegistry(registry); // use the camel old registry as a fallback compositeRegistry.addRegistry(((DefaultCamelContext) camelContext).getRegistry()); ((DefaultCamelContext) camelContext).setRegistry(compositeRegistry); } } answer.put("camel-1", camelContext); return answer; }
protected CompositeRegistry createRegistry() { final ServiceLoader<Registry> registriesLoaders = ServiceLoader.load(Registry.class, getClass().getClassLoader()); final List<Registry> registries = new ArrayList<Registry>(); registries.add(new JndiRegistry()); if (isEnableCdiIntegration()) { registries.add(new CdiBeanRegistry()); } registries.add(_writeableRegistry); for (Registry registry : registriesLoaders) { registries.add(registry); } return new CompositeRegistry(registries); }
public static Registry wrapRegistry(CamelContext camelContext, Registry registry, BundleContext bundleContext) { ObjectHelper.notNull(bundleContext, "BundleContext"); LOG.debug("Setting up OSGi ServiceRegistry"); OsgiServiceRegistry osgiServiceRegistry = new OsgiServiceRegistry(bundleContext); // Need to clean up the OSGi service when camel context is closed. camelContext.addLifecycleStrategy(osgiServiceRegistry); CompositeRegistry compositeRegistry = new CompositeRegistry(); compositeRegistry.addRegistry(osgiServiceRegistry); compositeRegistry.addRegistry(registry); return compositeRegistry; }
@Provides @Singleton public CompositeRegistry getRegistry(Injector injector) { CompositeRegistry compositeRegistry = new CompositeRegistry(); compositeRegistry.addRegistry(new GuiceRegistry(injector)); Injector parentInjector = injector.getParent(); if (parentInjector != null) { GuiceRegistry parentRegistry = parentInjector.getInstance(GuiceRegistry.class); compositeRegistry.addRegistry(parentRegistry); } return compositeRegistry; }
@Override protected void configure() { bind(Registry.class).to(CompositeRegistry.class); }
@Override protected CompositeRegistry createRegistry() { return (CompositeRegistry) OsgiCamelContextHelper.wrapRegistry(this, super.createRegistry(), _bundleContext); }