當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。