本文整理汇总了Java中org.apache.camel.component.properties.PropertiesComponent.setPropertiesResolver方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesComponent.setPropertiesResolver方法的具体用法?Java PropertiesComponent.setPropertiesResolver怎么用?Java PropertiesComponent.setPropertiesResolver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.component.properties.PropertiesComponent
的用法示例。
在下文中一共展示了PropertiesComponent.setPropertiesResolver方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: 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);
}
}
}
示例4: configure
import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Override
public void configure(final Env env, final Config config, final Binder binder) throws Throwable {
Config $camel = config.getConfig("camel");
DefaultCamelContext ctx = configure(new DefaultCamelContext(), $camel
.withoutPath("shutdown")
.withoutPath("threads")
.withoutPath("jmx")
.withoutPath("streamCaching"));
if (!$camel.getBoolean("jmx")) {
ctx.disableJMX();
}
/**
* Executor and thread poll
*/
ThreadPoolProfile threadPool = configure(new ThreadPoolProfile(), $camel.getConfig("threads"));
ctx.getExecutorServiceManager().setDefaultThreadPoolProfile(threadPool);
/**
* Shutdown options.
*/
configure(ctx.getShutdownStrategy(), $camel.getConfig("shutdown"));
if ($camel.getBoolean("streamCaching.enabled")) {
ctx.setStreamCaching(true);
configure(ctx.getStreamCachingStrategy(), $camel.getConfig("streamCaching"));
} else {
ctx.setStreamCaching(false);
}
/**
* Components etc..
*/
if (configurer != null) {
configurer.configure(ctx, config);
}
/**
* Routes
*/
if (routes != null) {
routes(routes, ctx, config);
}
/**
* Properties
*/
PropertiesComponent properties = new PropertiesComponent(config.root().origin().description());
properties.setIgnoreMissingLocation(true);
properties.setPropertiesResolver((context, ignoreMissingLocation, location) -> {
Properties props = new Properties();
config.entrySet()
.forEach(e -> props.setProperty(e.getKey(), e.getValue().unwrapped().toString()));
return props;
});
properties.setPrefixToken("${");
properties.setSuffixToken("}");
ctx.addComponent("properties", properties);
env.lifeCycle(CamelFinalizer.class);
/**
* Guice!
*/
binder.bind(CamelContext.class).toInstance(ctx);
binder.bind(DefaultCamelContext.class).toInstance(ctx);
binder.bind(ProducerTemplate.class).toInstance(ctx.createProducerTemplate());
binder.bind(FluentProducerTemplate.class).toInstance(ctx.createFluentProducerTemplate());
binder.bind(ConsumerTemplate.class).toInstance(ctx.createConsumerTemplate());
binder.bind(CamelFinalizer.class).asEagerSingleton();
binder.bind(RouteBuilder.class).toInstance(rb());
Multibinder<Object> routesBinder = Multibinder
.newSetBinder(binder, Object.class, Names.named("camel.routes"));
routeList.forEach(routeType -> routesBinder.addBinding().to(routeType));
}