1 24 package org.riotfamily.common.beans.config; 25 26 import java.util.Properties ; 27 28 38 public class PlaceholderWithDefaultConfigurer 39 extends PropertiesPlaceholderConfigurer { 40 41 public static final String DEFAULT_VALUE_SEPARATOR = "="; 42 43 private String valueSeparator = DEFAULT_VALUE_SEPARATOR; 44 45 public void setValueSeparator(String valueSeparator) { 46 this.valueSeparator = valueSeparator; 47 } 48 49 protected String resolvePlaceholder(String placeholder, Properties props, 50 int systemPropertiesMode) { 51 52 String defaultValue = null; 53 int i = placeholder.indexOf(valueSeparator); 54 if (i != -1) { 55 if (i + 1 < placeholder.length()) { 56 defaultValue = placeholder.substring(i + 1); 57 } 58 placeholder = placeholder.substring(0, i); 59 } 60 String value = super.resolvePlaceholder(placeholder, props, 61 systemPropertiesMode); 62 63 if (value == null) { 64 value = defaultValue; 65 } 66 67 return value; 68 } 69 70 } 71 | Popular Tags |