Search in sources :

Example 1 with CompositeRegistry

use of org.apache.camel.impl.CompositeRegistry in project camel by apache.

the class OsgiCamelContextHelper method wrapRegistry.

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;
}
Also used : CompositeRegistry(org.apache.camel.impl.CompositeRegistry)

Example 2 with CompositeRegistry

use of org.apache.camel.impl.CompositeRegistry in project camel by apache.

the class Main method getCamelContextMap.

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;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CompositeRegistry(org.apache.camel.impl.CompositeRegistry) HashMap(java.util.HashMap) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Aggregations

CompositeRegistry (org.apache.camel.impl.CompositeRegistry)2 HashMap (java.util.HashMap)1 CamelContext (org.apache.camel.CamelContext)1 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)1