1 5 package com.opensymphony.webwork.config; 6 7 import com.opensymphony.xwork.util.LocalizedTextUtil; 8 import org.apache.commons.logging.Log; 9 import org.apache.commons.logging.LogFactory; 10 11 import java.util.ArrayList ; 12 import java.util.Iterator ; 13 import java.util.StringTokenizer ; 14 15 16 24 public class DefaultConfiguration extends Configuration { 25 27 protected Log log = LogFactory.getLog(this.getClass()); 28 Configuration config; 29 30 32 37 public DefaultConfiguration() { 38 ArrayList list = new ArrayList (); 41 42 try { 43 list.add(new PropertiesConfiguration("webwork")); 44 } catch (Exception e) { 45 log.warn("Could not find webwork.properties"); 46 } 47 48 try { 49 list.add(new PropertiesConfiguration("com/opensymphony/webwork/default")); 50 } catch (Exception e) { 51 log.error("Could not find com/opensymphony/webwork/default.properties", e); 52 } 53 54 Configuration[] configList = new Configuration[list.size()]; 55 config = new DelegatingConfiguration((Configuration[]) list.toArray(configList)); 56 57 try { 59 StringTokenizer configFiles = new StringTokenizer ((String ) config.getImpl("webwork.custom.properties"), ","); 60 61 while (configFiles.hasMoreTokens()) { 62 String name = configFiles.nextToken(); 63 64 try { 65 list.add(new PropertiesConfiguration(name)); 66 } catch (Exception e) { 67 log.error("Could not find " + name + ".properties. Skipping"); 68 } 69 } 70 71 configList = new Configuration[list.size()]; 72 config = new DelegatingConfiguration((Configuration[]) list.toArray(configList)); 73 } catch (IllegalArgumentException e) { 74 } 75 76 try { 78 StringTokenizer bundleFiles = new StringTokenizer ((String ) config.getImpl("webwork.custom.i18n.resources"), ", "); 79 80 while (bundleFiles.hasMoreTokens()) { 81 String name = bundleFiles.nextToken(); 82 83 try { 84 log.info("Loading global messages from " + name); 85 LocalizedTextUtil.addDefaultResourceBundle(name); 86 } catch (Exception e) { 87 log.error("Could not find " + name + ".properties. Skipping"); 88 } 89 } 90 } catch (IllegalArgumentException e) { 91 } 93 } 94 95 97 102 public void setImpl(String aName, Object aValue) throws IllegalArgumentException , UnsupportedOperationException { 103 config.setImpl(aName, aValue); 104 } 105 106 111 public Object getImpl(String aName) throws IllegalArgumentException { 112 return config.getImpl(aName); 114 } 115 116 121 public boolean isSetImpl(String aName) { 122 return config.isSetImpl(aName); 123 } 124 125 130 public Iterator listImpl() { 131 return config.listImpl(); 132 } 133 } 134 | Popular Tags |