@Override public T produce(CreationalContext<T> ctx) { T context = super.produce(ctx); // Register the context in the OSGi registry BundleContext bundle = BundleContextUtils.getBundleContext(getClass()); context.getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundle)); if (!(context instanceof DefaultCamelContext)) { // Fail fast for the time being to avoid side effects by some methods get declared on the CamelContext interface throw new InjectionException("Camel CDI requires Camel context [" + context.getName() + "] to be a subtype of DefaultCamelContext"); } DefaultCamelContext adapted = context.adapt(DefaultCamelContext.class); adapted.setRegistry(OsgiCamelContextHelper.wrapRegistry(context, context.getRegistry(), bundle)); CamelContextNameStrategy strategy = context.getNameStrategy(); OsgiCamelContextHelper.osgiUpdate(adapted, bundle); // FIXME: the above call should not override explicit strategies provided by the end user or should decorate them instead of overriding them completely if (!(strategy instanceof DefaultCamelContextNameStrategy)) { context.setNameStrategy(strategy); } return context; }
@Override public T produce(CreationalContext<T> cc) { T context = super.produce(cc); // Register the context in the OSGi registry BundleContext bundle = BundleContextUtils.getBundleContext(getClass()); context.getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundle)); if (!(context instanceof DefaultCamelContext)) // Fail fast for the time being to avoid side effects by some methods get declared on the CamelContext interface throw new DeploymentException("Camel CDI requires Camel context [" + context.getName() + "] to be a subtype of DefaultCamelContext"); DefaultCamelContext adapted = context.adapt(DefaultCamelContext.class); adapted.setRegistry(OsgiCamelContextHelper.wrapRegistry(context, context.getRegistry(), bundle)); CamelContextNameStrategy strategy = context.getNameStrategy(); OsgiCamelContextHelper.osgiUpdate(adapted, bundle); // FIXME: the above call should not override explicit strategies provided by the end user or should decorate them instead of overriding them completely if (!(strategy instanceof DefaultCamelContextNameStrategy)) context.setNameStrategy(strategy); return context; }
public BlueprintCamelContext(BundleContext bundleContext, BlueprintContainer blueprintContainer) { this.bundleContext = bundleContext; this.blueprintContainer = blueprintContainer; // inject common osgi OsgiCamelContextHelper.osgiUpdate(this, bundleContext); // and these are blueprint specific setComponentResolver(new BlueprintComponentResolver(bundleContext)); setLanguageResolver(new BlueprintLanguageResolver(bundleContext)); setDataFormatResolver(new BlueprintDataFormatResolver(bundleContext)); setApplicationContextClassLoader(new BundleDelegatingClassLoader(bundleContext.getBundle())); // must use classloader of the namespace handler setModelJAXBContextFactory(new BlueprintModelJAXBContextFactory(CamelNamespaceHandler.class.getClassLoader())); }
/** * Create a new instance of OsgiSwitchYardCamelContextImpl. * @param bundleContext bundleContext */ public OsgiSwitchYardCamelContextImpl(BundleContext bundleContext) { _bundleContext = bundleContext; OsgiCamelContextHelper.osgiUpdate(this, bundleContext); // Ensure we publish this CamelContext to the OSGi service registry getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundleContext)); }
@Override protected Registry createRegistry() { Registry reg = new BlueprintContainerRegistry(getBlueprintContainer()); return OsgiCamelContextHelper.wrapRegistry(this, reg, bundleContext); }
public OsgiSpringCamelContext(ApplicationContext applicationContext, BundleContext bundleContext) { super(applicationContext); this.bundleContext = bundleContext; OsgiCamelContextHelper.osgiUpdate(this, bundleContext); }
@Override protected Registry createRegistry() { return OsgiCamelContextHelper.wrapRegistry(this, super.createRegistry(), bundleContext); }
@Override protected CompositeRegistry createRegistry() { return (CompositeRegistry) OsgiCamelContextHelper.wrapRegistry(this, super.createRegistry(), _bundleContext); }