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


Java PropertiesComponent.setPropertiesParser方法代码示例

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


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

示例1: 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

示例2: 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

示例3: activateService

import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Override
public ServiceHandler activateService(QName serviceName, ComponentModel config) {
    ServiceHandler handler = null;

    // add switchyard property parser to camel PropertiesComponent
    PropertiesComponent propertiesComponent = getCamelContext().getComponent("properties", PropertiesComponent.class);
    PropertyResolver pr = config.getModelConfiguration().getPropertyResolver();
    propertiesComponent.setPropertiesParser(new SwitchYardPropertiesParser(pr));
    
    // process service
    for (ComponentServiceModel service : config.getServices()) {
        if (service.getQName().equals(serviceName)) {
            handler = handleImplementation(service, serviceName);
            break;
        }
    }

    return handler;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:20,代码来源:CamelActivator.java

示例4: createCamelContext

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

示例5: properties

import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Produces
@ApplicationScoped
@Named("properties")
// "properties" component bean that Camel uses to lookup properties
PropertiesComponent properties(PropertiesParser parser) {
    PropertiesComponent component = new PropertiesComponent();
    // Use DeltaSpike as configuration source for Camel CDI
    component.setPropertiesParser(parser);
    return component;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:Application.java

示例6: properties

import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Bean(initMethod = "", destroyMethod = "")
// Camel handles the lifecycle of this bean
PropertiesComponent properties(CamelContext camelContext, PropertiesParser parser) {
    if (camelContext.hasComponent("properties") != null) {
        return camelContext.getComponent("properties", PropertiesComponent.class);
    } else {
        PropertiesComponent pc = new PropertiesComponent();
        pc.setPropertiesParser(parser);
        return pc;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:CamelAutoConfiguration.java

示例7: createCamelContext

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

示例8: testPasswordDecryption

import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@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.addComponent("properties", 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.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:33,代码来源:JasyptIntegrationTest.java

示例9: initPropertyPlaceholder

import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
protected void initPropertyPlaceholder() throws Exception {
    if (getCamelPropertyPlaceholder() != null) {
        CamelPropertyPlaceholderDefinition def = getCamelPropertyPlaceholder();

        PropertiesComponent pc = new PropertiesComponent();
        pc.setLocation(def.getLocation());
        pc.setEncoding(def.getEncoding());

        if (def.isCache() != null) {
            pc.setCache(def.isCache());
        }

        if (def.isIgnoreMissingLocation() != null) {
            pc.setIgnoreMissingLocation(def.isIgnoreMissingLocation());
        }

        // if using a custom resolver
        if (ObjectHelper.isNotEmpty(def.getPropertiesResolverRef())) {
            PropertiesResolver resolver = CamelContextHelper.mandatoryLookup(getContext(), def.getPropertiesResolverRef(),
                                                                             PropertiesResolver.class);
            pc.setPropertiesResolver(resolver);
        }

        // if using a custom parser
        if (ObjectHelper.isNotEmpty(def.getPropertiesParserRef())) {
            PropertiesParser parser = CamelContextHelper.mandatoryLookup(getContext(), def.getPropertiesParserRef(),
                                                                         PropertiesParser.class);
            pc.setPropertiesParser(parser);
        }
        
        pc.setPropertyPrefix(def.getPropertyPrefix());
        pc.setPropertySuffix(def.getPropertySuffix());
        
        if (def.isFallbackToUnaugmentedProperty() != null) {
            pc.setFallbackToUnaugmentedProperty(def.isFallbackToUnaugmentedProperty());
        }
        
        pc.setPrefixToken(def.getPrefixToken());
        pc.setSuffixToken(def.getSuffixToken());

        if (def.getFunctions() != null && !def.getFunctions().isEmpty()) {
            for (CamelPropertyPlaceholderFunctionDefinition function : def.getFunctions()) {
                String ref = function.getRef();
                PropertiesFunction pf = CamelContextHelper.mandatoryLookup(getContext(), ref, PropertiesFunction.class);
                pc.addFunction(pf);
            }
        }

        // register the properties component
        getContext().addComponent("properties", pc);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:53,代码来源:AbstractCamelContextFactoryBean.java

示例10: initPropertyPlaceholder

import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Override
protected void initPropertyPlaceholder() throws Exception {
    super.initPropertyPlaceholder();

    // if blueprint property resolver is enabled on CamelContext then bridge PropertiesComponent to blueprint
    if (isUseBlueprintPropertyResolver()) {
        // lookup existing configured properties component
        PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class);

        BlueprintPropertiesParser parser = new BlueprintPropertiesParser(pc, blueprintContainer, pc.getPropertiesParser());
        BlueprintPropertiesResolver resolver = new BlueprintPropertiesResolver(pc.getPropertiesResolver(), parser);

        // any extra properties
        ServiceReference<?> ref = bundleContext.getServiceReference(PropertiesComponent.OVERRIDE_PROPERTIES);
        if (ref != null) {
            Properties extra = (Properties) bundleContext.getService(ref);
            if (extra != null) {
                pc.setOverrideProperties(extra);
            }
        }

        // no locations has been set, so its a default component
        if (pc.getLocations() == null) {
            StringBuilder sb = new StringBuilder();
            String[] ids = parser.lookupPropertyPlaceholderIds();
            for (String id : ids) {
                sb.append("blueprint:").append(id).append(",");
            }
            if (sb.length() > 0) {
                // location supports multiple separated by comma
                pc.setLocation(sb.toString());
            }
        }

        if (pc.getLocations() != null) {
            // bridge camel properties with blueprint
            pc.setPropertiesParser(parser);
            pc.setPropertiesResolver(resolver);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:42,代码来源:CamelContextFactoryBean.java


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