本文整理匯總了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);
}