Author: thorsten
Date: Fri Aug 4 04:41:38 2006
New Revision: 428699
URL: http://svn.apache.org/viewvc?rev=428699&view=rev
Log:
FOR-914 [Java Coding] Do not raise exception when you can prevent them
Enhancing the code of the forrestConfModule.
Modified:
forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java
Modified: forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java
URL:
http://svn.apache.org/viewvc/forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java?rev=428699&r1=428698&r2=428699&view=diff
==============================================================================
--- forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java
(original)
+++ forrest/trunk/main/java/org/apache/forrest/conf/ForrestConfModule.java Fri
Aug 4 04:41:38 2006
@@ -136,45 +136,26 @@
filteringProperties = loadXMLPropertiesFromURI(filteringProperties,
forrestPropertiesStringURI);
- } catch (FileNotFoundException e) {
- if (debugging())
- debug("Unable to find local.forrest.properties.xml,
ignoring.");
- }
// get the values from forrest.properties.xml
- try {
forrestPropertiesStringURI = projectHome +
SystemUtils.FILE_SEPARATOR
+ "forrest.properties.xml";
filteringProperties = loadXMLPropertiesFromURI(filteringProperties,
forrestPropertiesStringURI);
- } catch (FileNotFoundException e) {
- if (debugging())
- debug("Unable to find forrest.properties.xml, ignoring.");
- }
// get the values from default.forrest.properties.xml
- try {
forrestPropertiesStringURI = contextHome +
SystemUtils.FILE_SEPARATOR
+ "default.forrest.properties.xml";
filteringProperties = loadXMLPropertiesFromURI(filteringProperties,
forrestPropertiesStringURI);
- } catch (FileNotFoundException e) {
- if (debugging())
- debug("Unable to find default.forrest.properties.xml,
ignoring.");
- }
// get forrest.properties and load the values
- try {
forrestPropertiesStringURI = projectHome +
SystemUtils.FILE_SEPARATOR
+ "forrest.properties";
filteringProperties = loadAntPropertiesFromURI(filteringProperties,
forrestPropertiesStringURI);
- } catch (FileNotFoundException e) {
- if (debugging())
- debug("Unable to find forrest.properties, using defaults.");
- }
// get default-forrest.properties and load the values
String defaultForrestPropertiesStringURI = contextHome +
SystemUtils.FILE_SEPARATOR
@@ -188,18 +169,15 @@
StringTokenizer st = new StringTokenizer(strPluginList, ",");
while (st.hasMoreTokens()) {
forrestPropertiesStringURI =
ForrestConfUtils.getPluginDir(st.nextToken().trim());
- try {
forrestPropertiesStringURI = forrestPropertiesStringURI
+ SystemUtils.FILE_SEPARATOR +
"default.plugin.properties.xml";
filteringProperties =
loadXMLPropertiesFromURI(filteringProperties,
forrestPropertiesStringURI);
- } catch (FileNotFoundException e) {
- if (debugging())
- debug("Unable to load " + forrestPropertiesStringURI +
", ignoring. "
- + e.getMessage());
- }
}
}
+ } catch (Exception e) {
+ getLogger().error("Opps, something went wrong.",e);
+ }
loadSystemProperties(filteringProperties);
ForrestConfUtils.aliasSkinProperties(filteringProperties);
@@ -259,9 +237,9 @@
InputStream in = null;
try {
source = m_resolver.resolveURI(propertiesStringURI);
+ if (debugging())
+ debug("Searching for forrest.properties.xml in " +
source.getURI());
if (source.exists()){
- if (debugging())
- debug("Searching for forrest.properties.xml in " +
source.getURI());
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
@@ -278,7 +256,8 @@
if (debugging())
debug("Loaded:" + propertiesStringURI +
filteringProperties.toString());
- }
+ }else if (debugging())
+ debug("Unable to find "+source.getURI()+", ignoring.");
} finally {
if (source != null) {
@@ -308,17 +287,17 @@
Source source = null;
InputStream in = null;
try {
-
source = m_resolver.resolveURI(antPropertiesStringURI);
-
if (debugging())
debug("Searching for forrest.properties in" + source.getURI());
- in = source.getInputStream();
- filteringProperties = new AntProperties(precedingProperties);
- filteringProperties.load(in);
+ if (source.exists()){
+ in = source.getInputStream();
+ filteringProperties = new AntProperties(precedingProperties);
+ filteringProperties.load(in);
- if (debugging())
- debug("Loaded:" + antPropertiesStringURI +
filteringProperties.toString());
+ if (debugging())
+ debug("Loaded:" + antPropertiesStringURI +
filteringProperties.toString());
+ }
} finally {
if (source != null) {