Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.cantaa.util.spring;
 
Replacement Placeholder-Configurer to be used in Spring Context

Author(s):
Hans Lesmeister
    private static final Logger log = LoggerFactory.getLogger(CantaaPropertyPlaceholderConfigurer.class);
//    public static final String APPLICATION_TYPE = "cantaa.commons.application.type";
    @Override
    protected Properties mergeProperties() throws IOException {
        Properties props = super.mergeProperties();
        stripProperties(props);
        PropertiesLoader.extendPropertiesFromExternalFile(props);
        .info("** Properties loaded from SpringContext **");
        PropertiesLoader.logProperties(props);
        return props;
    }

    
Check for the value of system property CommonConstants.APPLICATION_TYPE and strip the properties with that value as prefix

Parameters:
props Properties to (eventually) strip
    public static void stripProperties(Properties props) {
        String type = Environment.getApplicationType();
        PropertiesLoader.stripProperties(typepropstrue);
    }
//    /**
//     * Strips prefix (plus dot) from property names and sets the stripped property (name + value) back into the
//     * Properties-List
//     * <pre><code>
//     *     Properties props = new Properties();
//     *     props.setProperty("check.uno", "Some Value");  // Separated by a dot
//     *     stripProperties("check", props);               // Without the dot
//     *     log.debug(prop.getProperty("uno"));            // ==> "Some Value"
//     *     log.debug(prop.getProperty("check.uno"));      // ==> "Some Value" => Original prop with prefix is NOT removed
//     * </code></pre>
//     * @param prefix Prefix to check on
//     * @param props Properties to alter
//     */
//    public static void stripPropertiesPrefix(String prefix, Properties props) {
//        if (props == null) {
//            return;
//        }
//
//        if (StringUtil.isEmpty(prefix)) {
//            return;
//        }
//
//        String strip = prefix + ".";
//        Set<String> names = props.stringPropertyNames();
//        for (String name : names) {
//            if (name.startsWith(strip)) {
//                String value = props.getProperty(name);
//                String newName = name.substring(strip.length());
//                props.setProperty(newName, value);
//            }
//        }
//    }
New to GrepCode? Check out our FAQ X