/** * Searches for the property with the specified key in this property map. If the key is not * found in this property map, the parent property map, and its parents, recursively, are then * checked. * <br/> * If the key maps to a string value, it will be returned as is. If the property is not found, * <code>null</code> will be returned. For all other types a ConfigurationException will be * thrown. * * @param key Property key. * @return String value in this property map with the specified key value. */ public final String getString(final String key) { Object objectValue = get(key); if (objectValue == null) { return null; } else if (objectValue instanceof String) { return (String) objectValue; } Object[] args = new Object[] {key, objectValue}; String msg = "Configuration value is not a string: {0}={1}"; throw new ConfigurationException(MessageFormat.format(msg, args)); }
Object[] args = new Object[] {key, objectValue}; String msg = "Configuration value can not be converted to int: {0}={1}"; throw new ConfigurationException(MessageFormat.format(msg, args), ex); throw new ConfigurationException(MessageFormat.format(msg, args));
Object[] args = new Object[] {key, classname}; String msg = "Could not find class of configuration value: {0}={1}"; throw new ConfigurationException(MessageFormat.format(msg, args), ex); throw new ConfigurationException(MessageFormat.format(msg, args));
/** * Searches for the property with the specified key in this property map. If the key is not * found in this property map, the parent property map, and its parents, recursively, are then * checked. * <br/> * If the key maps to a string array, it will be returned as is. A simple string will be * converted into a string array by splitting it into substrings at every occurence of ',' * character. If the property is not found, <code>null</code> will be returned. For all other * types a ConfigurationException will be thrown. * * @param key Property key. * @return String array in this property map with the specified key value. */ public final String[] getStringArray(final String key) { Object objectValue = get(key); if (objectValue == null) { return null; } else if (objectValue instanceof String[]) { return (String[]) objectValue; } else if (objectValue instanceof String) { return ((String) objectValue).split(","); } Object[] args = new Object[] {key, objectValue}; String msg = "Configuration value is not a String[]: {0}={1}"; throw new ConfigurationException(MessageFormat.format(msg, args)); }
Object[] args = new Object[] {key, new Integer(i), classnames[i]}; String msg = "Could not find class of configuration value: {0}[{1}]={2}"; throw new ConfigurationException(MessageFormat.format(msg, args), ex); throw new ConfigurationException(MessageFormat.format(msg, args));
Object[] args = new Object[] {key, new Integer(i), classname}; String msg = "Could not find configured class: {0}[{1}]={2}"; throw new ConfigurationException(MessageFormat.format(msg, args), ex); } catch (IllegalAccessException ex) { Object[] args = new Object[] {key, new Integer(i), classname}; String msg = "Could not instantiate configured class: {0}[{1}]={2}"; throw new ConfigurationException(MessageFormat.format(msg, args), ex); } catch (InstantiationException ex) { Object[] args = new Object[] {key, new Integer(i), classname}; String msg = "Could not instantiate configured class: {0}[{1}]={2}"; throw new ConfigurationException(MessageFormat.format(msg, args), ex); } catch (ExceptionInInitializerError ex) { Object[] args = new Object[] {key, new Integer(i), classname}; String msg = "Could not instantiate configured class: {0}[{1}]={2}"; throw new ConfigurationException(MessageFormat.format(msg, args), ex); } catch (SecurityException ex) { Object[] args = new Object[] {key, new Integer(i), classname}; String msg = "Could not instantiate configured class: {0}[{1}]={2}"; throw new ConfigurationException(MessageFormat.format(msg, args), ex); throw new ConfigurationException(MessageFormat.format(msg, args));
throw new ConfigurationException(MessageFormat.format(msg, args));
/** * Load modul configuration from default locations. * <br/> * First it loads default configuration contained in Castor JAR. This gets overwritten * by a configuration found on Java library directory. If no configuration could be found * until that point a ConfigurationException will be thrown. * * @param path Path to the default configuration to load. * @param filename Name of the configuration file. */ protected void loadDefaultProperties(final String path, final String filename) { Properties properties = new Properties(); // Get detault configuration from the Castor JAR. boolean inCastorJar = loadFromClassPath(properties, path + filename); // Get overriding configuration from the Java library directory, ignore if not // found. If found merge existing properties. boolean inJavaLibDir = loadFromJavaHome(properties, filename); // Couldn't find configuration in Castor jar nor Java library directory. if (!inCastorJar && !inJavaLibDir) { throw new ConfigurationException("Failed to load configuration: " + filename); } _map.putAll(properties); }