Index: core-library/src/main/java/org/apache/james/context/AvalonFileSystem.java
===================================================================
--- core-library/src/main/java/org/apache/james/context/AvalonFileSystem.java	(revision 564411)
+++ core-library/src/main/java/org/apache/james/context/AvalonFileSystem.java	(working copy)
@@ -25,7 +25,10 @@
 import org.apache.james.services.FileSystem;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
 
 /**
  * Avalon implementation of the FileSystem service
@@ -66,6 +69,22 @@
             }
         }
     }
+    
+
+    /**
+     * @see org.apache.james.services.FileSystem#getResource(String)
+     */
+    public InputStream getResource(String url) throws IOException {
+    	if (url.startsWith("classpath://")) {
+    		String resourceName = url.substring("classpath://".length());
+			InputStream resourceAsStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
+    		if (resourceAsStream==null) {
+    			throw new IOException("Resource '"+resourceName+"' not found in the classpath!");
+    		}
+    		return resourceAsStream;
+    	}
+    	return new FileInputStream(getFile(url));
+    }
 
     /**
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
Index: core-library/src/main/java/org/apache/james/mailrepository/JDBCMailRepository.java
===================================================================
--- core-library/src/main/java/org/apache/james/mailrepository/JDBCMailRepository.java	(revision 564411)
+++ core-library/src/main/java/org/apache/james/mailrepository/JDBCMailRepository.java	(working copy)
@@ -45,6 +45,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.ObjectOutputStream;
 import java.io.ObjectInputStream;
 import java.sql.Blob;
@@ -305,10 +306,9 @@
         try {
             // Initialise the sql strings.
 
-            File sqlFile = null;
+            InputStream sqlFile = null;
             try {
-                sqlFile = fileSystem.getFile(sqlFileName);
-                sqlFileName = null;
+                sqlFile = fileSystem.getResource(sqlFileName);
             } catch (Exception e) {
                 getLogger().fatalError(e.getMessage(), e);
                 throw e;
@@ -318,7 +318,7 @@
                 logBuffer =
                     new StringBuffer(128)
                             .append("Reading SQL resources from file: ")
-                            .append(sqlFile.getAbsolutePath())
+                            .append(sqlFileName)
                             .append(", section ")
                             .append(this.getClass().getName())
                             .append(".");
Index: core-library/src/main/java/org/apache/james/services/FileSystem.java
===================================================================
--- core-library/src/main/java/org/apache/james/services/FileSystem.java	(revision 564411)
+++ core-library/src/main/java/org/apache/james/services/FileSystem.java	(working copy)
@@ -21,6 +21,8 @@
 
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
 
 /**
  * This service is used by components that wants to lookup a File resource
@@ -41,6 +43,18 @@
      */
     public File getFile(String fileURL) throws FileNotFoundException;
 
+    
+    /**
+     * Used to retrieve a specific file or resource from the application context, 
+     * or from the class path.
+     * 
+     * @param url the url of the resource
+     * @return the resource as an input stream
+     * @throws IOException if the resource not found
+     */
+    public InputStream getResource(String url) throws IOException;
+    
+    
     /**
      * Return the base folder used by the application 
      */
Index: core-library/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java
===================================================================
--- core-library/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java	(revision 564411)
+++ core-library/src/main/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java	(working copy)
@@ -34,6 +34,7 @@
 import org.apache.james.util.SqlResources;
 
 import java.io.File;
+import java.io.InputStream;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.PreparedStatement;
@@ -387,10 +388,10 @@
         try {
             DatabaseMetaData dbMetaData = conn.getMetaData();
 
-            File sqlFile = null;
+            InputStream sqlFile = null;
 
             try {
-                sqlFile = fileSystem.getFile(m_sqlFileName);
+                sqlFile = fileSystem.getResource(m_sqlFileName);
             } catch (Exception e) {
                 getLogger().fatalError(e.getMessage(), e);
                 throw e;
@@ -398,8 +399,8 @@
 
             if (getLogger().isDebugEnabled()) {
                 logBuffer = new StringBuffer(256).append(
-                        "Reading SQL resources from file: ").append(
-                        sqlFile.getAbsolutePath()).append(", section ").append(
+                        "Reading SQL resources from: ").append(
+                        m_sqlFileName).append(", section ").append(
                         this.getClass().getName()).append(".");
                 getLogger().debug(logBuffer.toString());
             }
Index: core-library/src/main/java/org/apache/james/util/SqlResources.java
===================================================================
--- core-library/src/main/java/org/apache/james/util/SqlResources.java	(revision 564411)
+++ core-library/src/main/java/org/apache/james/util/SqlResources.java	(working copy)
@@ -31,6 +31,7 @@
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import java.io.File;
+import java.io.InputStream;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.HashMap;
@@ -94,7 +95,51 @@
         DocumentBuilder builder = factory.newDocumentBuilder();
         Document sqlDoc = builder.parse(sqlFile);
 
-        // First process the database matcher, to determine the
+        init(sqlDoc, sqlDefsSection, conn, configParameters);
+    }
+    
+    /**
+     * Configures a DbResources object to provide SQL statements from an InputStream.
+     * 
+     * SQL statements returned may be specific to the particular type
+     * and version of the connected database, as well as the database driver.
+     * 
+     * Parameters encoded as $(parameter} in the input file are
+     * replace by values from the parameters Map, if the named parameter exists.
+     * Parameter values may also be specified in the resourceSection element.
+     * 
+     * @param sqlFile    the input stream containing the xml
+     * @param sqlDefsSection
+     *                   the xml element containing the strings to be used
+     * @param conn the Jdbc DatabaseMetaData, taken from a database connection
+     * @param configParameters a map of parameters (name-value string pairs) which are
+     *                   replaced where found in the input strings
+     */
+    public void init(InputStream input, String sqlDefsSection,
+                     Connection conn, Map configParameters)
+        throws Exception
+    {
+        // Parse the InputStream as an XML document.
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        DocumentBuilder builder = factory.newDocumentBuilder();
+        Document sqlDoc = builder.parse(input);
+
+        init(sqlDoc, sqlDefsSection, conn, configParameters);
+    }
+    
+
+    /**
+     * Configures a SqlResources object from an xml document.
+     * 
+     * @param sqlDoc
+     * @param sqlDefsSection
+     * @param conn
+     * @param configParameters
+     * @throws SQLException
+     */
+	protected void init(Document sqlDoc, String sqlDefsSection,
+			Connection conn, Map configParameters) throws SQLException {
+		// First process the database matcher, to determine the
         //  sql statements to use.
         Element dbMatcherElement = 
             (Element)(sqlDoc.getElementsByTagName("dbMatchers").item(0));
@@ -223,7 +268,7 @@
         // Copy in default strings, then overwrite product-specific ones.
         m_sql.putAll(defaultSqlStatements);
         m_sql.putAll(dbProductSqlStatements);
-    }
+	}
 
     /**
      * Compares the DatabaseProductName value for a jdbc Connection
Index: core-library/src/main/java/org/apache/james/vut/JDBCVirtualUserTable.java
===================================================================
--- core-library/src/main/java/org/apache/james/vut/JDBCVirtualUserTable.java	(revision 564411)
+++ core-library/src/main/java/org/apache/james/vut/JDBCVirtualUserTable.java	(working copy)
@@ -23,6 +23,7 @@
 package org.apache.james.vut;
 
 import java.io.File;
+import java.io.InputStream;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.PreparedStatement;
@@ -175,10 +176,9 @@
         try {
             // Initialise the sql strings.
 
-            File sqlFile = null;
+            InputStream sqlFile = null;
             try {
-                sqlFile = fileSystem.getFile(sqlFileName);
-                sqlFileName = null;
+                sqlFile = fileSystem.getResource(sqlFileName);
             } catch (Exception e) {
                 getLogger().fatalError(e.getMessage(), e);
                 throw e;
@@ -188,7 +188,7 @@
                 logBuffer =
                     new StringBuffer(128)
                             .append("Reading SQL resources from file: ")
-                            .append(sqlFile.getAbsolutePath())
+                            .append(sqlFileName)
                             .append(", section ")
                             .append(this.getClass().getName())
                             .append(".");
Index: phoenix-deployment/src/test/org/apache/james/JamesTest.java
===================================================================
--- phoenix-deployment/src/test/org/apache/james/JamesTest.java	(revision 564411)
+++ phoenix-deployment/src/test/org/apache/james/JamesTest.java	(working copy)
@@ -40,7 +40,10 @@
 import org.apache.james.userrepository.MockUsersRepository;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
@@ -82,6 +85,23 @@
     }
 
 
+    private abstract class BaseFileSystem implements FileSystem { 
+        /**
+         * @see org.apache.james.services.FileSystem#getResource(String)
+         */
+        public InputStream getResource(String url) throws IOException {
+        	if (url.startsWith("classpath://")) {
+        		String resourceName = url.substring("classpath://".length());
+    			InputStream resourceAsStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
+        		if (resourceAsStream==null) {
+        			throw new IOException("Resource '"+resourceName+"' not found in the classpath!");
+        		}
+        		return resourceAsStream;
+        	}
+        	return new FileInputStream(getFile(url));
+        }
+
+    }
 
     private MockServiceManager setUpServiceManager() {
         MockServiceManager serviceManager = new MockServiceManager();
@@ -88,7 +108,7 @@
         MockUsersRepository mockUsersRepository = new MockUsersRepository();
         serviceManager.put(UsersRepository.ROLE, mockUsersRepository);
         serviceManager.put(UsersStore.ROLE, new MockUsersStore(mockUsersRepository));
-        serviceManager.put(FileSystem.ROLE, new FileSystem() {
+        serviceManager.put(FileSystem.ROLE, new BaseFileSystem() {
 
             public File getBasedir() throws FileNotFoundException {
                 return new File(".");
@@ -98,6 +118,7 @@
                 return new File("./conf/");
             }
             
+            
         });
         serviceManager.put(DomainList.ROLE, new DomainList() {
 
Index: phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java
===================================================================
--- phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java	(revision 564411)
+++ phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java	(working copy)
@@ -22,7 +22,10 @@
 import org.apache.james.services.FileSystem;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
 
 public class MockFileSystem implements FileSystem {
     public File getBasedir() throws FileNotFoundException {
@@ -40,4 +43,20 @@
             throw new UnsupportedOperationException("getFile: "+fileURL);
         }
     }
+    
+    /**
+     * @see org.apache.james.services.FileSystem#getResource(String)
+     */
+    public InputStream getResource(String url) throws IOException {
+    	if (url.startsWith("classpath://")) {
+    		String resourceName = url.substring("classpath://".length());
+			InputStream resourceAsStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
+    		if (resourceAsStream==null) {
+    			throw new IOException("Resource '"+resourceName+"' not found in the classpath!");
+    		}
+    		return resourceAsStream;
+    	}
+    	return new FileInputStream(getFile(url));
+    }
+
 }
Index: phoenix-deployment/src/test/org/apache/james/userrepository/UsersFileRepositoryTest.java
===================================================================
--- phoenix-deployment/src/test/org/apache/james/userrepository/UsersFileRepositoryTest.java	(revision 564411)
+++ phoenix-deployment/src/test/org/apache/james/userrepository/UsersFileRepositoryTest.java	(working copy)
@@ -34,6 +34,8 @@
 
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.Collection;
 import java.util.Iterator;
 
@@ -61,6 +63,11 @@
                 throw new UnsupportedOperationException();
             }
             
+            @Override
+            public InputStream getResource(String url) throws IOException {
+                throw new UnsupportedOperationException();
+            }
+            
         });
         MockStore mockStore = new MockStore();
         File_Persistent_Object_Repository file_Persistent_Object_Repository = new File_Persistent_Object_Repository();
