You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by be...@apache.org on 2007/08/13 16:10:09 UTC
svn commit: r565357 -
/james/server/sandbox/spring-integration/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java
Author: berndf
Date: Mon Aug 13 07:10:08 2007
New Revision: 565357
URL: http://svn.apache.org/viewvc?view=rev&rev=565357
Log:
implement extended interface FileManager and add classpath loading capabilities.
see JAMES-803, thanks for the initial patch to Zsombor.
also, fix the hardcoded file loading behavior for conf files (which will be made configurable in another step)
Modified:
james/server/sandbox/spring-integration/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java
Modified: james/server/sandbox/spring-integration/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java?view=diff&rev=565357&r1=565356&r2=565357
==============================================================================
--- james/server/sandbox/spring-integration/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java (original)
+++ james/server/sandbox/spring-integration/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java Mon Aug 13 07:10:08 2007
@@ -20,24 +20,47 @@
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.FileInputStream;
import org.apache.james.services.FileSystem;
public class FileSystemBridge implements FileSystem {
+ private static final String FILE_PROTOCOL = "file://";
+ private static final String FILE_PROTOCOL_AND_CONF = "file://conf/";
- public File getBasedir() throws FileNotFoundException {
+ public File getBasedir() throws FileNotFoundException {
return new File(".");
}
+ /**
+ * loads resources from classpath or file system
+ */
+ 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.james.services.FileSystem#getFile(String filURL)
+ */
public File getFile(String fileURL) throws FileNotFoundException {
- if (fileURL.startsWith("file://")) {
- if (fileURL.startsWith("file://conf/")) {
- return new File("./src/trunk/config/"+fileURL.substring(12));
+ if (fileURL.startsWith(FILE_PROTOCOL)) {
+ if (fileURL.startsWith(FILE_PROTOCOL_AND_CONF)) {
+ return new File("./src/main/config/" + FILE_PROTOCOL_AND_CONF.substring(12));
} else {
- return new File("./"+fileURL.substring(7));
+ return new File("./" + FILE_PROTOCOL.substring(7));
}
} else {
- throw new UnsupportedOperationException("getFile: "+fileURL);
+ throw new UnsupportedOperationException("getFile: " + fileURL);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
Re: svn commit: r565357 - /james/server/sandbox/spring-integration/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java
Posted by Stefano Bagnara <ap...@bago.org>.
Bernd Fondermann ha scritto:
> Thanks, I already noted this misfactorization. Working on a corrected
> revision.
> Also re-checking my IDE setup.
If you use Eclipse, I usually take the standard "Java Convention
[built-in]" but I open the preferences for it and change the "Tab
policy" to "Spaces only".
I still have to understand why they did changed the default tab policies
in Eclipse 3.1 :-( The mixed style does not make sense at all, IMHO.
Thank you,
Stefano
> Bernd
>
> Stefano Bagnara wrote:
>> berndf@apache.org ha scritto:
>>> Author: berndf
>>> Date: Mon Aug 13 07:10:08 2007
>>> New Revision: 565357
>>>
>>> URL: http://svn.apache.org/viewvc?view=rev&rev=565357
>>> Log:
>>> implement extended interface FileManager and add classpath loading
>>> capabilities.
>>> see JAMES-803, thanks for the initial patch to Zsombor.
>>> also, fix the hardcoded file loading behavior for conf files (which
>>> will be made configurable in another step)
>>> [...]
>>> + private static final String FILE_PROTOCOL = "file://";
>>> + private static final String FILE_PROTOCOL_AND_CONF =
>>> "file://conf/";
>>> [...]
>>> - if (fileURL.startsWith("file://")) {
>>> - if (fileURL.startsWith("file://conf/")) {
>>> - return new
>>> File("./src/trunk/config/"+fileURL.substring(12));
>>> + if (fileURL.startsWith(FILE_PROTOCOL)) {
>>> + if (fileURL.startsWith(FILE_PROTOCOL_AND_CONF)) {
>>> + return new File("./src/main/config/" +
>>> FILE_PROTOCOL_AND_CONF.substring(12));
>>> } else {
>>> - return new File("./"+fileURL.substring(7));
>>> + return new File("./" + FILE_PROTOCOL.substring(7));
>>> }
>>
>> I think this is not correct.
>> fileURL.substring(12) cannot be replaced by
>> FILE_PROTOCOL_AND_CONF.substring(12)
>> also
>> fileURL.substring(7)
>> cannot be replaced by
>> FILE_PROTOCOL.substring(7)
>>
>> I think this does not work at all.
>>
>> Also, there are some TABS instead of SPACES left around (maybe they was
>> there before your patch)
>>
>> Stefano
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
Re: svn commit: r565357 - /james/server/sandbox/spring-integration/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java
Posted by Bernd Fondermann <bf...@brainlounge.de>.
Thanks, I already noted this misfactorization. Working on a corrected
revision.
Also re-checking my IDE setup.
Bernd
Stefano Bagnara wrote:
> berndf@apache.org ha scritto:
>> Author: berndf
>> Date: Mon Aug 13 07:10:08 2007
>> New Revision: 565357
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=565357
>> Log:
>> implement extended interface FileManager and add classpath loading capabilities.
>> see JAMES-803, thanks for the initial patch to Zsombor.
>> also, fix the hardcoded file loading behavior for conf files (which will be made configurable in another step)
>> [...]
>> + private static final String FILE_PROTOCOL = "file://";
>> + private static final String FILE_PROTOCOL_AND_CONF = "file://conf/";
>> [...]
>> - if (fileURL.startsWith("file://")) {
>> - if (fileURL.startsWith("file://conf/")) {
>> - return new File("./src/trunk/config/"+fileURL.substring(12));
>> + if (fileURL.startsWith(FILE_PROTOCOL)) {
>> + if (fileURL.startsWith(FILE_PROTOCOL_AND_CONF)) {
>> + return new File("./src/main/config/" + FILE_PROTOCOL_AND_CONF.substring(12));
>> } else {
>> - return new File("./"+fileURL.substring(7));
>> + return new File("./" + FILE_PROTOCOL.substring(7));
>> }
>
> I think this is not correct.
> fileURL.substring(12) cannot be replaced by
> FILE_PROTOCOL_AND_CONF.substring(12)
> also
> fileURL.substring(7)
> cannot be replaced by
> FILE_PROTOCOL.substring(7)
>
> I think this does not work at all.
>
> Also, there are some TABS instead of SPACES left around (maybe they was
> there before your patch)
>
> Stefano
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
Re: svn commit: r565357 - /james/server/sandbox/spring-integration/spring-deployment/src/main/java/org/apache/james/container/spring/adaptor/FileSystemBridge.java
Posted by Stefano Bagnara <ap...@bago.org>.
berndf@apache.org ha scritto:
> Author: berndf
> Date: Mon Aug 13 07:10:08 2007
> New Revision: 565357
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=565357
> Log:
> implement extended interface FileManager and add classpath loading capabilities.
> see JAMES-803, thanks for the initial patch to Zsombor.
> also, fix the hardcoded file loading behavior for conf files (which will be made configurable in another step)
> [...]
> + private static final String FILE_PROTOCOL = "file://";
> + private static final String FILE_PROTOCOL_AND_CONF = "file://conf/";
> [...]
> - if (fileURL.startsWith("file://")) {
> - if (fileURL.startsWith("file://conf/")) {
> - return new File("./src/trunk/config/"+fileURL.substring(12));
> + if (fileURL.startsWith(FILE_PROTOCOL)) {
> + if (fileURL.startsWith(FILE_PROTOCOL_AND_CONF)) {
> + return new File("./src/main/config/" + FILE_PROTOCOL_AND_CONF.substring(12));
> } else {
> - return new File("./"+fileURL.substring(7));
> + return new File("./" + FILE_PROTOCOL.substring(7));
> }
I think this is not correct.
fileURL.substring(12) cannot be replaced by
FILE_PROTOCOL_AND_CONF.substring(12)
also
fileURL.substring(7)
cannot be replaced by
FILE_PROTOCOL.substring(7)
I think this does not work at all.
Also, there are some TABS instead of SPACES left around (maybe they was
there before your patch)
Stefano
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org