Author: berndf
Date: Sun Aug 12 02:51:20 2007
New Revision: 565030
URL: http://svn.apache.org/viewvc?view=rev&rev=565030
Log:
add capability to load resource files from other sources than direct file
system access.
James/Avalon default implementation is still only using file system, though.
Modified:
james/server/trunk/core-library/src/main/java/org/apache/james/context/AvalonFileSystem.java
james/server/trunk/core-library/src/main/java/org/apache/james/services/FileSystem.java
james/server/trunk/phoenix-deployment/src/test/org/apache/james/JamesTest.java
james/server/trunk/phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java
james/server/trunk/phoenix-deployment/src/test/org/apache/james/userrepository/UsersFileRepositoryTest.java
Modified:
james/server/trunk/core-library/src/main/java/org/apache/james/context/AvalonFileSystem.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/context/AvalonFileSystem.java?view=diff&rev=565030&r1=565029&r2=565030
==============================================================================
---
james/server/trunk/core-library/src/main/java/org/apache/james/context/AvalonFileSystem.java
(original)
+++
james/server/trunk/core-library/src/main/java/org/apache/james/context/AvalonFileSystem.java
Sun Aug 12 02:51:20 2007
@@ -26,6 +26,9 @@
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.FileInputStream;
/**
* Avalon implementation of the FileSystem service
@@ -38,6 +41,14 @@
* Avalon context used by this implementation
*/
private Context context;
+
+ /**
+ * delegates to method getFile() and returns file as InputStream.
+ * @see
org.apache.james.context.AvalonFileSystem#getFile(java.lang.String)
+ */
+ public InputStream getResource(String url) throws IOException {
+ return new FileInputStream(getFile(url));
+ }
/**
* @see org.apache.james.services.FileSystem#getFile(java.lang.String)
Modified:
james/server/trunk/core-library/src/main/java/org/apache/james/services/FileSystem.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/services/FileSystem.java?view=diff&rev=565030&r1=565029&r2=565030
==============================================================================
---
james/server/trunk/core-library/src/main/java/org/apache/james/services/FileSystem.java
(original)
+++
james/server/trunk/core-library/src/main/java/org/apache/james/services/FileSystem.java
Sun Aug 12 02:51:20 2007
@@ -21,6 +21,8 @@
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.IOException;
/**
* This service is used by components that wants to lookup a File resource
@@ -31,6 +33,17 @@
public interface FileSystem {
String ROLE = "org.apache.james.services.FileSystem";
+
+ /**
+ * to retrieve a resource. this is typically a file resource,
+ * but depending on the implementation, this could also be from classpath
or
+ * from another source.
+ *
+ * @param url the url of the resource
+ * @return the resource as an input stream
+ * @throws IOException if the resource could not be accessed
+ */
+ public InputStream getResource(String url) throws IOException;
/**
* Used to retrieve a specific file in the application context
Modified:
james/server/trunk/phoenix-deployment/src/test/org/apache/james/JamesTest.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/JamesTest.java?view=diff&rev=565030&r1=565029&r2=565030
==============================================================================
---
james/server/trunk/phoenix-deployment/src/test/org/apache/james/JamesTest.java
(original)
+++
james/server/trunk/phoenix-deployment/src/test/org/apache/james/JamesTest.java
Sun Aug 12 02:51:20 2007
@@ -41,6 +41,9 @@
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.FileInputStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -92,6 +95,10 @@
public File getBasedir() throws FileNotFoundException {
return new File(".");
+ }
+
+ public InputStream getResource(String url) throws IOException {
+ return new FileInputStream(getFile(url));
}
public File getFile(String fileURL) throws FileNotFoundException {
Modified:
james/server/trunk/phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java?view=diff&rev=565030&r1=565029&r2=565030
==============================================================================
---
james/server/trunk/phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java
(original)
+++
james/server/trunk/phoenix-deployment/src/test/org/apache/james/test/mock/james/MockFileSystem.java
Sun Aug 12 02:51:20 2007
@@ -23,10 +23,17 @@
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.FileInputStream;
public class MockFileSystem implements FileSystem {
public File getBasedir() throws FileNotFoundException {
return new File(".");
+ }
+
+ public InputStream getResource(String url) throws IOException {
+ return new FileInputStream(getFile(url));
}
public File getFile(String fileURL) throws FileNotFoundException {
Modified:
james/server/trunk/phoenix-deployment/src/test/org/apache/james/userrepository/UsersFileRepositoryTest.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/userrepository/UsersFileRepositoryTest.java?view=diff&rev=565030&r1=565029&r2=565030
==============================================================================
---
james/server/trunk/phoenix-deployment/src/test/org/apache/james/userrepository/UsersFileRepositoryTest.java
(original)
+++
james/server/trunk/phoenix-deployment/src/test/org/apache/james/userrepository/UsersFileRepositoryTest.java
Sun Aug 12 02:51:20 2007
@@ -34,6 +34,9 @@
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.FileInputStream;
import java.util.Collection;
import java.util.Iterator;
@@ -55,6 +58,10 @@
public File getBasedir() throws FileNotFoundException {
return new File(".");
+ }
+
+ public InputStream getResource(String url) throws IOException {
+ return new FileInputStream(getFile(url));
}
public File getFile(String fileURL) throws FileNotFoundException {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]