Java Code Examples for org.apache.camel.component.properties.PropertiesComponent#setLocation()

The following examples show how to use org.apache.camel.component.properties.PropertiesComponent#setLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecuringConfigTest.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();

 // create the jasypt properties parser
    JasyptPropertiesParser jasypt = new JasyptPropertiesParser();
    // and set the master password
    jasypt.setPassword("supersecret");   
    
    // we can avoid keeping the master password in plaintext in the application
    // by referencing a environment variable
    // export CAMEL_ENCRYPTION_PASSWORD=supersecret
    // jasypt.setPassword("sysenv:CAMEL_ENCRYPTION_PASSWORD");
    
    // setup the properties component to use the production file
    PropertiesComponent prop = context.getComponent("properties", PropertiesComponent.class);
    prop.setLocation("classpath:rider-test.properties");

    // and use the jasypt properties parser so we can decrypt values
    prop.setPropertiesParser(jasypt);
    
    return context;
}
 
Example 2
Source File: XARollbackAfterDbTest.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
            pc.setLocation("camelinaction/sql.properties");

            from("activemq:queue:partners")
                    .transacted()
                    .log("*** transacted ***")
                    .bean(PartnerServiceBean.class, "toMap")
                    .log("*** before SQL ***")
                    .to("sql:{{sql-insert}}?dataSource=#myDataSource")
                    .log("*** after SQL ***")
                    .throwException(new IllegalArgumentException("Forced failure after DB"));
        }
    };
}
 
Example 3
Source File: XACommitTest.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
            pc.setLocation("camelinaction/sql.properties");

            from("activemq:queue:partners")
                .transacted()
                .log("*** transacted ***")
                .bean(PartnerServiceBean.class, "toMap")
                .log("*** before SQL ***")
                .to("sql:{{sql-insert}}?dataSource=#myDataSource")
                .log("*** after SQL ***")
                .to("mock:result");
        }
    };
}
 
Example 4
Source File: XARollbackBeforeDbTest.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
            pc.setLocation("camelinaction/sql.properties");

            from("activemq:queue:partners")
                .transacted()
                .log("*** transacted ***")
                .bean(PartnerServiceBean.class, "toMap")
                .log("*** before SQL ***")
                .throwException(new IllegalArgumentException("Forced failure before DB"))
                .to("sql:{{sql-insert}}?dataSource=#myDataSource")
                .log("*** after SQL ***");
        }
    };
}
 
Example 5
Source File: FtpToJMSWithPropertyPlaceholderTest.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
protected CamelContext createCamelContext() throws Exception {
    // create CamelContext
    CamelContext camelContext = super.createCamelContext();
    
    // connect to embedded ActiveMQ JMS broker
    ConnectionFactory connectionFactory = 
        new ActiveMQConnectionFactory("vm://localhost");
    camelContext.addComponent("jms",
        JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));

    // setup the properties component to use the test file
    PropertiesComponent prop = camelContext.getComponent("properties", PropertiesComponent.class);
    prop.setLocation("classpath:rider-test.properties");        
    
    return camelContext;
}
 
Example 6
Source File: EncryptedPropertiesPasswordInSystemPropertyTest.java    From camel-cookbook-examples with Apache License 2.0 6 votes vote down vote up
@Override
public CamelContext createCamelContext() {
    // normally this would be set along the lines of -DjasyptMasterPassword=encryptionPassword
    // in a place appropriate to the runtime
    System.setProperty("jasyptMasterPassword", "encryptionPassword");

    JasyptPropertiesParser propParser = new JasyptPropertiesParser();
    propParser.setPassword("sys:jasyptMasterPassword");

    PropertiesComponent propComponent = new PropertiesComponent();
    propComponent.setLocation("classpath:placeholder.properties");
    propComponent.setPropertiesParser(propParser);

    CamelContext camelContext = new DefaultCamelContext();
    camelContext.addComponent("properties", propComponent);
    return camelContext;
}
 
Example 7
Source File: CartConfiguration.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
/**
 * Create the Camel properties component using CDI @Produces with the name: properties
 */
@Produces
@Named("properties")
PropertiesComponent propertiesComponent() {
    PropertiesComponent component = new PropertiesComponent();
    // load properties file form the classpath
    component.setLocation("classpath:cart.properties");
    return component;
}
 
Example 8
Source File: CartConfiguration.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
/**
 * Create the Camel properties component using CDI @Produces with the name: properties
 */
@Produces
@Named("properties")
PropertiesComponent propertiesComponent() {
    PropertiesComponent component = new PropertiesComponent();
    // load properties file form the classpath
    component.setLocation("classpath:cart.properties");
    return component;
}
 
Example 9
Source File: HelloConfiguration.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
/**
 * Create the Camel properties component using CDI @Produces with the name: properties
 */
@Produces
@Named("properties")
PropertiesComponent propertiesComponent() {
    PropertiesComponent component = new PropertiesComponent();
    // load properties file form the classpath
    component.setLocation("classpath:hello.properties");
    return component;
}
 
Example 10
Source File: HelloConfiguration.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
/**
 * Create the Camel properties component using CDI @Produces with the name: properties
 */
@Produces
@Named("properties")
PropertiesComponent propertiesComponent() {
    PropertiesComponent component = new PropertiesComponent();
    // load properties file form the classpath
    component.setLocation("classpath:hello.properties");
    return component;
}
 
Example 11
Source File: CamelRiderJavaDSLTest.java    From camelinaction with Apache License 2.0 5 votes vote down vote up
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();

    // setup the properties component to use the test file
    PropertiesComponent prop = context.getComponent("properties", PropertiesComponent.class);
    prop.setLocation("classpath:rider-test.properties");

    return context;
}
 
Example 12
Source File: CamelRiderJavaDSLProdTest.java    From camelinaction with Apache License 2.0 5 votes vote down vote up
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();

    // setup the properties component to use the production file
    PropertiesComponent prop = context.getComponent("properties", PropertiesComponent.class);
    prop.setLocation("classpath:rider-prod.properties");

    return context;
}
 
Example 13
Source File: EncryptedPropertiesTest.java    From camel-cookbook-examples with Apache License 2.0 5 votes vote down vote up
@Override
public CamelContext createCamelContext() {
    JasyptPropertiesParser propParser = new JasyptPropertiesParser();
    propParser.setPassword("encryptionPassword");

    PropertiesComponent propComponent = new PropertiesComponent();
    propComponent.setLocation("classpath:placeholder.properties");
    propComponent.setPropertiesParser(propParser);

    CamelContext camelContext = new DefaultCamelContext();
    camelContext.addComponent("properties", propComponent);
    return camelContext;
}
 
Example 14
Source File: JasyptIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Test
public void testPasswordDecryption() throws Exception {

    // create the jasypt properties parser
    JasyptPropertiesParser jasypt = new JasyptPropertiesParser();
    // and set the master password
    jasypt.setPassword("secret");

    // create the properties component
    PropertiesComponent pc = new PropertiesComponent();
    pc.setLocation("classpath:password.properties");
    // and use the jasypt properties parser so we can decrypt values
    pc.setPropertiesParser(jasypt);

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.setPropertiesComponent(pc);
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").transform().simple("Hi ${body} the decrypted password is: ${properties:cool.password}");
        }
    });

    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        String result = producer.requestBody("direct:start", "John", String.class);
        Assert.assertEquals("Hi John the decrypted password is: tiger", result.trim());
    } finally {
        camelctx.close();
    }
}