本文整理汇总了Java中org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyPlaceholderHelper.PlaceholderResolver方法的具体用法?Java PropertyPlaceholderHelper.PlaceholderResolver怎么用?Java PropertyPlaceholderHelper.PlaceholderResolver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.PropertyPlaceholderHelper
的用法示例。
在下文中一共展示了PropertyPlaceholderHelper.PlaceholderResolver方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: injectPropertiesFromContent
import org.springframework.util.PropertyPlaceholderHelper; //导入方法依赖的package包/类
private int injectPropertiesFromContent(PropertyPlaceholderHelper.PlaceholderResolver resolver)
throws RunBuildException {
String propertiesFileContent = getRunnerParameters().get("propertiesFileContent");
int propertiesCount = 0;
if (StringUtils.hasText(propertiesFileContent)) {
getLogger().message("Will use properties content string configured by user");
try (BufferedReader reader = new BufferedReader(new StringReader(propertiesFileContent))) {
propertiesCount = injectEnvironmentVars(reader, resolver);
} catch (IOException | RuntimeException e) {
getLogger().exception(e);
throw new RunBuildException("Exception occured reading/parsing given properties content. Message ["
+ e.getMessage() + "]");
}
getLogger().message("Plugin injected [" + propertiesCount + "] parameters from properties content");
}
return propertiesCount;
}
示例2: injectPropertiesFromFile
import org.springframework.util.PropertyPlaceholderHelper; //导入方法依赖的package包/类
private int injectPropertiesFromFile(PropertyPlaceholderHelper.PlaceholderResolver resolver)
throws RunBuildException {
String propertiesFilePath = getRunnerParameters().get("propertiesFilePath");
int propertiesCount = 0;
if (StringUtils.hasText(propertiesFilePath)) {
getLogger().message("Will use properties from file [" + propertiesFilePath + "]");
try (BufferedReader reader = newBufferedReader(Paths.get(propertiesFilePath), StandardCharsets.UTF_8)) {
propertiesCount = injectEnvironmentVars(reader, resolver);
} catch (IOException | RuntimeException e) {
throw new RunBuildException("Exception occured reading/parsing [" + propertiesFilePath
+ "]. Message [" + e.getMessage() + "]");
}
getLogger().message("Plugin injected [" + propertiesCount + "] parameters from ["
+ propertiesFilePath + "]");
}
return propertiesCount;
}
示例3: SpelView
import org.springframework.util.PropertyPlaceholderHelper; //导入方法依赖的package包/类
public SpelView(String template) {
this.template = template;
this.prefix = new RandomValueStringGenerator().generate() + "{";
this.context.addPropertyAccessor(new MapAccessor());
this.resolver = new PropertyPlaceholderHelper.PlaceholderResolver() {
public String resolvePlaceholder(String name) {
Expression expression = parser.parseExpression(name);
Object value = expression.getValue(context);
return value == null ? null : value.toString();
}
};
}
示例4: makeProgramCommandLine
import org.springframework.util.PropertyPlaceholderHelper; //导入方法依赖的package包/类
@NotNull
@Override
public ProgramCommandLine makeProgramCommandLine() throws RunBuildException {
PropertyPlaceholderHelper.PlaceholderResolver resolver = new TeamcityPlaceholderResolver();
int envVarsFromFile = injectPropertiesFromFile(resolver);
int envVarsFromContent = injectPropertiesFromContent(resolver);
if (envVarsFromContent == 0 && envVarsFromFile == 0) {
getLogger().error("You have used the EnvInject plugin but not provided a properties file or content");
getLogger().error("This runner will effectively be a no-op");
}
return new SimpleProgramCommandLine(getRunnerContext(), "java", Collections.singletonList("-version"));
}
示例5: injectEnvironmentVars
import org.springframework.util.PropertyPlaceholderHelper; //导入方法依赖的package包/类
protected int injectEnvironmentVars(BufferedReader reader, PropertyPlaceholderHelper.PlaceholderResolver resolver)
throws IOException, RunBuildException {
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("{", "}");
String line;
int propertiesCount = 0;
while ((line = reader.readLine()) != null) {
addDebugMessage("Read line [%s]", line);
if (!line.contains("=")) {
throw new RunBuildException("The line [" + line + "] does contain property of the form key=value");
}
String[] split = line.split("=", 2);
addDebugMessage("Will use key [%s] and value [%s]", split[0], split[1]);
String finalValue = helper.replacePlaceholders(split[1], resolver);
addDebugMessage("Resolved value of [%s] is [%s]", split[1], finalValue);
if (split[0].startsWith(ENV_VAR_PREFIX)) {
addDebugMessage("Will set environment variable");
getAgentConfiguration().addEnvironmentVariable(split[0].replace(ENV_VAR_PREFIX, ""), finalValue);
} else if (split[0].startsWith(SYSTEM_VAR_PREFIX)) {
addDebugMessage("Will set system property");
getAgentConfiguration().addSystemProperty(split[0].replace(SYSTEM_VAR_PREFIX, ""), finalValue);
} else {
addDebugMessage("Will set configuration property");
getAgentConfiguration().addConfigurationParameter(split[0], finalValue);
}
propertiesCount++;
}
return propertiesCount;
}