本文整理汇总了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);
}
}
}
}
示例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);
}
示例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);
}
示例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();
}
}
示例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();
}
}
示例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);
}