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

项目: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   
@Override
protected TypeConverter createTypeConverter() {
    // CAMEL-3614: make sure we use a bundle context which imports org.apache.camel.impl.converter package
    BundleContext ctx = BundleContextUtils.getBundleContext(getClass());
    if (ctx == null) {
        ctx = bundleContext;
    }
    FactoryFinder finder = new OsgiFactoryFinderResolver(bundleContext).resolveDefaultFactoryFinder(getClassResolver());
    return new OsgiTypeConverter(ctx, this, getInjector(), finder);
}
项目:Camel    文件:OsgiDefaultCamelContext.java   
@Override
protected TypeConverter createTypeConverter() {
    // CAMEL-3614: make sure we use a bundle context which imports org.apache.camel.impl.converter package
    BundleContext ctx = BundleContextUtils.getBundleContext(getClass());
    if (ctx == null) {
        ctx = bundleContext;
    }
    FactoryFinder finder = new OsgiFactoryFinderResolver(bundleContext).resolveDefaultFactoryFinder(getClassResolver());
    return new OsgiTypeConverter(ctx, this, getInjector(), finder);
}
项目:Camel    文件:OsgiSpringCamelContext.java   
@Override
protected TypeConverter createTypeConverter() {
    // CAMEL-3614: make sure we use a bundle context which imports org.apache.camel.impl.converter package
    BundleContext ctx = BundleContextUtils.getBundleContext(getClass());
    if (ctx == null) {
        ctx = bundleContext;
    }
    FactoryFinder finder = new OsgiFactoryFinderResolver(bundleContext).resolveDefaultFactoryFinder(getClassResolver());
    return new OsgiTypeConverter(ctx, this, getInjector(), finder);
}
项目:switchyard    文件:OsgiSwitchYardCamelContextImpl.java   
@Override
protected TypeConverter createTypeConverter() {
    // CAMEL-3614: make sure we use a bundle context which imports org.apache.camel.impl.converter package
    BundleContext ctx = BundleContextUtils.getBundleContext(getClass());
    if (ctx == null) {
        ctx = _bundleContext;
    }
    FactoryFinder finder = new OsgiFactoryFinderResolver(_bundleContext).resolveDefaultFactoryFinder(getClassResolver());
    return new OsgiTypeConverter(ctx, getInjector(), finder);
}
项目:Camel    文件:BlueprintCamelContext.java   
@Override
public Map<String, Properties> findComponents() throws LoadPropertiesException, IOException {
    return BundleContextUtils.findComponents(bundleContext, this);
}
项目:Camel    文件:BlueprintCamelContext.java   
@Override
public String getComponentDocumentation(String componentName) throws IOException {
    return BundleContextUtils.getComponentDocumentation(bundleContext, this, componentName);
}
项目:Camel    文件:CdiCamelEnvironment.java   
private static boolean hasBundleContext(Class clazz) {
    return BundleContextUtils.getBundleContext(clazz) != null;
}
项目:Camel    文件:OsgiDefaultCamelContext.java   
@Override
public Map<String, Properties> findComponents() throws LoadPropertiesException, IOException {
    return BundleContextUtils.findComponents(bundleContext, this);
}
项目:Camel    文件:OsgiDefaultCamelContext.java   
@Override
public String getComponentDocumentation(String componentName) throws IOException {
    return BundleContextUtils.getComponentDocumentation(bundleContext, this, componentName);
}
项目:camel-cdi    文件:CdiCamelEnvironment.java   
private static boolean hasBundleContext(Class clazz) {
    return BundleContextUtils.getBundleContext(clazz) != null;
}