Search in sources :

Example 51 with PropertiesComponent

use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.

the class VelocityFileLetterWithPropertyTest method createRegistry.

protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = new JndiRegistry(createJndiContext());
    registry.bind("properties", new PropertiesComponent());
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Example 52 with PropertiesComponent

use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.

the class CamelRouterBuilder method main.

/**
     * Allow this route to be run as an application
     */
public static void main(String[] args) throws Exception {
    System.setProperty("soapEndpointPort", "9006");
    System.setProperty("restEndpointPort", "9002");
    CamelContext context = new DefaultCamelContext();
    PropertiesComponent pc = new PropertiesComponent();
    context.addComponent("properties", pc);
    context.start();
    context.addRoutes(new CamelRouterBuilder());
    Thread.sleep(1000);
    // JAXWSClient invocation
    JAXWSClient jaxwsClient = new JAXWSClient();
    BookStore bookStore = jaxwsClient.getBookStore();
    bookStore.addBook(new Book("Camel User Guide", 123L));
    Book book = bookStore.getBook(123L);
    System.out.println("Get the book with id 123. " + book);
    try {
        book = bookStore.getBook(124L);
        System.out.println("Get the book with id 124. " + book);
    } catch (Exception exception) {
        System.out.println("Expected exception received: " + exception);
    }
    // JAXRSClient invocation
    JAXRSClient jaxrsClient = new JAXRSClient();
    bookStore = jaxrsClient.getBookStore();
    bookStore.addBook(new Book("Karaf User Guide", 124L));
    book = bookStore.getBook(124L);
    System.out.println("Get the book with id 124. " + book);
    try {
        book = bookStore.getBook(126L);
        System.out.println("Get the book with id 126. " + book);
    } catch (Exception exception) {
        System.out.println("Expected exception received: " + exception);
    }
    Thread.sleep(1000);
    context.stop();
    System.exit(0);
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) BookStore(org.apache.camel.example.cxf.jaxrs.resources.BookStore) Book(org.apache.camel.example.cxf.jaxrs.resources.Book) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 53 with PropertiesComponent

use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.

the class CamelCxfExample method main.

public static void main(String[] args) throws Exception {
    // Set system properties for use with Camel property placeholders for running the examples.
    System.setProperty("routerPort", "9001");
    System.setProperty("servicePort", "9003");
    // START SNIPPET: e1
    CamelContext context = new DefaultCamelContext();
    // END SNIPPET: e1
    PropertiesComponent pc = new PropertiesComponent();
    context.addComponent("properties", pc);
    // Set up the JMS broker and the CXF SOAP over JMS server
    // START SNIPPET: e2
    JmsBroker broker = new JmsBroker();
    Server server = new Server();
    try {
        broker.start();
        server.start();
        // END SNIPPET: e2
        // Add some configuration by hand ...
        // START SNIPPET: e3
        context.addRoutes(new RouteBuilder() {

            public void configure() {
                CxfComponent cxfComponent = new CxfComponent(getContext());
                CxfEndpoint serviceEndpoint = new CxfEndpoint(SERVICE_ADDRESS, cxfComponent);
                serviceEndpoint.setServiceClass(Greeter.class);
                // Here we just pass the exception back, don't need to use errorHandler
                errorHandler(noErrorHandler());
                from(ROUTER_ENDPOINT_URI).to(serviceEndpoint);
            }
        });
        // END SNIPPET: e3
        String address = ROUTER_ADDRESS.replace("{{routerPort}}", System.getProperty("routerPort"));
        // Starting the routing context
        // Using the CXF Client to kick off the invocations
        // START SNIPPET: e4
        context.start();
        Client client = new Client(address + "?wsdl");
        // END SNIPPET: e4
        // Now everything is set up - let's start the context
        client.invoke();
        Thread.sleep(1000);
        context.stop();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        server.stop();
        broker.stop();
        System.exit(0);
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) RouteBuilder(org.apache.camel.builder.RouteBuilder) Greeter(org.apache.hello_world_soap_http.Greeter) CxfComponent(org.apache.camel.component.cxf.CxfComponent) CxfEndpoint(org.apache.camel.component.cxf.CxfEndpoint) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 54 with PropertiesComponent

use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.

the class SplunkPublishEventRouteBuilder method configure.

@Override
public void configure() throws Exception {
    log.info("About to start route: direct --> Splunk Server");
    // configure properties component
    PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class);
    pc.setLocation("classpath:application.properties");
    from("direct:start").convertBodyTo(SplunkEvent.class).to("splunk://submit?host={{splunk.host}}&port={{splunk.port}}" + "&username={{splunk.username}}&password={{splunk.password}}&sourceType=secure&source=myAppName");
}
Also used : SplunkEvent(org.apache.camel.component.splunk.event.SplunkEvent) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Example 55 with PropertiesComponent

use of org.apache.camel.component.properties.PropertiesComponent in project camel by apache.

the class SplunkSavedSearchRouteBuilder method configure.

@Override
public void configure() throws Exception {
    log.info("About to setup Splunk 'saved-search' route:Splunk Server --> log{results}");
    // configure properties component
    PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class);
    pc.setLocation("classpath:application.properties");
    from("splunk://savedsearch?host={{splunk.host}}&port={{splunk.port}}&delay=10s" + "&username={{splunk.username}}&password={{splunk.password}}&initEarliestTime=08/17/13 08:35:46:456" + "&savedSearch=failed_password").log("${body}");
}
Also used : PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Aggregations

PropertiesComponent (org.apache.camel.component.properties.PropertiesComponent)83 CamelContext (org.apache.camel.CamelContext)35 Properties (java.util.Properties)17 ApplicationScoped (javax.enterprise.context.ApplicationScoped)12 Produces (javax.enterprise.inject.Produces)12 Named (javax.inject.Named)12 RouteBuilder (org.apache.camel.builder.RouteBuilder)11 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)8 PropertiesLocation (org.apache.camel.component.properties.PropertiesLocation)7 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)6 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)3 Component (org.apache.camel.Component)3 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 Exchange (org.apache.camel.Exchange)2