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


Java DefaultCamelContext類代碼示例

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


DefaultCamelContext類屬於org.apache.camel.impl包,在下文中一共展示了DefaultCamelContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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());
        }

    }
}
 
開發者ID:syndesisio,項目名稱:syndesis-verifier,代碼行數:17,代碼來源:BaseVerifier.java

示例2: shouldMetadata

import org.apache.camel.impl.DefaultCamelContext; //導入依賴的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

示例3: ping

import org.apache.camel.impl.DefaultCamelContext; //導入依賴的package包/類
public void ping() throws Exception {
    // need to create Camel
    CamelContext camel = new DefaultCamelContext();

    // get the connector to use
    Component mention = camel.getComponent("salesforce-upsert-contact-connector");
    Optional<ComponentVerifierExtension> ext = mention.getExtension(ComponentVerifierExtension.class);

    // the connector must support ping check if its verifiable
    if (ext.isPresent()) {
        ComponentVerifierExtension verifier = ext.get();

        Map<String, Object> parameters = loadParameters();
        ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);

        System.out.println("=============================================");
        System.out.println("");
        System.out.println("Ping check result: " + result.getStatus());
        System.out.println("");
        System.out.println("=============================================");

    } else {
        System.out.println("Component does not support ping check");
    }
}
 
開發者ID:syndesisio,項目名稱:connectors,代碼行數:26,代碼來源:SalesforcePingCheck.java

示例4: ping

import org.apache.camel.impl.DefaultCamelContext; //導入依賴的package包/類
public void ping() throws Exception {
    // need to create Camel
    CamelContext camel = new DefaultCamelContext();

    // get the connector to use
    Component mention = camel.getComponent("twitter-mention-connector");
    Optional<ComponentVerifierExtension> ext = mention.getExtension(ComponentVerifierExtension.class);

    // the connector must support ping check if its verifiable
    if (ext.isPresent()) {
        ComponentVerifierExtension verifier = ext.get();
        Map<String, Object> parameters = loadParameters();
        ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);

        System.out.println("=============================================");
        System.out.println("");
        System.out.println("Ping check result: " + result.getStatus());
        System.out.println("");
        System.out.println("=============================================");

    } else {
        System.out.println("Component does not support ping check");
    }
}
 
開發者ID:syndesisio,項目名稱:connectors,代碼行數:25,代碼來源:TwitterPingCheck.java

示例5: ping

import org.apache.camel.impl.DefaultCamelContext; //導入依賴的package包/類
public void ping() throws Exception {
    // need to create Camel
    CamelContext camel = new DefaultCamelContext();

    // get the connector to use
    Component get = camel.getComponent("http-get-connector");
    Optional<ComponentVerifierExtension> ext = get.getExtension(ComponentVerifierExtension.class);

    // the connector must support ping check if its verifiable
    if (ext.isPresent()) {
        ComponentVerifierExtension verifier = ext.get();

        Map<String, Object> parameters = loadParameters();
        ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);

        System.out.println("=============================================");
        System.out.println("");
        System.out.println("Ping check result: " + result.getStatus());
        System.out.println("");
        System.out.println("=============================================");

    } else {
        System.out.println("Component does not support ping check");
    }
}
 
開發者ID:syndesisio,項目名稱:connectors,代碼行數:26,代碼來源:HttpPingCheck.java

示例6: testSDPParseOffer

import org.apache.camel.impl.DefaultCamelContext; //導入依賴的package包/類
@Test
public void testSDPParseOffer() throws Exception {
    Exchange ex = new DefaultExchange(new DefaultCamelContext());
    ex.getIn().setBody(offerSdp);
    processor.process(ex);
    assertEquals(ex.getIn().getBody().getClass(),Offer.class);

    Offer offer = (Offer)ex.getIn().getBody();

    MediaDescription mediaDescription = (MediaDescription) offer.getSdp().getMediaDescriptions(true).get(0);

    String icePwd = mediaDescription.getAttribute("ice-pwd");
    String iceUfrag = mediaDescription.getAttribute("ice-ufrag");
    String fingerprint = offer.getSdp().getAttribute("fingerprint");

    assertEquals(icePwd,"c490fef46f74bdbe64edd636bc49a259");
    assertEquals(iceUfrag,"64dc2277");
    assertEquals(fingerprint,"sha-256 99:45:B1:94:7E:97:AE:F2:A5:75:86:89:B5:AD:06:BB:63:02:FA:05:04:B2:83:1B:52:C9:EF:0E:61:8F:38:73");
}
 
開發者ID:IIlllII,項目名稱:bitbreeds-webrtc,代碼行數:20,代碼來源:ProcessSignalsTest.java

示例7: createCamelContext

import org.apache.camel.impl.DefaultCamelContext; //導入依賴的package包/類
@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("aggStrategy", AggregationStrategies.groupedExchange());

    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
    connectionFactory.setBrokerURL(broker.getTcpConnectorUri());

    SjmsComponent sjmsComponent = new SjmsComponent();
    sjmsComponent.setConnectionFactory(connectionFactory);

    SjmsBatchComponent sjmsBatchComponent = new SjmsBatchComponent();
    sjmsBatchComponent.setConnectionFactory(connectionFactory);

    CamelContext context = new DefaultCamelContext(registry);
    context.addComponent("sjms-batch", sjmsBatchComponent);
    context.addComponent("sjms", sjmsComponent);

    return context;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:21,代碼來源:SjmsBatchEndpointTest.java

示例8: doSignatureRouteTest

import org.apache.camel.impl.DefaultCamelContext; //導入依賴的package包/類
public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
    CamelContext context = new DefaultCamelContext();
    try {
        context.addRoutes(builder);
        context.start();

        MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
        mock.setExpectedMessageCount(1);

        ProducerTemplate template = context.createProducerTemplate();
        if (e != null) {
            template.send("direct:in", e);
        } else {
            template.sendBodyAndHeaders("direct:in", payload, headers);
        }
        assertMockEndpointsSatisfied();
        return mock.getReceivedExchanges().get(0);
    } finally {
        context.stop();
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:22,代碼來源:XmlSignatureTest.java

示例9: 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/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://myOtherGroup/myOtherTimerName?cron=0/1+*+*+*+*+?").to("log:two", "mock:two");
        }
    });
    camel2.start();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:23,代碼來源:QuartzTwoCamelContextRestartTest.java

示例10: execute

import org.apache.camel.impl.DefaultCamelContext; //導入依賴的package包/類
@Test
public void execute() throws Exception {
    Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
    exchange.getIn().setHeader(SmppConstants.COMMAND, "DataSm");
    exchange.getIn().setHeader(SmppConstants.SERVICE_TYPE, "XXX");
    exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_TON, TypeOfNumber.NATIONAL.value());
    exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_NPI, NumberingPlanIndicator.NATIONAL.value());
    exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR, "1818");
    exchange.getIn().setHeader(SmppConstants.DEST_ADDR_TON, TypeOfNumber.INTERNATIONAL.value());
    exchange.getIn().setHeader(SmppConstants.DEST_ADDR_NPI, NumberingPlanIndicator.INTERNET.value());
    exchange.getIn().setHeader(SmppConstants.DEST_ADDR, "1919");
    exchange.getIn().setHeader(SmppConstants.REGISTERED_DELIVERY, new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE).value());
    expect(session.dataShortMessage(eq("XXX"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL), eq("1818"),
            eq(TypeOfNumber.INTERNATIONAL), eq(NumberingPlanIndicator.INTERNET), eq("1919"), eq(new ESMClass()),
            eq(new RegisteredDelivery((byte) 2)), eq(DataCodings.newInstance((byte) 0))))
        .andReturn(new DataSmResult(new MessageId("1"), null));

    replay(session);

    command.execute(exchange);

    verify(session);

    assertEquals("1", exchange.getOut().getHeader(SmppConstants.ID));
    assertNull(exchange.getOut().getHeader(SmppConstants.OPTIONAL_PARAMETERS));
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:27,代碼來源:SmppDataSmCommandTest.java

示例11: 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

示例12: testRouteServiceStartupOrder

import org.apache.camel.impl.DefaultCamelContext; //導入依賴的package包/類
public void testRouteServiceStartupOrder() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);

    template.sendBody("direct:start", "Hello World");

    assertMockEndpointsSatisfied();

    // assert correct order
    DefaultCamelContext dcc = (DefaultCamelContext) context;
    List<RouteStartupOrder> order = dcc.getRouteStartupOrder();

    assertEquals(4, order.size());
    assertEquals("seda://foo", order.get(0).getRoute().getEndpoint().getEndpointUri());
    assertEquals("direct://start", order.get(1).getRoute().getEndpoint().getEndpointUri());
    assertEquals("seda://bar", order.get(2).getRoute().getEndpoint().getEndpointUri());
    assertEquals("direct://bar", order.get(3).getRoute().getEndpoint().getEndpointUri());

    // assert route service was started in order as well
    assertEquals("2143", startOrder);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:22,代碼來源:RouteServicesStartupOrderTest.java

示例13: createEndpointStringStringMapShouldReturnASmppEndpoint

import org.apache.camel.impl.DefaultCamelContext; //導入依賴的package包/類
@Test
public void createEndpointStringStringMapShouldReturnASmppEndpoint() throws Exception {
    CamelContext context = new DefaultCamelContext();
    component = new SmppComponent(context);
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("password", "secret");
    Endpoint endpoint = component.createEndpoint("smpp://[email protected]:2775", "?password=secret", parameters);
    SmppEndpoint smppEndpoint = (SmppEndpoint) endpoint;
    
    assertEquals("smpp://[email protected]:2775", smppEndpoint.getEndpointUri());
    assertEquals("smpp://[email protected]:2775", smppEndpoint.getEndpointKey());
    assertSame(component, smppEndpoint.getComponent());
    assertNotNull(smppEndpoint.getConfiguration());
    assertEquals("secret", smppEndpoint.getConfiguration().getPassword());
    assertEquals("smpp://[email protected]:2775", smppEndpoint.getConnectionString());
    assertEquals(ExchangePattern.InOnly, smppEndpoint.getExchangePattern());
    assertTrue(smppEndpoint.getBinding() instanceof SmppBinding);
    assertNotNull(smppEndpoint.getCamelContext());
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:20,代碼來源:SmppComponentTest.java

示例14: createRouteBuilder

import org.apache.camel.impl.DefaultCamelContext; //導入依賴的package包/類
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            DefaultCamelContext dcc = (DefaultCamelContext) context;
            dcc.setName("myCamel");

            context.setStreamCaching(true);
            context.getStreamCachingStrategy().setSpoolDirectory("target/cachedir/#name#/");

            from("direct:start").routeId("foo")
                .convertBodyTo(int.class)
                .to("mock:a");
        }
    };
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:18,代碼來源:ManagedStreamCachingStrategyTest.java

示例15: createCamelContext

import org.apache.camel.impl.DefaultCamelContext; //導入依賴的package包/類
@Override
public CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("testStrategy", new ListAggregationStrategy());
    ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(broker.getTcpConnectorUri());

    SjmsComponent sjmsComponent = new SjmsComponent();
    sjmsComponent.setConnectionFactory(connectionFactory);

    SjmsBatchComponent sjmsBatchComponent = new SjmsBatchComponent();
    sjmsBatchComponent.setConnectionFactory(connectionFactory);

    CamelContext context = new DefaultCamelContext(registry);
    context.addComponent("sjms", sjmsComponent);
    context.addComponent("sjms-batch", sjmsBatchComponent);
    return context;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:18,代碼來源:SjmsBatchConsumerTest.java


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