当前位置: 首页>>代码示例>>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;未经允许,请勿转载。