当前位置: 首页>>代码示例>>Java>>正文


Java OsgiCamelContextPublisher类代码示例

本文整理汇总了Java中org.apache.camel.core.osgi.OsgiCamelContextPublisher的典型用法代码示例。如果您正苦于以下问题:Java OsgiCamelContextPublisher类的具体用法?Java OsgiCamelContextPublisher怎么用?Java OsgiCamelContextPublisher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OsgiCamelContextPublisher类属于org.apache.camel.core.osgi包,在下文中一共展示了OsgiCamelContextPublisher类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: afterPropertiesSet

import org.apache.camel.core.osgi.OsgiCamelContextPublisher; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    super.afterPropertiesSet();
    // setup the application context classloader with the bundle delegating classloader
    ClassLoader cl = new BundleDelegatingClassLoader(bundleContext.getBundle());
    LOG.debug("Set the application context classloader to: {}", cl);
    getContext().setApplicationContextClassLoader(cl);
    osgiCamelContextPublisher = new OsgiCamelContextPublisher(bundleContext);
    osgiCamelContextPublisher.start();
    getContext().getManagementStrategy().addEventNotifier(osgiCamelContextPublisher);
    try {
        getClass().getClassLoader().loadClass("org.osgi.service.event.EventAdmin");
        getContext().getManagementStrategy().addEventNotifier(new OsgiEventAdminNotifier(bundleContext));
    } catch (Throwable t) {
        // Ignore, if the EventAdmin package is not available, just don't use it
        LOG.debug("EventAdmin package is not available, just don't use it");
    }
    // ensure routes is setup
    setupRoutes();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:CamelContextFactoryBean.java

示例2: setupCamelContext

import org.apache.camel.core.osgi.OsgiCamelContextPublisher; //导入依赖的package包/类
protected void setupCamelContext(final BundleContext bundleContext, final String camelContextId) throws Exception {
    // Set up CamelContext
    if (camelContextId != null) {
        context.setNameStrategy(new ExplicitCamelContextNameStrategy(camelContextId));
    }
    // TODO: allow to configure these options and not hardcode
    context.setUseMDCLogging(true);
    context.setUseBreadcrumb(true);

    // Add routes
    for (RoutesBuilder route : getRouteBuilders()) {
        context.addRoutes(configure(context, route, log));
    }

    // ensure we publish this CamelContext to the OSGi service registry
    context.getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundleContext));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:AbstractCamelRunner.java

示例3: produce

import org.apache.camel.core.osgi.OsgiCamelContextPublisher; //导入依赖的package包/类
@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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:CamelContextOsgiProducer.java

示例4: produce

import org.apache.camel.core.osgi.OsgiCamelContextPublisher; //导入依赖的package包/类
@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;
}
 
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:23,代码来源:CamelContextOsgiProducer.java

示例5: maybeStart

import org.apache.camel.core.osgi.OsgiCamelContextPublisher; //导入依赖的package包/类
private void maybeStart() throws Exception {
    LOG.trace("maybeStart: {}", this);

    // allow to register the BluerintCamelContext eager in the OSGi Service Registry, which ex is needed
    // for unit testing with camel-test-blueprint
    boolean eager = "true".equalsIgnoreCase(System.getProperty("registerBlueprintCamelContextEager"));
    if (eager) {
        for (EventNotifier notifier : getManagementStrategy().getEventNotifiers()) {
            if (notifier instanceof OsgiCamelContextPublisher) {
                OsgiCamelContextPublisher publisher = (OsgiCamelContextPublisher) notifier;
                publisher.registerCamelContext(this);
                break;
            }
        }
    }

    // for example from unit testing we want to start Camel later and not
    // when blueprint loading the bundle
    boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
    if (skip) {
        LOG.trace("maybeStart: {} is skipping as System property skipStartingCamelContext is set", this);
        return;
    }

    if (!isStarted() && !isStarting()) {
        LOG.debug("Starting {}", this);
        start();
    } else {
        // ignore as Camel is already started
        LOG.trace("Ignoring maybeStart() as {} is already started", this);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:BlueprintCamelContext.java

示例6: afterPropertiesSet

import org.apache.camel.core.osgi.OsgiCamelContextPublisher; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    super.afterPropertiesSet();
    getContext().getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundleContext));
    try {
        getClass().getClassLoader().loadClass("org.osgi.service.event.EventAdmin");
        getContext().getManagementStrategy().addEventNotifier(new OsgiEventAdminNotifier(bundleContext));
    } catch (Throwable t) {
        // Ignore, if the EventAdmin package is not available, just don't use it
        LOG.debug("EventAdmin package is not available, just don't use it");
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:CamelContextFactoryBean.java

示例7: OsgiSwitchYardCamelContextImpl

import org.apache.camel.core.osgi.OsgiCamelContextPublisher; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:11,代码来源:OsgiSwitchYardCamelContextImpl.java


注:本文中的org.apache.camel.core.osgi.OsgiCamelContextPublisher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。