本文整理汇总了Java中org.apache.camel.component.properties.PropertiesComponent.setInitialProperties方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesComponent.setInitialProperties方法的具体用法?Java PropertiesComponent.setInitialProperties怎么用?Java PropertiesComponent.setInitialProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.component.properties.PropertiesComponent
的用法示例。
在下文中一共展示了PropertiesComponent.setInitialProperties方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: propertiesComponent
import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Produces
@ApplicationScoped
@Named("properties")
private static PropertiesComponent propertiesComponent() {
Properties configuration = new Properties();
configuration.put("property", "value");
PropertiesComponent component = new PropertiesComponent();
component.setInitialProperties(configuration);
component.setLocation("classpath:camel1.properties,classpath:camel2.properties");
return component;
}
示例2: setupPropertiesComponent
import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
public static void setupPropertiesComponent(final CamelContext context, final Map<String, String> props, Logger log) {
// Set up PropertiesComponent
PropertiesComponent pc = new PropertiesComponent();
if (context.getComponentNames().contains("properties")) {
pc = context.getComponent("properties", PropertiesComponent.class);
} else {
context.addComponent("properties", pc);
}
// Set property prefix
if (System.getProperty(PROPERTY_PREFIX) != null) {
pc.setPropertyPrefix(System.getProperty(PROPERTY_PREFIX) + ".");
}
if (props != null) {
Properties initialProps = new Properties();
initialProps.putAll(props);
log.debug(String.format("Added %d initial properties", props.size()));
try {
pc.setInitialProperties(initialProps);
} catch (NoSuchMethodError e) {
// For Camel versions without setInitialProperties
pc.setOverrideProperties(initialProps);
pc.setLocation("default.properties");
}
}
}
示例3: configuration
import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Produces
@ApplicationScoped
@Named("properties")
private static PropertiesComponent configuration() {
Properties properties = new Properties();
properties.put("property", "value");
PropertiesComponent component = new PropertiesComponent();
component.setInitialProperties(properties);
return component;
}
示例4: configuration
import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Produces
@ApplicationScoped
@Named("properties")
private static PropertiesComponent configuration() {
Properties properties = new Properties();
properties.put("from", "inbound");
// Do not add the looked up property for test purpose
//properties.put("to", "mock:outbound");
PropertiesComponent component = new PropertiesComponent();
component.setInitialProperties(properties);
return component;
}
示例5: configuration
import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Produces
@ApplicationScoped
@Named("properties")
private static PropertiesComponent configuration() {
Properties properties = new Properties();
properties.put("from", "inbound");
properties.put("to", "mock:outbound");
PropertiesComponent component = new PropertiesComponent();
component.setInitialProperties(properties);
return component;
}
示例6: configuration
import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Produces
@ApplicationScoped
@Named("properties")
private static PropertiesComponent configuration() {
Properties properties = new Properties();
properties.put("from", "inbound");
properties.put("to", "direct:outbound");
properties.put("header.message", "n/a");
PropertiesComponent component = new PropertiesComponent();
component.setInitialProperties(properties);
return component;
}
示例7: configuration
import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Produces
@ApplicationScoped
@Named("properties")
private static PropertiesComponent configuration() {
Properties properties = new Properties();
properties.put("property", "default");
PropertiesComponent component = new PropertiesComponent();
component.setInitialProperties(properties);
return component;
}
示例8: configuration
import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
@Produces
@ApplicationScoped
@Named("properties")
private static PropertiesComponent configuration() {
Properties properties = new Properties();
properties.put("property1", "value 1");
properties.put("property2", "value 2");
PropertiesComponent component = new PropertiesComponent();
component.setInitialProperties(properties);
return component;
}
示例9: initProperties
import org.apache.camel.component.properties.PropertiesComponent; //导入方法依赖的package包/类
private static void initProperties(CamelContext context,
IPropertiesAware applicationPropertiesAware,
IPropertiesAware servicePropertiesAware) {
try {
PropertiesComponent propertiesComponent = context.getComponent(
"properties", PropertiesComponent.class);
propertiesComponent.setIgnoreMissingLocation(true);
String applicationPrefix = applicationPropertiesAware.getpropertiesPrefix();
String servicePrefix = null;
if(servicePropertiesAware != null) {
servicePrefix = applicationPrefix + "." + servicePropertiesAware.getpropertiesPrefix();
}
Properties applicationProperties =
loadProperties(applicationPrefix, applicationPropertiesAware);
Properties serviceProperties =
loadProperties(servicePrefix, servicePropertiesAware);
Properties initialServiceProperties = new Properties();
if(servicePropertiesAware != null){
initialServiceProperties = MapUtils.prefixProperties(servicePrefix, servicePropertiesAware.getInitialProperties());
}
Properties initialApplicationProperties = new Properties();
if(servicePropertiesAware != null){
initialApplicationProperties = MapUtils.prefixProperties(applicationPrefix, applicationPropertiesAware.getInitialProperties());
}
Properties mergedProps = MapUtils.mergeProperties(
applicationProperties,
serviceProperties);
mergedProps = MapUtils.mergeProperties(
initialApplicationProperties,
mergedProps);
mergedProps =MapUtils.mergeProperties(
initialServiceProperties,
mergedProps);
propertiesComponent.setInitialProperties(mergedProps);
} catch (Exception ex) {
throw new RuntimeException("could not initialize application properties", ex);
}
}