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


Java DefaultCamelContextNameStrategy类代码示例

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


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

示例1: testTwoManagedCamelContextClash

import org.apache.camel.impl.DefaultCamelContextNameStrategy; //导入依赖的package包/类
public void testTwoManagedCamelContextClash() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }

    camel1 = createCamelContext();
    camel1.start();
    assertTrue("Should be started", camel1.getStatus().isStarted());

    MBeanServer mbeanServer = camel1.getManagementStrategy().getManagementAgent().getMBeanServer();
    ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + camel1.getManagementName() + ",type=context,name=\"camel-1\"");
    assertTrue("Should be registered", mbeanServer.isRegistered(on));

    // now cheat and reset the counter so we can test for a clash
    DefaultCamelContextNameStrategy.setCounter(0);

    camel2 = createCamelContext();
    camel2.start();
    ObjectName on2 = ObjectName.getInstance("org.apache.camel:context=" + camel2.getManagementName() + ",type=context,name=\"camel-1\"");
    assertTrue("Should be registered", mbeanServer.isRegistered(on2));

    assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on));
    assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on2));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:TwoManagedCamelContextAutoAssignedNameClashTest.java

示例2: produce

import org.apache.camel.impl.DefaultCamelContextNameStrategy; //导入依赖的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

示例3: produce

import org.apache.camel.impl.DefaultCamelContextNameStrategy; //导入依赖的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

示例4: produce

import org.apache.camel.impl.DefaultCamelContextNameStrategy; //导入依赖的package包/类
@Override
public T produce(CreationalContext<T> ctx) {
    T context = super.produce(ctx);

    // Do not override the name if it's been already set (in the bean constructor for example)
    if (context.getNameStrategy() instanceof DefaultCamelContextNameStrategy) {
        context.setNameStrategy(nameStrategy(annotated));
    }

    // Add bean registry and Camel injector
    if (context instanceof DefaultCamelContext) {
        DefaultCamelContext adapted = context.adapt(DefaultCamelContext.class);
        adapted.setRegistry(new CdiCamelRegistry(manager));
        adapted.setInjector(new CdiCamelInjector(context.getInjector(), manager));
    } else {
        // Fail fast for the time being to avoid side effects by the time these two methods get declared on the CamelContext interface
        throw new InjectionException("Camel CDI requires Camel context [" + context.getName() + "] to be a subtype of DefaultCamelContext");
    }

    // Add event notifier if at least one observer is present
    Set<Annotation> qualifiers = annotated.getAnnotations().stream()
        .filter(isAnnotationType(Named.class).negate()
            .and(q -> manager.isQualifier(q.annotationType())))
        .collect(toSet());
    qualifiers.add(ANY);
    if (qualifiers.size() == 1) {
        qualifiers.add(DEFAULT);
    }
    qualifiers.retainAll(extension.getObserverEvents());
    if (!qualifiers.isEmpty()) {
        context.getManagementStrategy().addEventNotifier(new CdiEventNotifier(manager, qualifiers));
    }

    return context;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:36,代码来源:CamelContextProducer.java

示例5: produce

import org.apache.camel.impl.DefaultCamelContextNameStrategy; //导入依赖的package包/类
@Override
public T produce(CreationalContext<T> cc) {
    T context = super.produce(cc);

    // Do not override the name if it's been already set (in the bean constructor for example)
    if (context.getNameStrategy() instanceof DefaultCamelContextNameStrategy)
        context.setNameStrategy(nameStrategy(annotated));

    // Add bean registry and Camel injector
    if (context instanceof DefaultCamelContext) {
        DefaultCamelContext adapted = context.adapt(DefaultCamelContext.class);
        adapted.setRegistry(new CdiCamelRegistry(manager));
        adapted.setInjector(new CdiCamelInjector(context.getInjector(), manager));
    } else {
        // Fail fast for the time being to avoid side effects by the time these two methods get declared on the CamelContext interface
        throw new DeploymentException("Camel CDI requires Camel context [" + context.getName() + "] to be a subtype of DefaultCamelContext");
    }

    // Add event notifier if at least one observer is present
    Set<Annotation> qualifiers = annotated.getAnnotations().stream()
        .filter(isAnnotationType(Named.class).negate()
            .and(q -> manager.isQualifier(q.annotationType())))
        .collect(toSet());
    qualifiers.add(Any.Literal.INSTANCE);
    if (qualifiers.size() == 1)
        qualifiers.add(Default.Literal.INSTANCE);
    qualifiers.retainAll(manager.getExtension(CdiCamelExtension.class).getObserverEvents());
    if (!qualifiers.isEmpty())
        context.getManagementStrategy().addEventNotifier(new CdiEventNotifier(manager, qualifiers));

    return context;
}
 
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:33,代码来源:CamelContextProducer.java

示例6: setupCamelContext

import org.apache.camel.impl.DefaultCamelContextNameStrategy; //导入依赖的package包/类
@Override
protected void setupCamelContext(CamelContext camelContext) throws Exception {

	camelContext.setNameStrategy(new DefaultCamelContextNameStrategy("Gateway"));

}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:7,代码来源:CamelConfig.java


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