Search in sources :

Example 1 with Service

use of org.apache.camel.Service in project camel by apache.

the class SpringMarshalDomainObjectJSONTest method createCamelContext.

protected CamelContext createCamelContext() throws Exception {
    setUseRouteBuilder(false);
    final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/dataformat/xstream/SpringMarshalDomainObjectJSONTest.xml");
    setCamelContextService(new Service() {

        public void start() throws Exception {
            applicationContext.start();
        }

        public void stop() throws Exception {
            applicationContext.stop();
        }
    });
    return SpringCamelContext.springCamelContext(applicationContext);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Service(org.apache.camel.Service) AbstractXmlApplicationContext(org.springframework.context.support.AbstractXmlApplicationContext)

Example 2 with Service

use of org.apache.camel.Service in project camel by apache.

the class SpringMarshalListTest method createCamelContext.

protected CamelContext createCamelContext() throws Exception {
    setUseRouteBuilder(false);
    final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/dataformat/xstream/SpringMarshalListTest.xml");
    setCamelContextService(new Service() {

        public void start() throws Exception {
            applicationContext.start();
        }

        public void stop() throws Exception {
            applicationContext.stop();
        }
    });
    return SpringCamelContext.springCamelContext(applicationContext);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Service(org.apache.camel.Service) AbstractXmlApplicationContext(org.springframework.context.support.AbstractXmlApplicationContext)

Example 3 with Service

use of org.apache.camel.Service in project camel by apache.

the class SpringXStreamConfigurationTest method createCamelContext.

protected CamelContext createCamelContext() throws Exception {
    setUseRouteBuilder(false);
    final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/dataformat/xstream/SpringXStreamConfigurationTest.xml");
    setCamelContextService(new Service() {

        public void start() throws Exception {
            applicationContext.start();
        }

        public void stop() throws Exception {
            applicationContext.stop();
        }
    });
    return SpringCamelContext.springCamelContext(applicationContext);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Service(org.apache.camel.Service) AbstractXmlApplicationContext(org.springframework.context.support.AbstractXmlApplicationContext)

Example 4 with Service

use of org.apache.camel.Service in project camel by apache.

the class CamelJaxbSpringTest method createCamelContext.

protected CamelContext createCamelContext() throws Exception {
    setUseRouteBuilder(false);
    final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/jaxb/CamelJaxbTest.xml");
    setCamelContextService(new Service() {

        public void start() throws Exception {
            applicationContext.start();
        }

        public void stop() throws Exception {
            applicationContext.stop();
        }
    });
    return SpringCamelContext.springCamelContext(applicationContext);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Service(org.apache.camel.Service) AbstractXmlApplicationContext(org.springframework.context.support.AbstractXmlApplicationContext)

Example 5 with Service

use of org.apache.camel.Service in project camel by apache.

the class JmsAutoStartupTest method testAutoStartup.

@Test
public void testAutoStartup() throws Exception {
    Service service = context.getRoutes().get(0).getServices().get(0);
    JmsConsumer consumer = (JmsConsumer) service;
    assertEquals(false, consumer.getListenerContainer().isRunning());
    MockEndpoint mock = getMockEndpoint("mock:result");
    // should be stopped by default
    mock.expectedMessageCount(0);
    template.sendBody("activemq:queue:foo", "Hello World");
    Thread.sleep(2000);
    assertMockEndpointsSatisfied();
    mock.reset();
    mock.expectedBodiesReceived("Hello World");
    // then start the listener so we can consume the persistent message
    consumer.startListenerContainer();
    assertMockEndpointsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Service(org.apache.camel.Service) Test(org.junit.Test)

Aggregations

Service (org.apache.camel.Service)32 SuspendableService (org.apache.camel.SuspendableService)8 LifecycleStrategy (org.apache.camel.spi.LifecycleStrategy)8 AbstractXmlApplicationContext (org.springframework.context.support.AbstractXmlApplicationContext)8 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)8 StatefulService (org.apache.camel.StatefulService)7 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)6 ArrayList (java.util.ArrayList)5 Processor (org.apache.camel.Processor)5 Route (org.apache.camel.Route)5 IOException (java.io.IOException)4 Endpoint (org.apache.camel.Endpoint)4 MalformedObjectNameException (javax.management.MalformedObjectNameException)3 CamelContextAware (org.apache.camel.CamelContextAware)3 FailedToStartRouteException (org.apache.camel.FailedToStartRouteException)3 NoFactoryAvailableException (org.apache.camel.NoFactoryAvailableException)3 NoSuchEndpointException (org.apache.camel.NoSuchEndpointException)3 ResolveEndpointFailedException (org.apache.camel.ResolveEndpointFailedException)3 RuntimeCamelException (org.apache.camel.RuntimeCamelException)3 VetoCamelContextStartException (org.apache.camel.VetoCamelContextStartException)3