Java 类org.apache.camel.core.osgi.OsgiCamelContextHelper 实例源码

项目:Camel    文件:CamelContextOsgiProducer.java   
@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;
}
项目:camel-cdi    文件:CamelContextOsgiProducer.java   
@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;
}
项目:Camel    文件:BlueprintCamelContext.java   
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()));
}
项目:switchyard    文件:OsgiSwitchYardCamelContextImpl.java   
/**
 * 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));
}
项目:Camel    文件:BlueprintCamelContext.java   
@Override
protected Registry createRegistry() {
    Registry reg = new BlueprintContainerRegistry(getBlueprintContainer());
    return OsgiCamelContextHelper.wrapRegistry(this, reg, bundleContext);
}
项目:Camel    文件:OsgiSpringCamelContext.java   
public OsgiSpringCamelContext(ApplicationContext applicationContext, BundleContext bundleContext) {
    super(applicationContext);
    this.bundleContext = bundleContext;
    OsgiCamelContextHelper.osgiUpdate(this, bundleContext);
}
项目:Camel    文件:OsgiSpringCamelContext.java   
@Override
protected Registry createRegistry() {
    return OsgiCamelContextHelper.wrapRegistry(this, super.createRegistry(), bundleContext);
}
项目:switchyard    文件:OsgiSwitchYardCamelContextImpl.java   
@Override
protected CompositeRegistry createRegistry() {
    return (CompositeRegistry) OsgiCamelContextHelper.wrapRegistry(this, super.createRegistry(), _bundleContext);
}