當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultCamelContext.addRoutes方法代碼示例

本文整理匯總了Java中org.apache.camel.impl.DefaultCamelContext.addRoutes方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultCamelContext.addRoutes方法的具體用法?Java DefaultCamelContext.addRoutes怎麽用?Java DefaultCamelContext.addRoutes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.camel.impl.DefaultCamelContext的用法示例。


在下文中一共展示了DefaultCamelContext.addRoutes方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testDupeNameMultiContext

import org.apache.camel.impl.DefaultCamelContext; //導入方法依賴的package包/類
@Test
public void testDupeNameMultiContext() 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+*+*+*+*+?").to("log:one", "mock:one");
        }
    });
    camel1.start();

    camel2 = new DefaultCamelContext();
    camel2.setName("camel-2");
    camel2.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("quartz2://myGroup/myTimerName=0/2+*+*+*+*+?").to("log:two", "mock:two");
        }
    });
    camel2.start();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:23,代碼來源:QuartzNameCollisionTest.java

示例2: createRegistry

import org.apache.camel.impl.DefaultCamelContext; //導入方法依賴的package包/類
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();

    // let's create our black box as a Camel context and a set of routes
    DefaultCamelContext blackBox = new DefaultCamelContext(registry);
    blackBox.setName("blackBox");
    blackBox.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // we received purchase orders, so let's process it in some way then
            // send an invoice to our invoice endpoint
            from("direct:purchaseOrder").setHeader("received").constant("true").to("direct:invoice");
        }
    });
    blackBox.start();

    registry.bind("accounts", blackBox);
    return registry;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:21,代碼來源:JavaDslBlackBoxTest.java

示例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("quartz://myGroup/myTimerName?cron=0/1+*+*+*+*+?").to("mock:one");
        }
    });
    camel1.start();

    camel2 = new DefaultCamelContext();
    camel2.setName("camel-2");
    camel2.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("quartz://myOtherGroup/myOtherTimerName?cron=0/1+*+*+*+*+?").to("mock:two");
        }
    });
    camel2.start();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:23,代碼來源:QuartzTwoCamelContextTest.java

示例4: setUp

import org.apache.camel.impl.DefaultCamelContext; //導入方法依賴的package包/類
@Override
@Before
protected void setUp() throws Exception {
    super.setUp();

    context2 = new DefaultCamelContext();
    template2 = context2.createProducerTemplate();

    ServiceHelper.startServices(template2, context2);

    // add routes after CamelContext has been started
    RouteBuilder routeBuilder = createRouteBuilderForSecondContext();
    if (routeBuilder != null) {
        context2.addRoutes(routeBuilder);
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:AbstractDirectVmTestSupport.java

示例5: setUp

import org.apache.camel.impl.DefaultCamelContext; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    camel1 = new DefaultCamelContext();
    camel1.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").to("direct:foo");
            from("direct:foo").to("mock:a");
        }
    });
    camel1.start();

    camel2 = new DefaultCamelContext();
    camel2.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").to("direct:foo");
            from("direct:foo").to("mock:b");
        }
    });
    camel2.start();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:24,代碼來源:TwoCamelContextDirectEndpointTest.java

示例6: testThirdCamelContext

import org.apache.camel.impl.DefaultCamelContext; //導入方法依賴的package包/類
@Test
public void testThirdCamelContext() throws Exception {
    camel1.stop();
    
    camel2.stop();
            
    DefaultCamelContext camel3 = new DefaultCamelContext();
    camel3.setName("camel-3");
    camel3.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("quartz2://myThirdGroup/myThirdTimerName?cron=0/1+*+*+*+*+?").to("mock:three");
        }
    });
    camel3.start();
    
    MockEndpoint mock3 = camel3.getEndpoint("mock:three", MockEndpoint.class);
    mock3.expectedMinimumMessageCount(2);
    
    mock3.assertIsSatisfied();
    camel3.stop();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:23,代碼來源:QuartzTwoCamelContextTest.java

示例7: testRestart

import org.apache.camel.impl.DefaultCamelContext; //導入方法依賴的package包/類
/**
 * Make sure a resume doesn't trigger a dupe name error.
 */
@Test
public void testRestart() throws Exception {
    DefaultCamelContext camel = new DefaultCamelContext();

    camel.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("quartz2://myGroup/myTimerName?cron=0/1+*+*+*+*+?").to("log:one", "mock:one");
        }
    });

    // traverse a litany of states
    camel.start();
    Thread.sleep(100);
    camel.suspend();
    Thread.sleep(100);
    camel.resume();
    Thread.sleep(100);
    camel.stop();
    Thread.sleep(100);
    camel.start();
    Thread.sleep(100);
    camel.stop();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:28,代碼來源:QuartzNameCollisionTest.java

示例8: assertRoutes

import org.apache.camel.impl.DefaultCamelContext; //導入方法依賴的package包/類
protected XmlModel assertRoutes(File file, int expected, String ns) throws Exception {
    if (ns == null || ns.trim().length() == 0) {
        ns = CamelNamespaces.springNS;
    }
    XmlModel x = assertLoadModel(file, expected);

    // now lets add a route and write it back again...
    DefaultCamelContext tmpContext = new DefaultCamelContext();
    tmpContext.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("seda:newFrom").to("seda:newTo");
        }
    });
    x.getContextElement().getRoutes().addAll(tmpContext.getRouteDefinitions());

    List<RouteDefinition> routes = x.getRouteDefinitionList();
    assertEquals("routes: " + routes, expected + 1, routes.size());

    // now lets write to XML      model
    outDir.mkdirs();
    File outFile = new File(outDir, file.getName());
    System.out.println("Generating file: " + outFile);
    tool.marshal(outFile, x);

    assertFileExists(outFile);

    // lets check the file has the correct namespace inside it
    String text = FileCopyUtils.copyToString(new FileReader(outFile));
    assertTrue("Namespace " + ns + " not present in output file\n" + text, text.contains(ns));

    return x;
}
 
開發者ID:fabric8io,項目名稱:fabric8-forge,代碼行數:34,代碼來源:RouteXmlTestSupport.java

示例9: testProducer

import org.apache.camel.impl.DefaultCamelContext; //導入方法依賴的package包/類
public void testProducer() throws Exception {
    // use shutdown hook to verify that we have stopped within 5 seconds
    Thread hook = new AssertShutdownHook();
    Runtime.getRuntime().addShutdownHook(hook);

    start = System.currentTimeMillis();

    context = new DefaultCamelContext();
    context.addRoutes(createRouteBuilder());
    context.start();

    sendMessage();

    context.stop();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:16,代碼來源:Mina2ProducerShutdownTest.java

示例10: setUp

import org.apache.camel.impl.DefaultCamelContext; //導入方法依賴的package包/類
@Override
@Before
protected void setUp() throws Exception {
    super.setUp();
    context2 = new DefaultCamelContext();
    template2 = context2.createProducerTemplate();
    
    ServiceHelper.startServices(template2, context2);

    // add routes after CamelContext has been started
    RouteBuilder routeBuilder = createRouteBuilderForSecondContext();
    if (routeBuilder != null) {
        context2.addRoutes(routeBuilder);
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:16,代碼來源:AbstractVmTestSupport.java

示例11: 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();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:29,代碼來源:QuartzComponentCamelContextSharedSchedulerTest.java

示例12: 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);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:36,代碼來源:QuartzNameCollisionTest.java

示例13: 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("quartz://myGroup/myTimerName?cron=0/1+*+*+*+*+?").to("mock:one");
        }
    });
    camel1.start();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:13,代碼來源:QuartzOneCamelContextSuspendResumeTest.java

示例14: run

import org.apache.camel.impl.DefaultCamelContext; //導入方法依賴的package包/類
public void run() throws Exception {        
    DefaultCamelContext context = new DefaultCamelContext();
    
    final CountDownLatch logoutLatch = new CountDownLatch(1);
    
    RouteBuilder routes = new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // Modify the outgoing logon message to add a password
            // The modified message will be sent from the FIX engine when the message exchange completes
            from("quickfix:examples/inprocess.cfg?sessionID=FIX.4.2:TRADER->MARKET").
                filter(PredicateBuilder.and(
                        header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.AdminMessageSent),
                        header(QuickfixjEndpoint.MESSAGE_TYPE_KEY).isEqualTo(MsgType.LOGON))).
                bean(new CredentialInjector("PASSWORD"));

            // Release latch when the trader received a logout message
            from("quickfix:examples/inprocess.cfg?sessionID=FIX.4.2:TRADER->MARKET").
                filter(header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.SessionLogoff)).
                bean(new CountDownLatchDecrementer("logout", logoutLatch));

            // Reject all logons on market side
            // Demonstrates how to validate logons
            from("quickfix:examples/inprocess.cfg?sessionID=FIX.4.2:MARKET->TRADER").
                filter(PredicateBuilder.and(
                        header(QuickfixjEndpoint.EVENT_CATEGORY_KEY).isEqualTo(QuickfixjEventCategory.AdminMessageReceived),
                        header(QuickfixjEndpoint.MESSAGE_TYPE_KEY).isEqualTo(MsgType.LOGON))).
                bean(new LogonAuthenticator());
        }
    };
    
    context.addRoutes(routes);
    
    LOG.info("Starting Camel context");
    context.start();
    
    if (!logoutLatch.await(5L, TimeUnit.SECONDS)) {
        throw new IllegalStateException("Logout was not received");
    }
            
    context.stop();
    
    LOG.info("Example complete");
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:45,代碼來源:AuthenticationExample.java

示例15: test

import org.apache.camel.impl.DefaultCamelContext; //導入方法依賴的package包/類
@Test
public void test() throws Exception {

    if (!OS.isFamilyUnix()) {
        System.err.println("The test 'CamelExecTest' does not support the following OS : " + System.getProperty("os.name"));
        return;
    }

    String tempFilePath = tempDir.getAbsolutePath() + "/" + tempFileName;

    final File script = File.createTempFile("script", ".sh", tempDir);

    writeScript(script);

    final String exec = "bash?args=" + script.getAbsolutePath() + " " + tempFilePath + "&outFile=" + tempFilePath;

    DefaultCamelContext context = new DefaultCamelContext();
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:source")
                    .to("file:" + tempDir.getAbsolutePath() + "?fileName=" + tempFileName)
                    .to("exec:" + exec)
                    .process(new Processor() {
                        @Override
                        public void process(Exchange exchange) throws Exception {
                            String output = exchange.getIn().getBody(String.class);
                            assertEquals("hello world\n", output);
                        }
                    });

        }
    });

    context.start();

    ProducerTemplate pt = context.createProducerTemplate();
    String payload = "hello";

    pt.sendBody("direct:source", payload);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:42,代碼來源:ExecJava8IssueTest.java


注:本文中的org.apache.camel.impl.DefaultCamelContext.addRoutes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。