当前位置: 首页>>代码示例>>Java>>正文


Java PropertiesComponent类代码示例

本文整理汇总了Java中org.apache.camel.component.properties.PropertiesComponent的典型用法代码示例。如果您正苦于以下问题:Java PropertiesComponent类的具体用法?Java PropertiesComponent怎么用?Java PropertiesComponent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PropertiesComponent类属于org.apache.camel.component.properties包,在下文中一共展示了PropertiesComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initProperties

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
@Before
public void initProperties() throws Exception {
    log.info("Setting up test properties from {}", getPathToConfigProperties());
    PropertiesComponent testProperties = context.getComponent("properties", PropertiesComponent.class);
    testProperties.setLocation(getPathToConfigProperties());

    log.info("init databox ids and manager");
    ovmId = context.resolvePropertyPlaceholders("{{isds.ovm.id}}");
    foId = context.resolvePropertyPlaceholders("{{isds.fo.id}}");
    fo2Id = context.resolvePropertyPlaceholders("{{isds.fo2.id}}");

    String username = context.resolvePropertyPlaceholders("{{isds.fo.login}}");
    String password = context.resolvePropertyPlaceholders("{{isds.fo.password}}");
    authFo = new BasicAuthentication(TEST_CONFIG, username, password);
    manager = new DataBoxManager(TEST_CONFIG, authFo);

    // mark all messages as read to have clean state every time
    // unfortunately isds doesn't allow deleting
    markMessagesRead(context.resolvePropertyPlaceholders("{{isds.ovm.login}}"), context.resolvePropertyPlaceholders("{{isds.ovm.password"));
    markMessagesRead(context.resolvePropertyPlaceholders("{{isds.fo.login}}"), context.resolvePropertyPlaceholders("{{isds.fo.password"));
    markMessagesRead(context.resolvePropertyPlaceholders("{{isds.fo2.login}}"), context.resolvePropertyPlaceholders("{{isds.fo2.password"));
}
 
开发者ID:czgov,项目名称:camel-isds,代码行数:23,代码来源:ISDSTestBase.java

示例2: configure

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
@Override
public void configure() throws Exception {
    // configure properties component
    PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class);
    pc.setLocation("classpath:ftp.properties");

    // lets shutdown faster in case of in-flight messages stack up
    getContext().getShutdownStrategy().setTimeout(10);

    from("file:target/upload?moveFailed=../error")
        .log("Uploading file ${file:name}")
        .to("{{ftp.client}}")
        .log("Uploaded file ${file:name} complete.");

    // use system out so it stand out
    System.out.println("*********************************************************************************");
    System.out.println("Camel will route files from target/upload directory to the FTP server: "
            + getContext().resolvePropertyPlaceholders("{{ftp.server}}"));
    System.out.println("You can configure the location of the ftp server in the src/main/resources/ftp.properties file.");
    System.out.println("If the file upload fails, then the file is moved to the target/error directory.");
    System.out.println("Use ctrl + c to stop this application.");
    System.out.println("*********************************************************************************");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:MyFtpClientRouteBuilder.java

示例3: configure

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
@Override
public void configure() throws Exception {
    // configure properties component
    PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class);
    pc.setLocation("classpath:ftp.properties");

    // lets shutdown faster in case of in-flight messages stack up
    getContext().getShutdownStrategy().setTimeout(10);

    from("{{ftp.server}}")
        .to("file:target/download")
        .log("Downloaded file ${file:name} complete.");

    // use system out so it stand out
    System.out.println("*********************************************************************************");
    System.out.println("Camel will route files from the FTP server: "
            + getContext().resolvePropertyPlaceholders("{{ftp.server}}") + " to the target/download directory.");
    System.out.println("You can configure the location of the ftp server in the src/main/resources/ftp.properties file.");
    System.out.println("Use ctrl + c to stop this application.");
    System.out.println("*********************************************************************************");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:MyFtpServerRouteBuilder.java

示例4: isPropertyPlaceholder

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
private static boolean isPropertyPlaceholder(CamelContext context, Object value) {
    if (context != null) {
        Component component = context.hasComponent("properties");
        if (component != null) {
            PropertiesComponent pc;
            try {
                pc = context.getTypeConverter().mandatoryConvertTo(PropertiesComponent.class, component);
            } catch (Exception e) {
                return false;
            }
            if (value.toString().contains(pc.getPrefixToken()) && value.toString().contains(pc.getSuffixToken())) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:IntrospectionSupport.java

示例5: addComponent

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
public void addComponent(String componentName, final Component component) {
    ObjectHelper.notNull(component, "component");
    synchronized (components) {
        if (components.containsKey(componentName)) {
            throw new IllegalArgumentException("Cannot add component as its already previously added: " + componentName);
        }
        component.setCamelContext(this);
        components.put(componentName, component);
        for (LifecycleStrategy strategy : lifecycleStrategies) {
            strategy.onComponentAdd(componentName, component);
        }

        // keep reference to properties component up to date
        if (component instanceof PropertiesComponent && "properties".equals(componentName)) {
            propertiesComponent = (PropertiesComponent) component;
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:DefaultCamelContext.java

示例6: createCamelContext

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();

    final Properties properties = new Properties();
    properties.put("foo", "bar");
    PropertiesComponent pc = camelContext.getComponent("properties", PropertiesComponent.class);
    pc.setLocations(new String[0]);
    pc.setPropertiesResolver(new PropertiesResolver() {
        @Override
        public Properties resolveProperties(CamelContext context, boolean ignoreMissingLocation, String... uri) {
            return properties;
        }
    });

    return camelContext;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:PropertiesAvailableEverywhereTest.java

示例7: testRouteAutoStartedUsingProperties

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
public void testRouteAutoStartedUsingProperties() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {

            PropertiesComponent properties = new PropertiesComponent();
            properties.setLocation("classpath:org/apache/camel/processor/routeAutoStartupTest.properties");
            context.addComponent("properties", properties);

            from("direct:start").autoStartup("{{autoStartupProp}}").to("mock:result");
        }
    });
    context.start();

    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:RouteAutoStartupTest.java

示例8: createRouteBuilder

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            myProp.put("myDir", "target/done");

            PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
            pc.setLocation("ref:myProp");

            from("direct:start")
                .to("file:{{myDir}}?doneFileName=done-${file:name}")
                .to("mock:result");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:FilerProducerDoneFileNameRouteTest.java

示例9: createRouteBuilder

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        public void configure() throws Exception {
            PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
            pc.setLocation("org/apache/camel/builder/script/myproperties.properties");

            from("direct:start")
                .setHeader("myHeader").groovy("context.resolvePropertyPlaceholders('{{' + request.headers.get('foo') + '}}')")
                .to("mock:result");
            
            from("direct:number")
                .transform().groovy("{{myscript}}")
                .to("mock:result");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:GroovySetHeaderPropertyComponentTest.java

示例10: createCamelContext

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();

    // START SNIPPET: e1
    // 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:org/apache/camel/component/jasypt/myproperties.properties");
    // and use the jasypt properties parser so we can decrypt values
    pc.setPropertiesParser(jasypt);

    // add properties component to camel context
    context.addComponent("properties", pc);
    // END SNIPPET: e1

    return context;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:JasyptPropertiesTest.java

示例11: initPropertyPlaceholder

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
/**
 * Initializes the property placeholders by registering the {@link PropertiesComponent} with
 * the configuration from the given init parameters.
 */
private void initPropertyPlaceholder(ServletCamelContext camelContext, Map<String, Object> parameters) throws Exception {
    // setup property placeholder first
    Map<String, Object> properties = IntrospectionSupport.extractProperties(parameters, "propertyPlaceholder.");
    if (properties != null && !properties.isEmpty()) {
        PropertiesComponent pc = new PropertiesComponent();
        IntrospectionSupport.setProperties(pc, properties);
        // validate we could set all parameters
        if (!properties.isEmpty()) {
            throw new IllegalArgumentException("Error setting propertyPlaceholder parameters on CamelContext."
                    + " There are " + properties.size() + " unknown parameters. [" + properties + "]");
        }
        // register the properties component
        camelContext.addComponent("properties", pc);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:CamelServletContextListener.java

示例12: createCamelContext

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
@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;
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:24,代码来源:SecuringConfigTest.java

示例13: createRouteBuilder

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
@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"));
        }
    };
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:20,代码来源:XARollbackAfterDbTest.java

示例14: createRouteBuilder

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
@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");
        }
    };
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:20,代码来源:XACommitTest.java

示例15: createRouteBuilder

import org.apache.camel.component.properties.PropertiesComponent; //导入依赖的package包/类
@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 ***");
        }
    };
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:20,代码来源:XARollbackBeforeDbTest.java


注:本文中的org.apache.camel.component.properties.PropertiesComponent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。