Search in sources :

Example 36 with SpringCamelContext

use of org.apache.camel.spring.SpringCamelContext in project camel by apache.

the class AbstractMongoDbTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    applicationContext = new AnnotationConfigApplicationContext(EmbedMongoConfiguration.class);
    CamelContext ctx = new SpringCamelContext(applicationContext);
    PropertiesComponent pc = new PropertiesComponent("classpath:mongodb.test.properties");
    ctx.addComponent("properties", pc);
    return ctx;
}
Also used : CamelContext(org.apache.camel.CamelContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Example 37 with SpringCamelContext

use of org.apache.camel.spring.SpringCamelContext in project camel by apache.

the class SpelExpression method createEvaluationContext.

private EvaluationContext createEvaluationContext(Exchange exchange) {
    StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new RootObject(exchange));
    if (exchange.getContext() instanceof SpringCamelContext) {
        // Support references (like @foo) in expressions to beans defined in the Registry/ApplicationContext
        ApplicationContext applicationContext = ((SpringCamelContext) exchange.getContext()).getApplicationContext();
        evaluationContext.setBeanResolver(new BeanFactoryResolver(applicationContext));
    }
    return evaluationContext;
}
Also used : BeanFactoryResolver(org.springframework.context.expression.BeanFactoryResolver) ApplicationContext(org.springframework.context.ApplicationContext) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext)

Example 38 with SpringCamelContext

use of org.apache.camel.spring.SpringCamelContext in project camel by apache.

the class CxfEndpointUtils method createBus.

/**
     * Create a CXF bus with either BusFactory or SpringBusFactory if Camel Context
     * is SpringCamelContext.  In the latter case, this method updates the bus 
     * configuration with the applicationContext which SpringCamelContext holds 
     * 
     * @param context - the Camel Context
     */
public static Bus createBus(CamelContext context) {
    BusFactory busFactory = BusFactory.newInstance();
    if (context instanceof SpringCamelContext) {
        SpringCamelContext springCamelContext = (SpringCamelContext) context;
        ApplicationContext applicationContext = springCamelContext.getApplicationContext();
        busFactory = new SpringBusFactory(applicationContext);
    }
    return busFactory.createBus();
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) BusFactory(org.apache.cxf.BusFactory) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory)

Example 39 with SpringCamelContext

use of org.apache.camel.spring.SpringCamelContext in project bamboobsc by billchen198318.

the class TestHelloCamelStartForContextInitialized method execute.

@Override
public void execute(ServletContextEvent event) throws Exception {
    CamelContext context = new SpringCamelContext(AppContext.getApplicationContext());
    context.start();
}
Also used : CamelContext(org.apache.camel.CamelContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext)

Example 40 with SpringCamelContext

use of org.apache.camel.spring.SpringCamelContext in project wildfly-camel by wildfly-extras.

the class SpringIntegrationProducerTest method testSendingOneWayMessage.

@Test
public void testSendingOneWayMessage() throws Exception {
    SpringCamelContext camelctx = (SpringCamelContext) contextRegistry.getCamelContext("camel");
    Assert.assertNotNull(camelctx);
    ProducerTemplate template = camelctx.createProducerTemplate();
    template.sendBody("direct:onewayMessage", "Greet");
    HelloWorldService service = SpringUtils.getMandatoryBean(camelctx, HelloWorldService.class, "helloService");
    Assert.assertEquals("We should call the service", service.getGreetName(), "Greet");
}
Also used : ProducerTemplate(org.apache.camel.ProducerTemplate) HelloWorldService(org.wildfly.camel.test.spring.subA.HelloWorldService) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) Test(org.junit.Test)

Aggregations

SpringCamelContext (org.apache.camel.spring.SpringCamelContext)49 CamelContext (org.apache.camel.CamelContext)21 Test (org.junit.Test)21 RouteBuilder (org.apache.camel.builder.RouteBuilder)17 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 ConnectorAction (io.syndesis.common.model.action.ConnectorAction)15 ProducerTemplate (org.apache.camel.ProducerTemplate)15 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)14 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)12 RouteDefinition (org.apache.camel.model.RouteDefinition)7 StepAction (io.syndesis.common.model.action.StepAction)6 Step (io.syndesis.common.model.integration.Step)6 DoToSpringCamelContextsStrategy (org.apache.camel.test.spring.CamelSpringTestHelper.DoToSpringCamelContextsStrategy)5 Method (java.lang.reflect.Method)4 LinkedList (java.util.LinkedList)4 PropertiesComponent (org.apache.camel.component.properties.PropertiesComponent)4 ProcessorDefinition (org.apache.camel.model.ProcessorDefinition)4 Breakpoint (org.apache.camel.spi.Breakpoint)4 Exchange (org.apache.camel.Exchange)3 ConnectorDescriptor (io.syndesis.common.model.action.ConnectorDescriptor)2