[jbosscache-commits] JBoss Cache SVN: r6231 - in core/trunk/src: main/java/org/jboss/cache/util and 1 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Wed Jul 9 08:01:42 EDT 2008
Author: mircea.markus
Date: 2008-07-09 08:01:42 -0400 (Wed, 09 Jul 2008)
New Revision: 6231
Added:
core/trunk/src/main/java/org/jboss/cache/util/FileLookup.java
Removed:
core/trunk/src/main/java/org/jboss/cache/config/parsing/FileLookup.java
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
Log:
moved FileLookup from config to util as it might be referenced from here aswell
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java 2008-07-09 10:50:13 UTC (rev 6230)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java 2008-07-09 12:01:42 UTC (rev 6231)
@@ -22,8 +22,6 @@
package org.jboss.cache.config.parsing;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
@@ -32,6 +30,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.util.FileLookup;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java 2008-07-09 10:50:13 UTC (rev 6230)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java 2008-07-09 12:01:42 UTC (rev 6231)
@@ -23,6 +23,7 @@
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
+import org.jboss.cache.util.FileLookup;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
@@ -46,7 +47,7 @@
/**
* Writes to the <b>os</b> the 3.x configuration file resulted by transforming the 2.x configuration file passed in
* as <b>is</b>. Transformation is performed according to the <b>xsltFile</b>. The xslt file is looked up using a
- * {@link org.jboss.cache.config.parsing.FileLookup}
+ * {@link org.jboss.cache.util.FileLookup}
*/
public void parse(InputStream is, OutputStream os, String xsltFile) throws Exception
{
@@ -66,7 +67,7 @@
/**
* Writes to the <b>os</b> the 3.x configuration file resulted by transforming the 2.x configuration file passed in
* as <b>inputFile</b>. Transformation is performed according to the <b>xsltFile</b>. Both <b>inputFile</b> and he xslt
- * file are looked up using a {@link org.jboss.cache.config.parsing.FileLookup}
+ * file are looked up using a {@link org.jboss.cache.util.FileLookup}
*/
public void parse(String inputFile, OutputStream os, String xsltFile) throws Exception
{
Deleted: core/trunk/src/main/java/org/jboss/cache/config/parsing/FileLookup.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/FileLookup.java 2008-07-09 10:50:13 UTC (rev 6230)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/FileLookup.java 2008-07-09 12:01:42 UTC (rev 6231)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.config.parsing;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
-/**
- * Holds the logic of looking up a file, in the following sequence:
- * <ol>
- * <li> try to load it with the curent thread's context ClassLoader</li>
- * <li> if fails, the system ClassLoader</li>
- * <li> if fails, try to load it as a file from the disck </li>
- * </ol>
- *
- * @author Mircea.Markus at jboss.com
- * @since 3.0
- */
-public class FileLookup
-{
- private static final Log log = LogFactory.getLog(FileLookup.class);
-
- /**
- * Looks up the file, see : {@link org.jboss.cache.config.parsing.FileLookup}.
- * @param filename might be the name of the file (too look it up in the class path) or an url to a file.
- * @return an input stream to the file or null if nothing found through all lookup steps.
- */
- public InputStream lookupFile(String 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)
- {
- return null;
- }
- }
- return is;
- }
-
- protected InputStream getAsInputStreamFromClassLoader(String filename)
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- InputStream is = cl == null ? null : cl.getResourceAsStream(filename);
- if (is == null)
- {
- // check system class loader
- is = getClass().getClassLoader().getResourceAsStream(filename);
- }
- return is;
- }
-}
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-07-09 10:50:13 UTC (rev 6230)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-07-09 12:01:42 UTC (rev 6231)
@@ -28,6 +28,7 @@
import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.element.LoadersElementParser;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.util.FileLookup;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -107,10 +108,10 @@
/**
* Parses an XML file and returns a new configuration.
- * For looking up the file, {@link org.jboss.cache.config.parsing.FileLookup} is used.
+ * For looking up the file, {@link org.jboss.cache.util.FileLookup} is used.
*
* @throws OldFileFormatException if the file has a 2.x format
- * @see org.jboss.cache.config.parsing.FileLookup
+ * @see org.jboss.cache.util.FileLookup
*/
public Configuration parseFile(String filename)
{
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-07-09 10:50:13 UTC (rev 6230)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-07-09 12:01:42 UTC (rev 6231)
@@ -22,14 +22,13 @@
import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.eviction.EvictionPolicy;
import org.jboss.cache.util.Util;
+import org.jboss.cache.util.FileLookup;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
Copied: core/trunk/src/main/java/org/jboss/cache/util/FileLookup.java (from rev 6225, core/trunk/src/main/java/org/jboss/cache/config/parsing/FileLookup.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/FileLookup.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/util/FileLookup.java 2008-07-09 12:01:42 UTC (rev 6231)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+/**
+ * Holds the logic of looking up a file, in the following sequence:
+ * <ol>
+ * <li> try to load it with the curent thread's context ClassLoader</li>
+ * <li> if fails, the system ClassLoader</li>
+ * <li> if fails, try to load it as a file from the disck </li>
+ * </ol>
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+public class FileLookup
+{
+ private static final Log log = LogFactory.getLog(FileLookup.class);
+
+ /**
+ * Looks up the file, see : {@link FileLookup}.
+ * @param filename might be the name of the file (too look it up in the class path) or an url to a file.
+ * @return an input stream to the file or null if nothing found through all lookup steps.
+ */
+ public InputStream lookupFile(String 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)
+ {
+ return null;
+ }
+ }
+ return is;
+ }
+
+ protected InputStream getAsInputStreamFromClassLoader(String filename)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ InputStream is = cl == null ? null : cl.getResourceAsStream(filename);
+ if (is == null)
+ {
+ // check system class loader
+ is = getClass().getClassLoader().getResourceAsStream(filename);
+ }
+ return is;
+ }
+}
Modified: core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-07-09 10:50:13 UTC (rev 6230)
+++ core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java 2008-07-09 12:01:42 UTC (rev 6231)
@@ -14,7 +14,7 @@
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
-import org.jboss.cache.config.parsing.FileLookup;
+import org.jboss.cache.util.FileLookup;
import org.jboss.cache.eviction.LRUConfiguration;
import org.jboss.cache.transaction.TransactionSetup;
import org.jgroups.conf.XmlConfigurator;
More information about the jbosscache-commits
mailing list