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


Java PropertyPlaceholderHelper.PlaceholderResolver方法代码示例

本文整理汇总了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;
}
 
开发者ID:kannanekanath,项目名称:teamcity-envinject-plugin,代码行数:19,代码来源:EnvInjectService.java

示例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;
}
 
开发者ID:kannanekanath,项目名称:teamcity-envinject-plugin,代码行数:19,代码来源:EnvInjectService.java

示例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();
        }
    };
}
 
开发者ID:gravitee-io,项目名称:graviteeio-access-management,代码行数:13,代码来源:SpelView.java

示例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"));
}
 
开发者ID:kannanekanath,项目名称:teamcity-envinject-plugin,代码行数:13,代码来源:EnvInjectService.java

示例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;
}
 
开发者ID:kannanekanath,项目名称:teamcity-envinject-plugin,代码行数:29,代码来源:EnvInjectService.java


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