[jboss-cvs] JBossCache/src/org/jboss/cache/factories ...
Manik Surtani
manik at jboss.org
Tue Apr 3 18:25:49 EDT 2007
User: msurtani
Date: 07/04/03 18:25:49
Modified: src/org/jboss/cache/factories XmlConfigurationParser.java
Log:
JBCACHE-1021
Revision Changes Path
1.16 +29 -14 JBossCache/src/org/jboss/cache/factories/XmlConfigurationParser.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: XmlConfigurationParser.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/factories/XmlConfigurationParser.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- XmlConfigurationParser.java 31 Jan 2007 22:51:16 -0000 1.15
+++ XmlConfigurationParser.java 3 Apr 2007 22:25:49 -0000 1.16
@@ -29,6 +29,8 @@
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
@@ -60,17 +62,30 @@
*/
public Configuration parseFile(String filename)
{
- return parseStream(getAsInputStreamFromClassLoader(filename));
+ InputStream is = getAsInputStreamFromClassLoader(filename);
+ if (is == null)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Unable to find configuration file " + filename + " in classpath; searching for this file on the filesystem instead.");
+ try
+ {
+ is = new FileInputStream(filename);
+ }
+ catch (FileNotFoundException e)
+ {
+ throw new ConfigurationException("Unable to find config file " + filename + " either in classpath or on the filesystem!", e);
+ }
+ }
+
+ return parseStream(is);
}
/**
* Parses an input stream containing XML text and returns a new configuration.
*/
- public Configuration parseStream(InputStream stream)
+ protected Configuration parseStream(InputStream stream)
{
// loop through all elements in XML.
- if (stream == null) throw new ConfigurationException("Input stream for configuration xml is null!");
-
Element root = XmlHelper.getDocumentRoot(stream);
Element mbeanElement = getMBeanElement(root);
More information about the jboss-cvs-commits
mailing list