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


Java CamelContextRegistry.getCamelContext方法代码示例

本文整理汇总了Java中org.wildfly.extension.camel.CamelContextRegistry.getCamelContext方法的典型用法代码示例。如果您正苦于以下问题:Java CamelContextRegistry.getCamelContext方法的具体用法?Java CamelContextRegistry.getCamelContext怎么用?Java CamelContextRegistry.getCamelContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wildfly.extension.camel.CamelContextRegistry的用法示例。


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

示例1: performRuntime

import org.wildfly.extension.camel.CamelContextRegistry; //导入方法依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {

    String propName = operation.get(ModelDescriptionConstants.OP_ADDR).asObject().get(ModelConstants.CONTEXT).asString();
    String propValue = CamelContextResource.VALUE.resolveModelAttribute(context, model).asString();
    subsystemState.putContextDefinition(propName, propValue.trim());

    ServiceController<?> container = context.getServiceRegistry(false).getService(CamelConstants.CAMEL_CONTEXT_REGISTRY_SERVICE_NAME);
    if (container != null) {
        CamelContextRegistryService serviceRegistry = CamelContextRegistryService.class.cast(container.getService());
        CamelContextRegistry camelContextRegistry = serviceRegistry.getValue();
        if (camelContextRegistry != null) {
            if (camelContextRegistry.getCamelContext(propName) == null) {
                serviceRegistry.createCamelContext(propName, propValue);
            }
        }
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:19,代码来源:CamelContextAdd.java

示例2: testDeployedContext

import org.wildfly.extension.camel.CamelContextRegistry; //导入方法依赖的package包/类
@Test
public void testDeployedContext() throws Exception {

    CamelContextRegistry registry = ServiceLocator.getRequiredService(CamelContextRegistry.class);
    CamelContext camelctx = registry.getCamelContext("netty-context");
    Assert.assertNotNull("CamelContext not null", camelctx);
    Assert.assertEquals(ServiceStatus.Started, camelctx.getStatus());

    PollingConsumer pollingConsumer = camelctx.getEndpoint("seda:end").createPollingConsumer();
    pollingConsumer.start();

    Socket socket = new Socket(SOCKET_HOST, 7999);
    socket.setKeepAlive(true);
    PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

    try {
        out.write("Kermit\n");
    } finally {
        out.close();
        socket.close();
    }

    String result = pollingConsumer.receive().getIn().getBody(String.class);
    Assert.assertEquals("Hello Kermit", result);
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:26,代码来源:NettyIntegrationTest.java

示例3: testSimpleTransform

import org.wildfly.extension.camel.CamelContextRegistry; //导入方法依赖的package包/类
@Test
public void testSimpleTransform() throws Exception {

    CamelContextRegistry contextRegistry = ServiceLocator.getRequiredService(CamelContextRegistry.class);
    CamelContext camelctx = contextRegistry.getCamelContext("camel-1");
    Assert.assertEquals(CamelContextRegistry.class.getClassLoader(), camelctx.getApplicationContextClassLoader());
    Assert.assertEquals(ServiceStatus.Started, camelctx.getStatus());

    ProducerTemplate producer = camelctx.createProducerTemplate();
    String result = producer.requestBody("direct:start", "Kermit", String.class);
    Assert.assertEquals("Hello Kermit", result);
}
 
开发者ID:wildfly-swarm-archive,项目名称:wildfly-swarm-camel,代码行数:13,代码来源:SystemContextTransformTest.java

示例4: testMonitorMBeanAttribute

import org.wildfly.extension.camel.CamelContextRegistry; //导入方法依赖的package包/类
@Test
public void testMonitorMBeanAttribute() throws Exception {
    Context context = new InitialContext();
    CamelContextRegistry contextRegistry = (CamelContextRegistry) context.lookup("java:jboss/camel/CamelContextRegistry");

    CamelContext sysctx = contextRegistry.getCamelContext("camel-1");
    Assert.assertEquals(ServiceStatus.Started, sysctx.getStatus());
    final String routeName = sysctx.getRoutes().get(0).getId();

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("jmx:platform?format=raw&objectDomain=org.apache.camel&key.context=camel-1&key.type=routes&key.name=\"" + routeName + "\"" +
            "&monitorType=counter&observedAttribute=ExchangesTotal&granularityPeriod=500").
            to("direct:end");
        }
    });

    camelctx.start();
    try {
        ConsumerTemplate consumer = camelctx.createConsumerTemplate();
        MonitorNotification notifcation = consumer.receiveBody("direct:end", MonitorNotification.class);
        Assert.assertEquals("ExchangesTotal", notifcation.getObservedAttribute());
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-swarm-archive,项目名称:wildfly-swarm-camel,代码行数:29,代码来源:JMXIntegrationTest.java

示例5: testMonitorMBeanAttribute

import org.wildfly.extension.camel.CamelContextRegistry; //导入方法依赖的package包/类
@Test
public void testMonitorMBeanAttribute() throws Exception {
    Context context = new InitialContext();
    CamelContextRegistry contextRegistry = (CamelContextRegistry) context.lookup("java:jboss/camel/CamelContextRegistry");

    CamelContext sysctx = contextRegistry.getCamelContext("camel-1");
    Assert.assertEquals(ServiceStatus.Started, sysctx.getStatus());
    final String routeName = sysctx.getRoutes().get(0).getId();

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("jmx:platform?format=raw&objectDomain=org.apache.camel&key.context=camel-1&key.type=routes&key.name=\"" + routeName + "\"" +
                    "&monitorType=counter&observedAttribute=ExchangesTotal&granularityPeriod=500").
                    to("direct:end");
        }
    });

    camelctx.start();
    try {
        ConsumerTemplate consumer = camelctx.createConsumerTemplate();
        MonitorNotification notifcation = consumer.receiveBody("direct:end", MonitorNotification.class);
        Assert.assertEquals("ExchangesTotal", notifcation.getObservedAttribute());
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:29,代码来源:JMXIntegrationTest.java

示例6: testSimpleTransform

import org.wildfly.extension.camel.CamelContextRegistry; //导入方法依赖的package包/类
@Test
public void testSimpleTransform() throws Exception {

    CamelContextRegistry contextRegistry = ServiceLocator.getRequiredService(CamelContextRegistry.class);
    CamelContext camelctx = contextRegistry.getCamelContext("myname");
    Assert.assertEquals(ServiceStatus.Started, camelctx.getStatus());

    ProducerTemplate producer = camelctx.createProducerTemplate();
    String result = producer.requestBody("direct:start", "Kermit", String.class);
    Assert.assertEquals("Hello Kermit", result);
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:12,代码来源:SystemContextTransformTest.java


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