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


Java CamelContext.addComponent方法代碼示例

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


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

示例1: shouldMetadata

import org.apache.camel.CamelContext; //導入方法依賴的package包/類
@Test
public void shouldMetadata() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    context.addComponent("petstore", new PetstoreComponent(PAYLOAD));

    try {
        context.start();

        final PetstoreAdapter adapter = new PetstoreAdapter(PAYLOAD, PROPERTIES, INPUT, OUTPUT);
        final ActionDefinitionEndpoint endpoint = new ActionDefinitionEndpoint(context, "petstore", adapter);
        final SyndesisMetadata<?> metadata = endpoint.definition("dog-food", Collections.emptyMap());

        assertThat(metadata.properties).isSameAs(PROPERTIES);
        assertThat(metadata.inputSchema).isSameAs(INPUT);
        assertThat(metadata.outputSchema).isSameAs(OUTPUT);
    } finally {
        context.stop();
    }
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:20,代碼來源:ActionDefinitionEndpointTest.java

示例2: createCamelContext

import org.apache.camel.CamelContext; //導入方法依賴的package包/類
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();

    // set up the component so the data source is built using
    // test properties
    SqlStoredStartConnectorComponent component = new SqlStoredStartConnectorComponent();
    component.addOption("user", properties.getProperty("sql-connector.user"));
    component.addOption("password", properties.getProperty("sql-connector.password"));
    component.addOption("url", properties.getProperty("sql-connector.url"));

    // bind the component to the camel context
    context.addComponent("sql-stored-start-connector", component);

    return context;
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:17,代碼來源:SqlStoredStartConnectorComponentTest.java

示例3: createCamelContext

import org.apache.camel.CamelContext; //導入方法依賴的package包/類
protected CamelContext createCamelContext() throws Exception {
  CamelContext camelContext = super.createCamelContext();

  ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
  camelContext
      .addComponent("activemq", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));

  return camelContext;
}
 
開發者ID:eXcellme,項目名稱:eds,代碼行數:10,代碼來源:ActiveMQWithCamelTest.java

示例4: createCamelContext

import org.apache.camel.CamelContext; //導入方法依賴的package包/類
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();

    SqlStoredConnectorComponent component = new SqlStoredConnectorComponent();
    component.addOption("user", properties.getProperty("sql-connector.user"));
    component.addOption("password", properties.getProperty("sql-connector.password"));
    component.addOption("url", properties.getProperty("sql-connector.url"));

    // bind the component to the camel context
    context.addComponent("sql-stored-connector", component);

    return context;
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:15,代碼來源:SqlStoredConnectorComponentTest.java

示例5: camelConnectorTest

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

    Statement stmt = connection.createStatement();
    String createTable = "CREATE TABLE NAME (id INTEGER PRIMARY KEY, firstName VARCHAR(255), " + 
                         "lastName VARCHAR(255))"; 
    stmt.executeUpdate(createTable);
    stmt.executeUpdate("INSERT INTO NAME VALUES (1, 'Joe', 'Jackson')");
    stmt.executeUpdate("INSERT INTO NAME VALUES (2, 'Roger', 'Waters')");
    int numberOfRecords = 2;

    CamelContext context = new DefaultCamelContext();

    SqlStartConnectorComponent component = new SqlStartConnectorComponent();
    component.addOption("user", properties.getProperty("sql-connector.user"));
    component.addOption("password", properties.getProperty("sql-connector.password"));
    component.addOption("url", properties.getProperty("sql-connector.url"));

    // bind the component to the camel context
    context.addComponent("sql-start-connector", component);

    CountDownLatch latch = new CountDownLatch(numberOfRecords);
    final Result result = new Result();

    try {
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("sql-start-connector:SELECT * FROM NAME ORDER BY id?schedulerPeriod=31000")
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange)
                            throws Exception {
                        result.add(exchange.getIn().getBody(String.class));
                        latch.countDown();
                    }
                }).to("stream:out");
            }
        });
        context.start();
        latch.await(30l,TimeUnit.SECONDS);
        Assert.assertEquals(numberOfRecords, result.getJsonBeans().size());
        Collection<Object> values = new ArrayList<>();
        for (String  jsonBean: result.getJsonBeans()) {
            values.addAll(JSONBeanUtil.parsePropertiesFromJSONBean(jsonBean).values());
        }
        Assert.assertTrue(values.contains("1"));
        Assert.assertTrue(values.contains("2"));
    } finally {
        context.stop();
    }
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:53,代碼來源:SqlStartConnectorComponentTest.java

示例6: camelConnectorTest

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

    Statement stmt = connection.createStatement();
    String createTable = "CREATE TABLE NAME (id INTEGER PRIMARY KEY, firstName VARCHAR(255), " +
                         "lastName VARCHAR(255))";
    stmt.executeUpdate(createTable);
    stmt.executeUpdate("INSERT INTO NAME VALUES (1, 'Joe', 'Jackson')");
    stmt.executeUpdate("INSERT INTO NAME VALUES (2, 'Roger', 'Waters')");

    CamelContext context = new DefaultCamelContext();

    SqlConnectorComponent component = new SqlConnectorComponent();
    component.addOption("user", properties.getProperty("sql-connector.user"));
    component.addOption("password", properties.getProperty("sql-connector.password"));
    component.addOption("url", properties.getProperty("sql-connector.url"));

    // bind the component to the camel context
    context.addComponent("sql-connector", component);

    CountDownLatch latch = new CountDownLatch(1);
    final Result result = new Result();

    try {
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("timer://myTimer?period=2000")
                .to("sql-connector:SELECT * FROM NAME ORDER BY id")
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange)
                            throws Exception {
                        result.setJsonBean(exchange.getIn().getBody(String.class));
                        latch.countDown();
                    }
                }).to("stream:out");
            }
        });
        context.start();
        latch.await(30l,TimeUnit.SECONDS);
        Properties props = JSONBeanUtil.parsePropertiesFromJSONBean(result.getJsonBean());
        Assert.assertTrue(props.getProperty("ID").equals("1") || props.getProperty("ID").equals("2"));
    } finally {
        context.stop();
    }
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:48,代碼來源:SqlConnectorComponentTest.java

示例7: camelConnectorInputParamTest

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

    Statement stmt = connection.createStatement();

    String createTable = "CREATE TABLE ALLTYPES (charType CHAR, varcharType VARCHAR(255), " +
            "numericType NUMERIC, decimalType DECIMAL, smallType SMALLINT," +
            "dateType DATE, timeType TIME )";
    stmt.executeUpdate(createTable);

    CamelContext context = new DefaultCamelContext();

    SqlConnectorComponent component = new SqlConnectorComponent();
    component.addOption("user", properties.getProperty("sql-connector.user"));
    component.addOption("password", properties.getProperty("sql-connector.password"));
    component.addOption("url", properties.getProperty("sql-connector.url"));

    // bind the component to the camel context
    context.addComponent("sql-connector", component);

    CountDownLatch latch = new CountDownLatch(1);

    final Result result = new Result();

    Map<String,Object> values = new HashMap<>();
    values.put("CHARVALUE", SqlSampleValue.charValue);
    values.put("VARCHARVALUE", SqlSampleValue.stringValue);
    values.put("NUMERICVALUE", SqlSampleValue.decimalValue);
    values.put("DECIMALVALUE", SqlSampleValue.decimalValue);
    values.put("SMALLINTVALUE", SqlSampleValue.integerValue);

    String jsonBody = JSONBeanUtil.toJSONBean(values);

    final String insertStatement = "INSERT INTO ALLTYPES "
            + "(charType, varcharType, numericType, decimalType, smallType) VALUES "
            + "(:#CHARVALUE, :#VARCHARVALUE, :#NUMERICVALUE, :#DECIMALVALUE, :#SMALLINTVALUE)";
    SqlStatementParser parser = new SqlStatementParser(connection, schema, insertStatement);
    parser.parse();

    try {
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("timer://myTimer?period=2000")
                .setBody().constant(jsonBody)
                .to("sql-connector:" + insertStatement)
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange)
                            throws Exception {
                        result.setJsonBean(exchange.getIn().getBody(String.class));
                        latch.countDown();
                    }
                }).to("stream:out");
            }
        });
        context.start();
        latch.await(5l,TimeUnit.SECONDS);
        Properties props = JSONBeanUtil.parsePropertiesFromJSONBean(result.getJsonBean());
        Assert.assertEquals(values.size(),props.size());
    } finally {
        context.stop();
    }
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:65,代碼來源:SqlConnectorComponentTest.java


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