1 24 package org.riotfamily.common.beans.config; 25 26 import java.util.Enumeration ; 27 import java.util.Properties ; 28 29 import org.springframework.beans.propertyeditors.PropertiesEditor; 30 import org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer; 31 32 69 public class PropertiesPlaceholderConfigurer extends 70 ServletContextPropertyPlaceholderConfigurer { 71 72 protected String resolvePlaceholder(String placeholder, Properties props) { 73 int i = placeholder.indexOf('*'); 74 if (i != -1) { 75 return resolveAll(props, placeholder.substring(0, i)); 76 } 77 return super.resolvePlaceholder(placeholder, props); 78 } 79 80 protected String resolveAll(Properties props, String prefix) { 81 StringBuffer sb = new StringBuffer (); 82 Enumeration names = props.propertyNames(); 83 while (names.hasMoreElements()) { 84 String name = (String ) names.nextElement(); 85 if (name.startsWith(prefix) && name.length() > prefix.length()) { 86 sb.append(name.substring(prefix.length())); 87 sb.append('='); 88 sb.append(props.getProperty(name)); 89 sb.append('\n'); 90 } 91 } 92 return sb.toString(); 93 } 94 } 95 | Popular Tags |