本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
}