本文整理汇总了Java中org.apache.camel.impl.DefaultCamelContext.getComponent方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultCamelContext.getComponent方法的具体用法?Java DefaultCamelContext.getComponent怎么用?Java DefaultCamelContext.getComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.impl.DefaultCamelContext
的用法示例。
在下文中一共展示了DefaultCamelContext.getComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@PostConstruct
public void start() throws Exception {
camel = new DefaultCamelContext();
camel.start();
final Component component = camel.getComponent(getConnectorAction(), true, false);
if (component == null) {
log.error("Component {} does not exist", getConnectorAction());
} else {
verifier = component.getExtension(verifierExtensionClass).orElse(null);
if (verifier == null) {
log.warn("Component {} does not support verifier extension", getConnectorAction());
}
}
}
示例2: testRemoveJob
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
/**
* Confirm the quartz trigger is removed on route stop.
*/
@Test
public void testRemoveJob() throws Exception {
camel1 = new DefaultCamelContext();
camel1.setName("camel-1");
camel1.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz2://myGroup/myTimerName?cron=0/1+*+*+*+*+?").id("route-1").to("log:one", "mock:one");
}
});
camel1.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz2://myGroup2/myTimerName?cron=0/1+*+*+*+*+?").id("route-2").to("log:one", "mock:one");
}
});
camel1.start();
QuartzComponent component = (QuartzComponent) camel1.getComponent("quartz2");
Scheduler scheduler = component.getScheduler();
TriggerKey triggerKey = TriggerKey.triggerKey("myTimerName", "myGroup");
Trigger trigger = scheduler.getTrigger(triggerKey);
Assert.assertNotNull(trigger);
camel1.stopRoute("route-1");
Trigger.TriggerState triggerState = component.getScheduler().getTriggerState(triggerKey);
Assert.assertNotNull(trigger);
Assert.assertEquals(Trigger.TriggerState.PAUSED, triggerState);
}
示例3: setUp
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
camel1 = new DefaultCamelContext();
camel1.setName("camel-1");
camel1.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz2://myGroup/myTimerName?cron=0/2+*+*+*+*+?").to("mock:one");
}
});
camel1.start();
camel2 = new DefaultCamelContext();
camel2.setName("camel-2");
Scheduler camel1Scheduler = camel1.getComponent("quartz2", QuartzComponent.class).getScheduler();
QuartzComponent camel2QuartzComponent = camel2.getComponent("quartz2", QuartzComponent.class);
camel2QuartzComponent.setScheduler(camel1Scheduler);
camel2.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz2://myOtherGroup/myOtherTimerName?cron=0/1+*+*+*+*+?").to("mock:two");
}
});
camel2.start();
}
示例4: testRemoveJob
import org.apache.camel.impl.DefaultCamelContext; //导入方法依赖的package包/类
/**
* Confirm the quartz trigger is removed on route stop.
*/
@Test
public void testRemoveJob() throws Exception {
camel1 = new DefaultCamelContext();
camel1.setName("camel-1");
camel1.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz://myGroup/myTimerName?cron=0/1+*+*+*+*+?").id("route-1").to("log:one", "mock:one");
}
});
camel1.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz://myGroup2/myTimerName?cron=0/1+*+*+*+*+?").id("route-2").to("log:one", "mock:one");
}
});
camel1.start();
QuartzComponent component = (QuartzComponent) camel1.getComponent("quartz");
Scheduler scheduler = component.getScheduler();
Trigger trigger = scheduler.getTrigger("myTimerName", "myGroup");
Assert.assertNotNull(trigger);
camel1.stopRoute("route-1");
int triggerState = component.getScheduler().getTriggerState("myTimerName", "myGroup");
Assert.assertNotNull(trigger);
Assert.assertEquals(Trigger.STATE_PAUSED, triggerState);
}