本文整理汇总了Java中org.wildfly.extension.camel.CamelContextRegistry类的典型用法代码示例。如果您正苦于以下问题:Java CamelContextRegistry类的具体用法?Java CamelContextRegistry怎么用?Java CamelContextRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CamelContextRegistry类属于org.wildfly.extension.camel包,在下文中一共展示了CamelContextRegistry类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例7: lookup
import org.wildfly.extension.camel.CamelContextRegistry; //导入依赖的package包/类
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
if (serviceInstance.get() == null) {
CamelContextRegistry service = ServiceLocator.getRequiredService(CamelContextRegistry.class);
serviceProducer.set(service);
}
return serviceInstance.get();
}
示例8: start
import org.wildfly.extension.camel.CamelContextRegistry; //导入依赖的package包/类
@Override
public void start(StartContext startContext) throws StartException {
ContextCreateHandlerRegistry handlerRegistry = injectedHandlerRegistry.getValue();
ServiceRegistry serviceRegistry = startContext.getController().getServiceContainer();
contextRegistry = new CamelContextRegistryImpl(handlerRegistry, serviceRegistry, startContext.getChildTarget());
// Register the service with gravia
Runtime runtime = injectedRuntime.getValue();
ModuleContext syscontext = runtime.getModuleContext();
registration = syscontext.registerService(CamelContextRegistry.class, contextRegistry, null);
for (final String name : subsystemState.getContextDefinitionNames()) {
createCamelContext(name, subsystemState.getContextDefinition(name));
}
}
示例9: createCamelContext
import org.wildfly.extension.camel.CamelContextRegistry; //导入依赖的package包/类
public void createCamelContext(String name, String contextDefinition) {
ClassLoader classLoader = CamelContextRegistry.class.getClassLoader();
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(classLoader);
String beansXML = getBeansXML(name, contextDefinition);
for (CamelContext camelctx : SpringCamelContextFactory.createCamelContextList(beansXML.getBytes(), classLoader)) {
camelctx.start();
}
} catch (Exception ex) {
throw new IllegalStateException("Cannot create camel context: " + name, ex);
} finally {
Thread.currentThread().setContextClassLoader(tccl);
}
}
示例10: getContextRegistry
import org.wildfly.extension.camel.CamelContextRegistry; //导入依赖的package包/类
private CamelContextRegistry getContextRegistry() throws NamingException {
return (CamelContextRegistry) new InitialContext().lookup("java:jboss/camel/CamelContextRegistry");
}
开发者ID:wildfly-swarm-archive,项目名称:wildfly-swarm-camel,代码行数:4,代码来源:JPATransactionManagerIntegrationTest.java
示例11: getContextRegistry
import org.wildfly.extension.camel.CamelContextRegistry; //导入依赖的package包/类
private CamelContextRegistry getContextRegistry() throws NamingException {
return (CamelContextRegistry) new InitialContext().lookup("java:jboss/camel/CamelContextRegistry");
}
示例12: canProvide
import org.wildfly.extension.camel.CamelContextRegistry; //导入依赖的package包/类
@Override
public boolean canProvide(final Class<?> type) {
return CamelContextRegistry.class.isAssignableFrom(type);
}