You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by rg...@apache.org on 2009/09/13 08:26:24 UTC
svn commit: r814264 [1/2] - in /commons/proper/vfs/branches/VFS281: ./
core/src/main/java/org/apache/commons/vfs/
core/src/main/java/org/apache/commons/vfs/impl/
core/src/main/java/org/apache/commons/vfs/provider/
core/src/main/java/org/apache/commons/...
Author: rgoers
Date: Sun Sep 13 06:26:23 2009
New Revision: 814264
URL: http://svn.apache.org/viewvc?rev=814264&view=rev
Log:
Implement changes to address VFS-281
Added:
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/DefaultFileSystemOptions.java (contents, props changed)
- copied, changed from r805870, commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileSystemConfigBuilder.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemOptions.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemOptions.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemOptions.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileSystemOptions.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/ProxyType.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemOptions.java
- copied, changed from r812334, commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemOptions.java
Modified:
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemConfigBuilder.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemManager.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemOptions.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemConfigBuilder.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FTPClientWrapper.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpClientFactory.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystem.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileProvider.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemConfigBuilder.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileProvider.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/res/ResourceFileSystemConfigBuilder.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystem.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/util/UserAuthenticatorUtils.java
commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/ftp/test/FtpProviderTestCase.java
commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/ram/test/CustomRamProviderTest.java
commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/sftp/test/SftpProviderTestCase.java
commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavProviderTestCase.java
commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/provider/webdav/test/WebdavVersioningTests.java
commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/commons/vfs/util/DelegatingFileSystemOptionsBuilderTest.java
commons/proper/vfs/branches/VFS281/pom.xml
Copied: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/DefaultFileSystemOptions.java (from r805870, commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileSystemConfigBuilder.java)
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/DefaultFileSystemOptions.java?p2=commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/DefaultFileSystemOptions.java&p1=commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileSystemConfigBuilder.java&r1=805870&r2=814264&rev=814264&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/DefaultFileSystemOptions.java Sun Sep 13 06:26:23 2009
@@ -19,10 +19,10 @@
/**
* Abstract class which has the right to fill FileSystemOptions.
*
- * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
* @version $Revision$ $Date$
*/
-public abstract class FileSystemConfigBuilder
+public class DefaultFileSystemOptions extends FileSystemOptions
{
/** Default prefix to use when resolving system properties */
private static final String PREFIX = "vfs.";
@@ -33,74 +33,93 @@
/** The prefix to use when resolving system properties */
private final String prefix;
- protected FileSystemConfigBuilder()
+ /**
+ *
+ */
+ protected DefaultFileSystemOptions()
{
this.prefix = PREFIX;
}
- protected FileSystemConfigBuilder(String component)
+
+ /**
+ * @param component The component String;
+ */
+ protected DefaultFileSystemOptions(String component)
{
this.prefix = PREFIX + component;
}
/**
* The root URI of the file system.
- * @param opts The FileSystem options
* @param rootURI The creator name to be associated with the file.
*/
- public void setRootURI(FileSystemOptions opts, String rootURI)
+ public void setRootURI(String rootURI)
{
- setParam(opts, ROOTURI, rootURI);
+ setParam(ROOTURI, rootURI);
}
/**
* Return the root URI of the file system.
- * @param opts The FileSystem options
* @return The root URI.
*/
- public String getRootURI(FileSystemOptions opts)
+ public String getRootURI()
{
- return getString(opts, ROOTURI);
+ return getString(ROOTURI);
}
+ /**
+ * Sets the user authenticator to get authentication informations.
+ * @param userAuthenticator The UserAuthenticator.
+ * @throws FileSystemException if an error occurs setting the UserAuthenticator.
+ */
+ public void setUserAuthenticator(UserAuthenticator userAuthenticator)
+ throws FileSystemException
+ {
+ setParam("userAuthenticator", userAuthenticator);
+ }
- protected void setParam(FileSystemOptions opts, String name, Object value)
+ /**
+ * @see #setUserAuthenticator
+ * @return The UserAuthenticator.
+ */
+ public UserAuthenticator getUserAuthenticator()
{
- opts.setOption(getConfigClass(), name, value);
+ return (UserAuthenticator) getParam("userAuthenticator");
}
- protected Object getParam(FileSystemOptions opts, String name)
+ protected void setParam(String name, Object value)
{
- if (opts == null)
- {
- return null;
- }
+ setOption(this.getClass(), name, value);
+ }
- return opts.getOption(getConfigClass(), name);
+ protected Object getParam(String name)
+ {
+ return getOption(this.getClass(), name);
}
- protected boolean hasParam(FileSystemOptions opts, String name)
+ protected boolean hasParam(String name)
{
- return opts != null && opts.hasOption(getConfigClass(), name);
+ return hasOption(this.getClass(), name);
}
- protected boolean hasObject(FileSystemOptions opts, String name)
+ protected boolean hasObject(String name)
{
- return hasParam(opts, name) || System.getProperties().containsKey(PREFIX + name);
+ return hasParam(name) || System.getProperties().containsKey(PREFIX + name);
}
- protected Boolean getBoolean(FileSystemOptions opts, String name)
+ protected Boolean getBoolean(String name)
{
- return getBoolean(opts, name, null);
+ return getBoolean(name, null);
}
- protected boolean getBoolean(FileSystemOptions opts, String name, boolean defaultValue)
+ protected boolean getBoolean(String name, boolean defaultValue)
{
- return getBoolean(opts, name, new Boolean(defaultValue)).booleanValue();
+ return getBoolean(name, new Boolean(defaultValue)).booleanValue();
}
- protected Boolean getBoolean(FileSystemOptions opts, String name, Boolean defaultValue)
+ protected Boolean getBoolean(String name, Boolean defaultValue)
{
- Boolean value = (Boolean) getParam(opts, name);
+ Boolean value = (Boolean) getParam(name);
if (value == null)
{
String str = System.getProperty(PREFIX + name);
@@ -113,19 +132,19 @@
return value;
}
- protected Byte getByte(FileSystemOptions opts, String name)
+ protected Byte getByte(String name)
{
- return getByte(opts, name, null);
+ return getByte(name, null);
}
- protected byte getByte(FileSystemOptions opts, String name, byte defaultValue)
+ protected byte getByte(String name, byte defaultValue)
{
- return getByte(opts, name, new Byte(defaultValue)).byteValue();
+ return getByte(name, new Byte(defaultValue)).byteValue();
}
- protected Byte getByte(FileSystemOptions opts, String name, Byte defaultValue)
+ protected Byte getByte(String name, Byte defaultValue)
{
- Byte value = (Byte) getParam(opts, name);
+ Byte value = (Byte) getParam(name);
if (value == null)
{
String str = System.getProperty(this.prefix + name);
@@ -138,19 +157,19 @@
return value;
}
- protected Character getCharacter(FileSystemOptions opts, String name)
+ protected Character getCharacter(String name)
{
- return getCharacter(opts, name, null);
+ return getCharacter(name, null);
}
- protected char getCharacter(FileSystemOptions opts, String name, char defaultValue)
+ protected char getCharacter(String name, char defaultValue)
{
- return getCharacter(opts, name, new Character(defaultValue)).charValue();
+ return getCharacter(name, new Character(defaultValue)).charValue();
}
- protected Character getCharacter(FileSystemOptions opts, String name, Character defaultValue)
+ protected Character getCharacter(String name, Character defaultValue)
{
- Character value = (Character) getParam(opts, name);
+ Character value = (Character) getParam(name);
if (value == null)
{
String str = System.getProperty(this.prefix + name);
@@ -163,19 +182,19 @@
return value;
}
- protected Double getDouble(FileSystemOptions opts, String name)
+ protected Double getDouble(String name)
{
- return getDouble(opts, name, null);
+ return getDouble(name, null);
}
- protected double getDouble(FileSystemOptions opts, String name, double defaultValue)
+ protected double getDouble(String name, double defaultValue)
{
- return getDouble(opts, name, new Double(defaultValue)).doubleValue();
+ return getDouble(name, new Double(defaultValue)).doubleValue();
}
- protected Double getDouble(FileSystemOptions opts, String name, Double defaultValue)
+ protected Double getDouble(String name, Double defaultValue)
{
- Double value = (Double) getParam(opts, name);
+ Double value = (Double) getParam(name);
if (value == null)
{
String str = System.getProperty(this.prefix + name);
@@ -188,19 +207,19 @@
return value;
}
- protected Float getFloat(FileSystemOptions opts, String name)
+ protected Float getFloat(String name)
{
- return getFloat(opts, name, null);
+ return getFloat(name, null);
}
- protected float getFloat(FileSystemOptions opts, String name, float defaultValue)
+ protected float getFloat(String name, float defaultValue)
{
- return getFloat(opts, name, new Float(defaultValue)).floatValue();
+ return getFloat(name, new Float(defaultValue)).floatValue();
}
- protected Float getFloat(FileSystemOptions opts, String name, Float defaultValue)
+ protected Float getFloat(String name, Float defaultValue)
{
- Float value = (Float) getParam(opts, name);
+ Float value = (Float) getParam(name);
if (value == null)
{
String str = System.getProperty(this.prefix + name);
@@ -213,19 +232,19 @@
return value;
}
- protected Integer getInteger(FileSystemOptions opts, String name)
+ protected Integer getInteger(String name)
{
- return getInteger(opts, name, null);
+ return getInteger(name, null);
}
- protected int getInteger(FileSystemOptions opts, String name, int defaultValue)
+ protected int getInteger(String name, int defaultValue)
{
- return getInteger(opts, name, new Integer(defaultValue)).intValue();
+ return getInteger(name, new Integer(defaultValue)).intValue();
}
- protected Integer getInteger(FileSystemOptions opts, String name, Integer defaultValue)
+ protected Integer getInteger(String name, Integer defaultValue)
{
- Integer value = (Integer) getParam(opts, name);
+ Integer value = (Integer) getParam(name);
if (value == null)
{
String str = System.getProperty(this.prefix + name);
@@ -238,19 +257,19 @@
return value;
}
- protected Long getLong(FileSystemOptions opts, String name)
+ protected Long getLong(String name)
{
- return getLong(opts, name, null);
+ return getLong(name, null);
}
- protected long getLong(FileSystemOptions opts, String name, long defaultValue)
+ protected long getLong(String name, long defaultValue)
{
- return getLong(opts, name, new Long(defaultValue)).longValue();
+ return getLong(name, new Long(defaultValue)).longValue();
}
- protected Long getLong(FileSystemOptions opts, String name, Long defaultValue)
+ protected Long getLong(String name, Long defaultValue)
{
- Long value = (Long) getParam(opts, name);
+ Long value = (Long) getParam(name);
if (value == null)
{
String str = System.getProperty(this.prefix + name);
@@ -263,19 +282,19 @@
return value;
}
- protected Short getShort(FileSystemOptions opts, String name)
+ protected Short getShort(String name)
{
- return getShort(opts, name, null);
+ return getShort(name, null);
}
- protected short getShort(FileSystemOptions opts, String name, short defaultValue)
+ protected short getShort(String name, short defaultValue)
{
- return getShort(opts, name, new Short(defaultValue)).shortValue();
+ return getShort(name, new Short(defaultValue)).shortValue();
}
- protected Short getShort(FileSystemOptions opts, String name, Short defaultValue)
+ protected Short getShort(String name, Short defaultValue)
{
- Short value = (Short) getParam(opts, name);
+ Short value = (Short) getParam(name);
if (value == null)
{
String str = System.getProperty(this.prefix + name);
@@ -288,14 +307,14 @@
return value;
}
- protected String getString(FileSystemOptions opts, String name)
+ protected String getString(String name)
{
- return getString(opts, name, null);
+ return getString(name, null);
}
- protected String getString(FileSystemOptions opts, String name, String defaultValue)
+ protected String getString(String name, String defaultValue)
{
- String value = (String) getParam(opts, name);
+ String value = (String) getParam(name);
if (value == null)
{
value = System.getProperty(this.prefix + name);
@@ -306,6 +325,4 @@
}
return value;
}
-
- protected abstract Class getConfigClass();
-}
+}
\ No newline at end of file
Propchange: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/DefaultFileSystemOptions.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/DefaultFileSystemOptions.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemConfigBuilder.java Sun Sep 13 06:26:23 2009
@@ -21,6 +21,7 @@
*
* @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
* @version $Revision$ $Date$
+ * @deprecated Use FileSystemOptions classes instead.
*/
public abstract class FileSystemConfigBuilder
{
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemManager.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemManager.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemManager.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemManager.java Sun Sep 13 06:26:23 2009
@@ -297,6 +297,14 @@
FileSystemConfigBuilder getFileSystemConfigBuilder(final String scheme) throws FileSystemException;
/**
+ * Get the FileSystemOptions for the specified scheme.
+ * @param scheme The protocol.
+ * @return The FileSystemOptions for the specified scheme.
+ * @throws FileSystemException if an error occurs.
+ */
+ FileSystemOptions getFileSystemOptions(final String scheme) throws FileSystemException;
+
+ /**
* Resolve the uri to a filename.
*
* @param uri The uri to resolve.
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemOptions.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemOptions.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemOptions.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemOptions.java Sun Sep 13 06:26:23 2009
@@ -26,14 +26,34 @@
*
* @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
* @version $Revision$ $Date$
- * @see org.apache.commons.vfs.provider.sftp.SftpFileSystemConfigBuilder
- * @see org.apache.commons.vfs.provider.ftp.FtpFileSystemConfigBuilder
*/
-public final class FileSystemOptions implements Cloneable
+public class FileSystemOptions implements Cloneable
{
/** The options */
private Map options = new TreeMap();
+ public static <T extends FileSystemOptions> T makeSpecific(Class<T> clazz, FileSystemOptions fsOptions)
+ {
+ if (fsOptions == null)
+ {
+ return null;
+ }
+ if (clazz.isAssignableFrom(fsOptions.getClass()))
+ {
+ return (T) fsOptions;
+ }
+ try
+ {
+ T obj = clazz.newInstance();
+ obj.options = fsOptions.options;
+ return obj;
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
+ }
+
/**
* Keys in the options Map.
*/
@@ -165,10 +185,11 @@
/**
* {@inheritDoc}
*/
- public Object clone() {
- FileSystemOptions clone = new FileSystemOptions();
+ public Object clone() throws CloneNotSupportedException
+ {
+ FileSystemOptions clone = (FileSystemOptions) super.clone();
clone.options = new TreeMap(options);
return clone;
}
-
+
}
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemConfigBuilder.java Sun Sep 13 06:26:23 2009
@@ -24,6 +24,7 @@
/**
* Default options usable for all filesystems.
* @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ * @deprecated Use AbstractFileSystemOptions
*/
public class DefaultFileSystemConfigBuilder extends FileSystemConfigBuilder
{
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java Sun Sep 13 06:26:23 2009
@@ -81,7 +81,7 @@
/**
* Mapping from URI scheme to FileProvider.
*/
- private final Map providers = new HashMap();
+ private final Map<String, FileProvider> providers = new HashMap<String, FileProvider>();
/**
* All components used by this manager.
@@ -1077,6 +1077,7 @@
* @param scheme The scheme to locate.
* @return The FileSystemConfigBuilder for the scheme.
* @throws FileSystemException if the given scheme is not konwn
+ * @deprecated - Use the FileSystemOptions for the scheme.
*/
public FileSystemConfigBuilder getFileSystemConfigBuilder(final String scheme)
throws FileSystemException
@@ -1090,6 +1091,23 @@
return provider.getConfigBuilder();
}
+ /**
+ * Get the FileSystemOptions for the specified scheme.
+ * @param scheme The protocol.
+ * @return The FileSystemOptions for the specified scheme.
+ * @throws FileSystemException if an error occurs.
+ */
+ public FileSystemOptions getFileSystemOptions(final String scheme)
+ throws FileSystemException
+ {
+ FileProvider provider = providers.get(scheme);
+ if (provider == null)
+ {
+ throw new FileSystemException("vfs.impl/unknown-scheme.error", new Object[] {scheme});
+ }
+ return provider.getFileSystemOptions();
+ }
+
// -- OPERATIONS --
/**
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java Sun Sep 13 06:26:23 2009
@@ -16,12 +16,7 @@
*/
package org.apache.commons.vfs.provider;
-import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystem;
-import org.apache.commons.vfs.FileSystemConfigBuilder;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.*;
import org.apache.commons.vfs.provider.local.GenericFileNameParser;
import java.util.Map;
@@ -45,11 +40,26 @@
// private final Map fileSystems = new HashMap();
private final Map fileSystems = new TreeMap();
+ private final Class<? extends FileSystemOptions> fileSystemOptionsClass;
+
private FileNameParser parser;
public AbstractFileProvider()
{
parser = GenericFileNameParser.getInstance();
+ fileSystemOptionsClass = DefaultFileSystemOptions.class;
+ }
+
+ protected AbstractFileProvider(Class<? extends FileSystemOptions> optionsClass)
+ {
+ parser = GenericFileNameParser.getInstance();
+ fileSystemOptionsClass = optionsClass;
+ }
+
+ protected AbstractFileProvider(FileNameParser fileNameParser, Class<? extends FileSystemOptions> optionsClass)
+ {
+ parser = fileNameParser;
+ fileSystemOptionsClass = optionsClass;
}
protected FileNameParser getFileNameParser()
@@ -191,4 +201,20 @@
throw new FileSystemException("vfs.provider/filename-parser-missing.error");
// return GenericFileName.parseUri(getFileNameParser(), uri, 0);
}
+
+ /**
+ * Returns a FileSystemOptions instance appropriate for this provider.
+ * @return The FileSystemOptions.
+ */
+ public FileSystemOptions getFileSystemOptions()
+ {
+ try
+ {
+ return fileSystemOptionsClass.newInstance();
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
+ }
}
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileSystem.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileSystem.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileSystem.java Sun Sep 13 06:26:23 2009
@@ -18,20 +18,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.commons.vfs.CacheStrategy;
-import org.apache.commons.vfs.Capability;
-import org.apache.commons.vfs.FileListener;
-import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSelector;
-import org.apache.commons.vfs.FileSystem;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileSystemManager;
-import org.apache.commons.vfs.FileSystemOptions;
-import org.apache.commons.vfs.FilesCache;
-import org.apache.commons.vfs.VfsLog;
-import org.apache.commons.vfs.FileSystemConfigBuilder;
-import org.apache.commons.vfs.impl.DefaultFileSystemConfigBuilder;
+import org.apache.commons.vfs.*;
import org.apache.commons.vfs.cache.OnCallRefreshFileObject;
import org.apache.commons.vfs.events.AbstractFileChangeEvent;
import org.apache.commons.vfs.events.ChangedEvent;
@@ -107,12 +94,40 @@
final FileObject parentLayer,
final FileSystemOptions fileSystemOptions)
{
+ this(rootName, parentLayer, fileSystemOptions, null);
+ }
+
+ protected AbstractFileSystem(final FileName rootName,
+ final FileObject parentLayer,
+ final FileSystemOptions fileSystemOptions,
+ final Class<? extends FileSystemOptions> optionsClass)
+ {
// this.parentLayer = parentLayer;
this.parentLayer = parentLayer;
this.rootName = rootName;
- this.fileSystemOptions = fileSystemOptions;
- FileSystemConfigBuilder builder = DefaultFileSystemConfigBuilder.getInstance();
- String uri = builder.getRootURI(fileSystemOptions);
+ if (optionsClass == null)
+ {
+ this.fileSystemOptions = fileSystemOptions == null ? new PrivateFileSystemOptions() : fileSystemOptions;
+ }
+ else
+ {
+ if (fileSystemOptions != null)
+ {
+ this.fileSystemOptions = FileSystemOptions.makeSpecific(optionsClass, fileSystemOptions);
+ }
+ else
+ {
+ try
+ {
+ this.fileSystemOptions = optionsClass.newInstance();
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalArgumentException("Invalid optiosn class", ex);
+ }
+ }
+ }
+ String uri = ((DefaultFileSystemOptions)this.fileSystemOptions).getRootURI();
if (uri == null)
{
uri = rootName.getURI();
@@ -437,6 +452,11 @@
return fileSystemOptions;
}
+ protected <T extends FileSystemOptions> T getOptions()
+ {
+ return (T) fileSystemOptions;
+ }
+
/**
* Return the FileSystemManager used to instantiate this filesystem.
* @return the FileSystemManager.
@@ -679,4 +699,9 @@
return openStreams > 0;
}
}
+
+ private class PrivateFileSystemOptions extends DefaultFileSystemOptions
+ {
+
+ }
}
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java Sun Sep 13 06:26:23 2009
@@ -38,6 +38,16 @@
super();
}
+ protected AbstractOriginatingFileProvider(Class<? extends FileSystemOptions> optionsClass)
+ {
+ super(optionsClass);
+ }
+
+ protected AbstractOriginatingFileProvider(FileNameParser fileNameParser, Class<? extends FileSystemOptions> optionsClass)
+ {
+ super(fileNameParser, optionsClass);
+ }
+
/**
* Locates a file object, by absolute URI.
*
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.java Sun Sep 13 06:26:23 2009
@@ -64,6 +64,7 @@
/**
* Gets the configbuilder useable to collect the needed fileSystemOptions.
* @return a FileSystemConfigBuilder for the particular file system.
+ * @deprecated - Use FileSystemOptions specific to the scheme instead.
*/
FileSystemConfigBuilder getConfigBuilder();
@@ -83,4 +84,10 @@
* @throws FileSystemException if an error occurs.
*/
FileName parseUri(FileName root, String uri) throws FileSystemException;
-}
+
+ /**
+ * Return FileSystemOptions appropriate for the specific provider.
+ * @return A FileSystemOptions instance.
+ */
+ FileSystemOptions getFileSystemOptions();
+}
\ No newline at end of file
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FTPClientWrapper.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FTPClientWrapper.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FTPClientWrapper.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FTPClientWrapper.java Sun Sep 13 06:26:23 2009
@@ -37,11 +37,11 @@
class FTPClientWrapper implements FtpClient
{
private final GenericFileName root;
- private final FileSystemOptions fileSystemOptions;
+ private final FtpFileSystemOptions fileSystemOptions;
private FTPClient ftpClient;
- FTPClientWrapper(final GenericFileName root, final FileSystemOptions fileSystemOptions) throws FileSystemException
+ FTPClientWrapper(final GenericFileName root, final FtpFileSystemOptions fileSystemOptions) throws FileSystemException
{
this.root = root;
this.fileSystemOptions = fileSystemOptions;
@@ -53,7 +53,7 @@
return root;
}
- public FileSystemOptions getFileSystemOptions()
+ public FtpFileSystemOptions getFileSystemOptions()
{
return fileSystemOptions;
}
@@ -74,7 +74,7 @@
UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD,
UserAuthenticatorUtils.toChar(rootName.getPassword())),
rootName.getPath(),
- getFileSystemOptions());
+ fileSystemOptions);
}
finally
{
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java Sun Sep 13 06:26:23 2009
@@ -52,7 +52,7 @@
* @throws FileSystemException if an error occurs while connecting.
*/
public static FTPClient createConnection(String hostname, int port, char[] username, char[] password,
- String workingDirectory, FileSystemOptions fileSystemOptions)
+ String workingDirectory, FtpFileSystemOptions fileSystemOptions)
throws FileSystemException
{
// Determine the username and password to use
@@ -70,37 +70,32 @@
{
final FTPClient client = new FTPClient();
- String key = FtpFileSystemConfigBuilder.getInstance().getEntryParser(fileSystemOptions);
+ String key = fileSystemOptions.getEntryParser();
if (key != null)
{
FTPClientConfig config = new FTPClientConfig(key);
- String serverLanguageCode =
- FtpFileSystemConfigBuilder.getInstance().getServerLanguageCode(fileSystemOptions);
+ String serverLanguageCode = fileSystemOptions.getServerLanguageCode();
if (serverLanguageCode != null)
{
config.setServerLanguageCode(serverLanguageCode);
}
- String defaultDateFormat =
- FtpFileSystemConfigBuilder.getInstance().getDefaultDateFormat(fileSystemOptions);
+ String defaultDateFormat = fileSystemOptions.getDefaultDateFormat();
if (defaultDateFormat != null)
{
config.setDefaultDateFormatStr(defaultDateFormat);
}
- String recentDateFormat =
- FtpFileSystemConfigBuilder.getInstance().getRecentDateFormat(fileSystemOptions);
+ String recentDateFormat = fileSystemOptions.getRecentDateFormat();
if (recentDateFormat != null)
{
config.setRecentDateFormatStr(recentDateFormat);
}
- String serverTimeZoneId =
- FtpFileSystemConfigBuilder.getInstance().getServerTimeZoneId(fileSystemOptions);
+ String serverTimeZoneId = fileSystemOptions.getServerTimeZoneId();
if (serverTimeZoneId != null)
{
config.setServerTimeZoneId(serverTimeZoneId);
}
- String[] shortMonthNames =
- FtpFileSystemConfigBuilder.getInstance().getShortMonthNames(fileSystemOptions);
+ String[] shortMonthNames = fileSystemOptions.getShortMonthNames();
if (shortMonthNames != null)
{
StringBuffer shortMonthNamesStr = new StringBuffer(BUFSZ);
@@ -118,8 +113,7 @@
client.configure(config);
}
- FTPFileEntryParserFactory myFactory =
- FtpFileSystemConfigBuilder.getInstance().getEntryParserFactory(fileSystemOptions);
+ FTPFileEntryParserFactory myFactory = fileSystemOptions.getEntryParserFactory();
if (myFactory != null)
{
client.setParserFactory(myFactory);
@@ -151,7 +145,7 @@
}
// Set dataTimeout value
- Integer dataTimeout = FtpFileSystemConfigBuilder.getInstance().getDataTimeout(fileSystemOptions);
+ Integer dataTimeout = fileSystemOptions.getDataTimeout();
if (dataTimeout != null)
{
client.setDataTimeout(dataTimeout.intValue());
@@ -161,7 +155,7 @@
// All file operations a relative to the filesystem-root
// String root = getRoot().getName().getPath();
- Boolean userDirIsRoot = FtpFileSystemConfigBuilder.getInstance().getUserDirIsRoot(fileSystemOptions);
+ Boolean userDirIsRoot = fileSystemOptions.getUserDirIsRoot();
if (workingDirectory != null && (userDirIsRoot == null || !userDirIsRoot.booleanValue()))
{
if (!client.changeWorkingDirectory(workingDirectory))
@@ -170,7 +164,7 @@
}
}
- Boolean passiveMode = FtpFileSystemConfigBuilder.getInstance().getPassiveMode(fileSystemOptions);
+ Boolean passiveMode = fileSystemOptions.getPassiveMode();
if (passiveMode != null && passiveMode.booleanValue())
{
client.enterLocalPassiveMode();
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java Sun Sep 13 06:26:23 2009
@@ -67,10 +67,11 @@
Capability.RANDOM_ACCESS_READ,
}));
+ private static final Class<? extends FileSystemOptions> FSOPTIONS_CLASS = FtpFileSystemOptions.class;
+
public FtpFileProvider()
{
- super();
- setFileNameParser(FtpFileNameParser.getInstance());
+ super(FtpFileNameParser.getInstance(), FSOPTIONS_CLASS);
}
/**
@@ -82,7 +83,9 @@
// Create the file system
final GenericFileName rootName = (GenericFileName) name;
- FTPClientWrapper ftpClient = new FTPClientWrapper(rootName, fileSystemOptions);
+ FtpFileSystemOptions options = FileSystemOptions.makeSpecific(FtpFileSystemOptions.class, fileSystemOptions);
+
+ FTPClientWrapper ftpClient = new FTPClientWrapper(rootName, options);
/*
FTPClient ftpClient = FtpClientFactory.createConnection(rootName.getHostName(),
rootName.getPort(),
@@ -92,7 +95,7 @@
fileSystemOptions);
*/
- return new FtpFileSystem(rootName, ftpClient, fileSystemOptions);
+ return new FtpFileSystem(rootName, ftpClient, options, FSOPTIONS_CLASS);
}
public FileSystemConfigBuilder getConfigBuilder()
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java Sun Sep 13 06:26:23 2009
@@ -35,8 +35,7 @@
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
* @version $Revision$ $Date$
*/
-public class FtpFileSystem
- extends AbstractFileSystem
+public class FtpFileSystem extends AbstractFileSystem
{
private static final Log LOG = LogFactory.getLog(FtpFileSystem.class);
@@ -49,9 +48,10 @@
private FtpClient idleClient;
protected FtpFileSystem(final GenericFileName rootName, final FtpClient ftpClient,
- final FileSystemOptions fileSystemOptions)
+ final FileSystemOptions fileSystemOptions,
+ final Class<? extends FileSystemOptions> optionsClass)
{
- super(rootName, null, fileSystemOptions);
+ super(rootName, null, fileSystemOptions, optionsClass);
// hostname = rootName.getHostName();
// port = rootName.getPort();
@@ -149,4 +149,9 @@
{
return new FtpFileObject(name, this, getRootName());
}
+
+ public FtpFileSystemOptions getFileSystemOptions()
+ {
+ return super.getOptions();
+ }
}
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java Sun Sep 13 06:26:23 2009
@@ -25,27 +25,12 @@
*
* @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
* @version $Revision$ $Date$
+ * @deprecated Use FTPFileSystemOptions instead.
*/
public final class FtpFileSystemConfigBuilder extends FileSystemConfigBuilder
{
private static final FtpFileSystemConfigBuilder builder = new FtpFileSystemConfigBuilder();
- private static final String FACTORY_KEY = FTPFileEntryParserFactory.class.getName() + ".KEY";
- private static final String PASSIVE_MODE = FtpFileSystemConfigBuilder.class.getName() + ".PASSIVE";
- private static final String USER_DIR_IS_ROOT = FtpFileSystemConfigBuilder.class.getName() + ".USER_DIR_IS_ROOT";
- private static final String DATA_TIMEOUT = FtpFileSystemConfigBuilder.class.getName() + ".DATA_TIMEOUT";
-
- private static final String SERVER_LANGUAGE_CODE =
- FtpFileSystemConfigBuilder.class.getName() + ".SERVER_LANGUAGE_CODE";
- private static final String DEFAULT_DATE_FORMAT =
- FtpFileSystemConfigBuilder.class.getName() + ".DEFAULT_DATE_FORMAT";
- private static final String RECENT_DATE_FORMAT =
- FtpFileSystemConfigBuilder.class.getName() + ".RECENT_DATE_FORMAT";
- private static final String SERVER_TIME_ZONE_ID =
- FtpFileSystemConfigBuilder.class.getName() + ".SERVER_TIME_ZONE_ID";
- private static final String SHORT_MONTH_NAMES =
- FtpFileSystemConfigBuilder.class.getName() + ".SHORT_MONTH_NAMES";
-
private FtpFileSystemConfigBuilder()
{
super("ftp.");
@@ -64,7 +49,7 @@
*/
public void setEntryParserFactory(FileSystemOptions opts, FTPFileEntryParserFactory factory)
{
- setParam(opts, FTPFileEntryParserFactory.class.getName(), factory);
+ FtpFileSystemOptions.getInstance(opts).setEntryParserFactory(factory);
}
/**
@@ -74,7 +59,7 @@
*/
public FTPFileEntryParserFactory getEntryParserFactory(FileSystemOptions opts)
{
- return (FTPFileEntryParserFactory) getParam(opts, FTPFileEntryParserFactory.class.getName());
+ return FtpFileSystemOptions.getInstance(opts).getEntryParserFactory();
}
/**
@@ -89,7 +74,7 @@
*/
public void setEntryParser(FileSystemOptions opts, String key)
{
- setParam(opts, FACTORY_KEY, key);
+ FtpFileSystemOptions.getInstance(opts).setEntryParser(key);
}
/**
@@ -99,7 +84,7 @@
*/
public String getEntryParser(FileSystemOptions opts)
{
- return getString(opts, FACTORY_KEY);
+ return FtpFileSystemOptions.getInstance(opts).getEntryParser();
}
protected Class getConfigClass()
@@ -115,7 +100,7 @@
*/
public void setPassiveMode(FileSystemOptions opts, boolean passiveMode)
{
- setParam(opts, PASSIVE_MODE, passiveMode ? Boolean.TRUE : Boolean.FALSE);
+ FtpFileSystemOptions.getInstance(opts).setPassiveMode(passiveMode);
}
/**
@@ -125,7 +110,7 @@
*/
public Boolean getPassiveMode(FileSystemOptions opts)
{
- return getBoolean(opts, PASSIVE_MODE);
+ return FtpFileSystemOptions.getInstance(opts).getPassiveMode();
}
/**
@@ -136,7 +121,7 @@
*/
public void setUserDirIsRoot(FileSystemOptions opts, boolean userDirIsRoot)
{
- setParam(opts, USER_DIR_IS_ROOT, userDirIsRoot ? Boolean.TRUE : Boolean.FALSE);
+ FtpFileSystemOptions.getInstance(opts).setUserDirIsRoot(userDirIsRoot);
}
/**
@@ -146,7 +131,7 @@
*/
public Boolean getUserDirIsRoot(FileSystemOptions opts)
{
- return getBoolean(opts, USER_DIR_IS_ROOT);
+ return FtpFileSystemOptions.getInstance(opts).getUserDirIsRoot();
}
/**
@@ -156,7 +141,7 @@
*/
public Integer getDataTimeout(FileSystemOptions opts)
{
- return getInteger(opts, DATA_TIMEOUT);
+ return FtpFileSystemOptions.getInstance(opts).getDataTimeout();
}
/**
@@ -169,7 +154,7 @@
*/
public void setDataTimeout(FileSystemOptions opts, Integer dataTimeout)
{
- setParam(opts, DATA_TIMEOUT, dataTimeout);
+ FtpFileSystemOptions.getInstance(opts).setDataTimeout(dataTimeout);
}
/**
@@ -180,7 +165,7 @@
*/
public String getServerLanguageCode(FileSystemOptions opts)
{
- return getString(opts, SERVER_LANGUAGE_CODE);
+ return FtpFileSystemOptions.getInstance(opts).getServerLanguageCode();
}
/**
@@ -191,7 +176,7 @@
*/
public void setServerLanguageCode(FileSystemOptions opts, String serverLanguageCode)
{
- setParam(opts, SERVER_LANGUAGE_CODE, serverLanguageCode);
+ FtpFileSystemOptions.getInstance(opts).setServerLanguageCode(serverLanguageCode);
}
/**
@@ -202,7 +187,7 @@
*/
public String getDefaultDateFormat(FileSystemOptions opts)
{
- return getString(opts, DEFAULT_DATE_FORMAT);
+ return FtpFileSystemOptions.getInstance(opts).getDefaultDateFormat();
}
/**
@@ -213,7 +198,7 @@
*/
public void setDefaultDateFormat(FileSystemOptions opts, String defaultDateFormat)
{
- setParam(opts, DEFAULT_DATE_FORMAT, defaultDateFormat);
+ FtpFileSystemOptions.getInstance(opts).setDefaultDateFormat(defaultDateFormat);
}
/**
@@ -223,7 +208,7 @@
*/
public String getRecentDateFormat(FileSystemOptions opts)
{
- return getString(opts, RECENT_DATE_FORMAT);
+ return FtpFileSystemOptions.getInstance(opts).getRecentDateFormat();
}
/**
@@ -233,7 +218,7 @@
*/
public void setRecentDateFormat(FileSystemOptions opts, String recentDateFormat)
{
- setParam(opts, RECENT_DATE_FORMAT, recentDateFormat);
+ FtpFileSystemOptions.getInstance(opts).setRecentDateFormat(recentDateFormat);
}
/**
@@ -243,7 +228,7 @@
*/
public String getServerTimeZoneId(FileSystemOptions opts)
{
- return getString(opts, SERVER_TIME_ZONE_ID);
+ return FtpFileSystemOptions.getInstance(opts).getServerTimeZoneId();
}
/**
@@ -253,7 +238,7 @@
*/
public void setServerTimeZoneId(FileSystemOptions opts, String serverTimeZoneId)
{
- setParam(opts, SERVER_TIME_ZONE_ID, serverTimeZoneId);
+ FtpFileSystemOptions.getInstance(opts).setServerTimeZoneId(serverTimeZoneId);
}
/**
@@ -263,7 +248,7 @@
*/
public String[] getShortMonthNames(FileSystemOptions opts)
{
- return (String[]) getParam(opts, SHORT_MONTH_NAMES);
+ return FtpFileSystemOptions.getInstance(opts).getShortMonthNames();
}
/**
@@ -273,13 +258,6 @@
*/
public void setShortMonthNames(FileSystemOptions opts, String[] shortMonthNames)
{
- String[] clone = null;
- if (shortMonthNames != null)
- {
- clone = new String[shortMonthNames.length];
- System.arraycopy(shortMonthNames, 0, clone, 0, shortMonthNames.length);
- }
-
- setParam(opts, SHORT_MONTH_NAMES, clone);
+ FtpFileSystemOptions.getInstance(opts).setShortMonthNames(shortMonthNames);
}
}
Added: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemOptions.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemOptions.java?rev=814264&view=auto
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemOptions.java (added)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemOptions.java Sun Sep 13 06:26:23 2009
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.ftp;
+
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.DefaultFileSystemOptions;
+import org.apache.commons.net.ftp.parser.FTPFileEntryParserFactory;
+
+/**
+ * FTP File System Options
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ */
+public class FtpFileSystemOptions extends DefaultFileSystemOptions
+{
+ // Why are these keys prefixed with a class name? FileSystemOptionsKey does that automatically.
+ private static final String FACTORY_KEY = FTPFileEntryParserFactory.class.getName() + ".KEY";
+ private static final String PASSIVE_MODE = FtpFileSystemConfigBuilder.class.getName() + ".PASSIVE";
+ private static final String USER_DIR_IS_ROOT = FtpFileSystemConfigBuilder.class.getName() + ".USER_DIR_IS_ROOT";
+ private static final String DATA_TIMEOUT = FtpFileSystemConfigBuilder.class.getName() + ".DATA_TIMEOUT";
+
+ private static final String SERVER_LANGUAGE_CODE =
+ FtpFileSystemConfigBuilder.class.getName() + ".SERVER_LANGUAGE_CODE";
+ private static final String DEFAULT_DATE_FORMAT =
+ FtpFileSystemConfigBuilder.class.getName() + ".DEFAULT_DATE_FORMAT";
+ private static final String RECENT_DATE_FORMAT =
+ FtpFileSystemConfigBuilder.class.getName() + ".RECENT_DATE_FORMAT";
+ private static final String SERVER_TIME_ZONE_ID =
+ FtpFileSystemConfigBuilder.class.getName() + ".SERVER_TIME_ZONE_ID";
+ private static final String SHORT_MONTH_NAMES =
+ FtpFileSystemConfigBuilder.class.getName() + ".SHORT_MONTH_NAMES";
+
+ public FtpFileSystemOptions()
+ {
+ this("ftp.");
+ }
+
+ protected FtpFileSystemOptions(String scheme)
+ {
+ super(scheme);
+ }
+
+ public static FtpFileSystemOptions getInstance(FileSystemOptions opts)
+ {
+ return FileSystemOptions.makeSpecific(FtpFileSystemOptions.class, opts);
+ }
+ /**
+ * FTPFileEntryParserFactory which will be used for ftp-entry parsing.
+ *
+ * @param factory instance of your factory
+ */
+ public void setEntryParserFactory(FTPFileEntryParserFactory factory)
+ {
+ setParam(FTPFileEntryParserFactory.class.getName(), factory);
+ }
+
+ /**
+ * @see #setEntryParserFactory
+ * @return An FTPFileEntryParserFactory.
+ */
+ public FTPFileEntryParserFactory getEntryParserFactory()
+ {
+ return (FTPFileEntryParserFactory) getParam(FTPFileEntryParserFactory.class.getName());
+ }
+
+ /**
+ * set the FQCN of your FileEntryParser used to parse the directory listing from your server.<br />
+ * <br />
+ * <i>If you do not use the default commons-net FTPFileEntryParserFactory e.g. by using
+ * {@link #setEntryParserFactory}
+ * this is the "key" parameter passed as argument into your custom factory</i>
+ *
+ * @param key The key.
+ */
+ public void setEntryParser(String key)
+ {
+ setParam(FACTORY_KEY, key);
+ }
+
+ /**
+ * @see #setEntryParser
+ * @return the key to the EntryParser.
+ */
+ public String getEntryParser()
+ {
+ return getString(FACTORY_KEY);
+ }
+
+ /**
+ * enter into passive mode.
+ *
+ * @param passiveMode true if passive mode should be used.
+ */
+ public void setPassiveMode(boolean passiveMode)
+ {
+ setParam(PASSIVE_MODE, passiveMode ? Boolean.TRUE : Boolean.FALSE);
+ }
+
+ /**
+ * @return true if passive mode is set.
+ * @see #setPassiveMode
+ */
+ public Boolean getPassiveMode()
+ {
+ return getBoolean(PASSIVE_MODE);
+ }
+
+ /**
+ * use user directory as root (do not change to fs root).
+ *
+ * @param userDirIsRoot true if the user directory should be treated as the root.
+ */
+ public void setUserDirIsRoot(boolean userDirIsRoot)
+ {
+ setParam(USER_DIR_IS_ROOT, userDirIsRoot ? Boolean.TRUE : Boolean.FALSE);
+ }
+
+ /**
+ * @return true if the user directory is treated as the root.
+ * @see #setUserDirIsRoot
+ */
+ public Boolean getUserDirIsRoot()
+ {
+ return getBoolean(USER_DIR_IS_ROOT);
+ }
+
+ /**
+ * @return The timeout as an Integer.
+ * @see #setDataTimeout
+ */
+ public Integer getDataTimeout()
+ {
+ return getInteger(DATA_TIMEOUT);
+ }
+
+ /**
+ * set the data timeout for the ftp client.<br />
+ * If you set the dataTimeout to <code>null</code> no dataTimeout will be set on the
+ * ftp client.
+ *
+ * @param dataTimeout The timeout value.
+ */
+ public void setDataTimeout(Integer dataTimeout)
+ {
+ setParam(DATA_TIMEOUT, dataTimeout);
+ }
+
+ /**
+ * get the language code used by the server. see {@link org.apache.commons.net.ftp.FTPClientConfig}
+ * for details and examples.
+ * @return The language code of the server.
+ */
+ public String getServerLanguageCode()
+ {
+ return getString(SERVER_LANGUAGE_CODE);
+ }
+
+ /**
+ * set the language code used by the server. see {@link org.apache.commons.net.ftp.FTPClientConfig}
+ * for details and examples.
+ * @param serverLanguageCode The servers language code.
+ */
+ public void setServerLanguageCode(String serverLanguageCode)
+ {
+ setParam(SERVER_LANGUAGE_CODE, serverLanguageCode);
+ }
+
+ /**
+ * get the language code used by the server. see {@link org.apache.commons.net.ftp.FTPClientConfig}
+ * for details and examples.
+ * @return The default date format.
+ */
+ public String getDefaultDateFormat()
+ {
+ return getString(DEFAULT_DATE_FORMAT);
+ }
+
+ /**
+ * set the language code used by the server. see {@link org.apache.commons.net.ftp.FTPClientConfig}
+ * for details and examples.
+ * @param defaultDateFormat The default date format.
+ */
+ public void setDefaultDateFormat(String defaultDateFormat)
+ {
+ setParam(DEFAULT_DATE_FORMAT, defaultDateFormat);
+ }
+
+ /**
+ * see {@link org.apache.commons.net.ftp.FTPClientConfig} for details and examples.
+ * @return The recent date format.
+ */
+ public String getRecentDateFormat()
+ {
+ return getString(RECENT_DATE_FORMAT);
+ }
+
+ /**
+ * see {@link org.apache.commons.net.ftp.FTPClientConfig} for details and examples.
+ * @param recentDateFormat The recent date format.
+ */
+ public void setRecentDateFormat(String recentDateFormat)
+ {
+ setParam(RECENT_DATE_FORMAT, recentDateFormat);
+ }
+
+ /**
+ * see {@link org.apache.commons.net.ftp.FTPClientConfig} for details and examples.
+ * @return The server timezone id.
+ */
+ public String getServerTimeZoneId()
+ {
+ return getString(SERVER_TIME_ZONE_ID);
+ }
+
+ /**
+ * see {@link org.apache.commons.net.ftp.FTPClientConfig} for details and examples.
+ * @param serverTimeZoneId The server timezone id.
+ */
+ public void setServerTimeZoneId(String serverTimeZoneId)
+ {
+ setParam(SERVER_TIME_ZONE_ID, serverTimeZoneId);
+ }
+
+ /**
+ * see {@link org.apache.commons.net.ftp.FTPClientConfig} for details and examples.
+ * @return An array of short month names.
+ */
+ public String[] getShortMonthNames()
+ {
+ return (String[]) getParam(SHORT_MONTH_NAMES);
+ }
+
+ /**
+ * see {@link org.apache.commons.net.ftp.FTPClientConfig} for details and examples.
+ * @param shortMonthNames an array of short month name Strings.
+ */
+ public void setShortMonthNames(String[] shortMonthNames)
+ {
+ String[] clone = null;
+ if (shortMonthNames != null)
+ {
+ clone = new String[shortMonthNames.length];
+ System.arraycopy(shortMonthNames, 0, clone, 0, shortMonthNames.length);
+ }
+
+ setParam(SHORT_MONTH_NAMES, clone);
+ }
+}
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpClientFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpClientFactory.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpClientFactory.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpClientFactory.java Sun Sep 13 06:26:23 2009
@@ -42,22 +42,43 @@
{
}
- public static HttpClient createConnection(String scheme, String hostname, int port, String username,
+ /**
+ * Creates a new connection to the server.
+ * @param builder The configuration builder.
+ * @param scheme The protocol.
+ * @param hostname The name of the host to connect to.
+ * @param port The port number to connect to.
+ * @param username The user name for authentication.
+ * @param password The password.
+ * @param fileSystemOptions FileSystemOptions.
+ * @return an HttpClient.
+ * @throws FileSystemException if an error occurs.
+ * @deprecated - HttpFileSystemConfigBuilder is not needed.
+ */
+ public static HttpClient createConnection(HttpFileSystemConfigBuilder builder, String scheme, String hostname,
+ int port, String username,
String password, FileSystemOptions fileSystemOptions)
throws FileSystemException
{
- return createConnection(HttpFileSystemConfigBuilder.getInstance(), scheme, hostname, port,
- username, password, fileSystemOptions);
+ return createConnection(scheme, hostname, port, username, password, fileSystemOptions);
}
/**
* Creates a new connection to the server.
+ * @param scheme The protocol.
+ * @param hostname The name of the host to connect to.
+ * @param port The port number to connect to.
+ * @param username The user name for authentication.
+ * @param password The password.
+ * @param fileSystemOptions FileSystemOptions.
+ * @return an HttpClient.
+ * @throws FileSystemException if an error occurs.
*/
- public static HttpClient createConnection(HttpFileSystemConfigBuilder builder, String scheme,
- String hostname, int port, String username,
+ public static HttpClient createConnection(String scheme, String hostname, int port, String username,
String password, FileSystemOptions fileSystemOptions)
throws FileSystemException
{
+ HttpFileSystemOptions httpOpts = HttpFileSystemOptions.getInstance(fileSystemOptions);
HttpClient client;
try
{
@@ -71,15 +92,15 @@
if (fileSystemOptions != null)
{
- String proxyHost = builder.getProxyHost(fileSystemOptions);
- int proxyPort = builder.getProxyPort(fileSystemOptions);
+ String proxyHost = httpOpts.getProxyHost();
+ int proxyPort = httpOpts.getProxyPort();
if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0)
{
config.setProxy(proxyHost, proxyPort);
}
- UserAuthenticator proxyAuth = builder.getProxyAuthenticator(fileSystemOptions);
+ UserAuthenticator proxyAuth = httpOpts.getProxyAuthenticator();
if (proxyAuth != null)
{
UserAuthenticationData authData = UserAuthenticatorUtils.authenticate(proxyAuth, new UserAuthenticationData.Type[]
@@ -99,7 +120,7 @@
}
}
- Cookie[] cookies = builder.getCookies(fileSystemOptions);
+ Cookie[] cookies = httpOpts.getCookies();
if (cookies != null)
{
client.getState().addCookies(cookies);
@@ -110,8 +131,8 @@
* are set in the HostConfiguration. They are all used as part of the key when HttpConnectionManagerParams
* tries to locate the host configuration.
*/
- connectionMgrParams.setMaxConnectionsPerHost(config, builder.getMaxConnectionsPerHost(fileSystemOptions));
- connectionMgrParams.setMaxTotalConnections(builder.getMaxTotalConnections(fileSystemOptions));
+ connectionMgrParams.setMaxConnectionsPerHost(config, httpOpts.getMaxConnectionsPerHost());
+ connectionMgrParams.setMaxTotalConnections(httpOpts.getMaxTotalConnections());
client.setHostConfiguration(config);
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java Sun Sep 13 06:26:23 2009
@@ -26,6 +26,7 @@
import org.apache.commons.vfs.UserAuthenticationData;
import org.apache.commons.vfs.provider.AbstractOriginatingFileProvider;
import org.apache.commons.vfs.provider.GenericFileName;
+import org.apache.commons.vfs.provider.FileNameParser;
import org.apache.commons.vfs.util.UserAuthenticatorUtils;
import java.util.Arrays;
@@ -58,10 +59,16 @@
UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD
};
+ private static final Class<? extends FileSystemOptions> FSOPTIONS_CLASS = HttpFileSystemOptions.class;
+
public HttpFileProvider()
{
- super();
- setFileNameParser(HttpFileNameParser.getInstance());
+ super(HttpFileNameParser.getInstance(), FSOPTIONS_CLASS);
+ }
+
+ protected HttpFileProvider(FileNameParser fileNameParser, Class<? extends FileSystemOptions> optionsClass)
+ {
+ super(fileNameParser, optionsClass);
}
/**
@@ -92,9 +99,15 @@
UserAuthenticatorUtils.cleanup(authData);
}
- return new HttpFileSystem(rootName, httpClient, fileSystemOptions);
+ return new HttpFileSystem(rootName, httpClient, fileSystemOptions, FSOPTIONS_CLASS);
}
+ /**
+ * Get ConfigurationBuilder
+ * @return The FileSystemConfigBuilder.
+ * @deprecated - Use HttpFileSystemOptions instead.
+ */
+
public FileSystemConfigBuilder getConfigBuilder()
{
return HttpFileSystemConfigBuilder.getInstance();
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystem.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystem.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystem.java Sun Sep 13 06:26:23 2009
@@ -40,9 +40,11 @@
{
private final HttpClient client;
- protected HttpFileSystem(final GenericFileName rootName, final HttpClient client, final FileSystemOptions fileSystemOptions)
+ protected HttpFileSystem(final GenericFileName rootName, final HttpClient client,
+ final FileSystemOptions fileSystemOptions,
+ final Class<? extends FileSystemOptions> optionsClass)
{
- super(rootName, null, fileSystemOptions);
+ super(rootName, null, fileSystemOptions, optionsClass);
this.client = client;
}
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java Sun Sep 13 06:26:23 2009
@@ -27,6 +27,7 @@
*
* @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
* @version $Revision$ $Date$
+ * @deprecated Use HttpFileSystemOptions instead.
*/
public class HttpFileSystemConfigBuilder extends FileSystemConfigBuilder
{
@@ -37,10 +38,6 @@
return builder;
}
- private static final int DEFAULT_MAX_HOST_CONNECTIONS = 5;
-
- private static final int DEFAULT_MAX_CONNECTIONS = 50;
-
protected HttpFileSystemConfigBuilder(String prefix)
{
super(prefix);
@@ -58,7 +55,7 @@
*/
public void setUrlCharset(FileSystemOptions opts, String chaset)
{
- setParam(opts, "urlCharset", chaset);
+ HttpFileSystemOptions.getInstance(opts).setUrlCharset(chaset);
}
/**
@@ -68,7 +65,7 @@
*/
public String getUrlCharset(FileSystemOptions opts)
{
- return getString(opts, "urlCharset");
+ return HttpFileSystemOptions.getInstance(opts).getUrlCharset();
}
/**
@@ -80,7 +77,7 @@
*/
public void setProxyHost(FileSystemOptions opts, String proxyHost)
{
- setParam(opts, "proxyHost", proxyHost);
+ HttpFileSystemOptions.getInstance(opts).setProxyHost(proxyHost);
}
/**
@@ -92,7 +89,7 @@
*/
public void setProxyPort(FileSystemOptions opts, int proxyPort)
{
- setParam(opts, "proxyPort", new Integer(proxyPort));
+ HttpFileSystemOptions.getInstance(opts).setProxyPort(proxyPort);
}
/**
@@ -104,7 +101,7 @@
*/
public String getProxyHost(FileSystemOptions opts)
{
- return getString(opts, "proxyHost");
+ return HttpFileSystemOptions.getInstance(opts).getProxyHost();
}
/**
@@ -116,7 +113,7 @@
*/
public int getProxyPort(FileSystemOptions opts)
{
- return getInteger(opts, "proxyPort", 0);
+ return HttpFileSystemOptions.getInstance(opts).getProxyPort();
}
/**
@@ -124,7 +121,7 @@
*/
public void setProxyAuthenticator(FileSystemOptions opts, UserAuthenticator authenticator)
{
- setParam(opts, "proxyAuthenticator", authenticator);
+ HttpFileSystemOptions.getInstance(opts).setProxyAuthenticator(authenticator);
}
/**
@@ -132,7 +129,7 @@
*/
public UserAuthenticator getProxyAuthenticator(FileSystemOptions opts)
{
- return (UserAuthenticator) getParam(opts, "proxyAuthenticator");
+ return HttpFileSystemOptions.getInstance(opts).getProxyAuthenticator();
}
/**
@@ -140,7 +137,7 @@
*/
public void setCookies(FileSystemOptions opts, Cookie[] cookies)
{
- setParam(opts, "cookies", cookies);
+ HttpFileSystemOptions.getInstance(opts).setCookies(cookies);
}
/**
@@ -148,7 +145,7 @@
*/
public Cookie[] getCookies(FileSystemOptions opts)
{
- return (Cookie[]) getParam(opts, "cookies");
+ return HttpFileSystemOptions.getInstance(opts).getCookies();
}
/**
@@ -156,7 +153,7 @@
*/
public void setMaxTotalConnections(FileSystemOptions opts, int maxTotalConnections)
{
- setParam(opts, HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, new Integer(maxTotalConnections));
+ HttpFileSystemOptions.getInstance(opts).setMaxTotalConnections(maxTotalConnections);
}
/**
@@ -166,7 +163,7 @@
*/
public int getMaxTotalConnections(FileSystemOptions opts)
{
- return getInteger(opts, HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, DEFAULT_MAX_CONNECTIONS);
+ return HttpFileSystemOptions.getInstance(opts).getMaxTotalConnections();
}
/**
@@ -174,7 +171,7 @@
*/
public void setMaxConnectionsPerHost(FileSystemOptions opts, int maxHostConnections)
{
- setParam(opts, HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, new Integer(maxHostConnections));
+ HttpFileSystemOptions.getInstance(opts).setMaxConnectionsPerHost(maxHostConnections);
}
/**
@@ -184,7 +181,7 @@
*/
public int getMaxConnectionsPerHost(FileSystemOptions opts)
{
- return getInteger(opts, HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, DEFAULT_MAX_HOST_CONNECTIONS);
+ return HttpFileSystemOptions.getInstance(opts).getMaxConnectionsPerHost();
}
protected Class getConfigClass()
Added: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemOptions.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemOptions.java?rev=814264&view=auto
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemOptions.java (added)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemOptions.java Sun Sep 13 06:26:23 2009
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.http;
+
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.UserAuthenticator;
+import org.apache.commons.vfs.DefaultFileSystemOptions;
+import org.apache.commons.httpclient.Cookie;
+import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
+
+/**
+ * HTTP File System Options
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ */
+public class HttpFileSystemOptions extends DefaultFileSystemOptions
+{
+ private static final int DEFAULT_MAX_HOST_CONNECTIONS = 5;
+
+ private static final int DEFAULT_MAX_CONNECTIONS = 50;
+
+ public HttpFileSystemOptions()
+ {
+ this("http.");
+ }
+
+ protected HttpFileSystemOptions(String scheme)
+ {
+ super(scheme);
+ }
+
+ public static HttpFileSystemOptions getInstance(FileSystemOptions opts)
+ {
+ return FileSystemOptions.makeSpecific(HttpFileSystemOptions.class, opts);
+ }
+
+ /**
+ * Set the charset used for url encoding<br>
+ *
+ * @param chaset the chaset
+ */
+ public void setUrlCharset(String chaset)
+ {
+ setParam("urlCharset", chaset);
+ }
+
+ /**
+ * Set the charset used for url encoding<br>
+ *
+ * @return the chaset
+ */
+ public String getUrlCharset()
+ {
+ return getString("urlCharset");
+ }
+
+ /**
+ * Set the proxy to use for http connection.<br>
+ * You have to set the ProxyPort too if you would like to have the proxy relly used.
+ *
+ * @param proxyHost the host
+ * @see #setProxyPort
+ */
+ public void setProxyHost(String proxyHost)
+ {
+ setParam("proxyHost", proxyHost);
+ }
+
+ /**
+ * Set the proxy-port to use for http connection
+ * You have to set the ProxyHost too if you would like to have the proxy relly used.
+ *
+ * @param proxyPort the port
+ * @see #setProxyHost
+ */
+ public void setProxyPort(int proxyPort)
+ {
+ setParam("proxyPort", new Integer(proxyPort));
+ }
+
+ /**
+ * Get the proxy to use for http connection
+ * You have to set the ProxyPort too if you would like to have the proxy relly used.
+ *
+ * @return proxyHost
+ * @see #setProxyPort
+ */
+ public String getProxyHost()
+ {
+ return getString("proxyHost");
+ }
+
+ /**
+ * Get the proxy-port to use for http the connection
+ * You have to set the ProxyHost too if you would like to have the proxy relly used.
+ *
+ * @return proxyPort: the port number or 0 if it is not set
+ * @see #setProxyHost
+ */
+ public int getProxyPort()
+ {
+ return getInteger("proxyPort", 0);
+ }
+
+ /**
+ * Set the proxy authenticator where the system should get the credentials from
+ */
+ public void setProxyAuthenticator(UserAuthenticator authenticator)
+ {
+ setParam("proxyAuthenticator", authenticator);
+ }
+
+ /**
+ * Get the proxy authenticator where the system should get the credentials from
+ */
+ public UserAuthenticator getProxyAuthenticator()
+ {
+ return (UserAuthenticator) getParam("proxyAuthenticator");
+ }
+
+ /**
+ * The cookies to add to the reqest
+ */
+ public void setCookies(Cookie[] cookies)
+ {
+ setParam("cookies", cookies);
+ }
+
+ /**
+ * The cookies to add to the reqest
+ */
+ public Cookie[] getCookies()
+ {
+ return (Cookie[]) getParam("cookies");
+ }
+
+ /**
+ * The maximum number of connections allowed
+ */
+ public void setMaxTotalConnections(int maxTotalConnections)
+ {
+ setParam(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, new Integer(maxTotalConnections));
+ }
+
+ /**
+ * Retrieve the maximum number of connections allowed.
+ * @return The maximum number of connections allowed.
+ */
+ public int getMaxTotalConnections()
+ {
+ return getInteger(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, DEFAULT_MAX_CONNECTIONS);
+ }
+
+ /**
+ * The maximum number of connections allowed to any host
+ */
+ public void setMaxConnectionsPerHost(int maxHostConnections)
+ {
+ setParam(HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, new Integer(maxHostConnections));
+ }
+
+ /**
+ * Retrieve the maximum number of connections allowed per host.
+ * @return The maximum number of connections allowed per host.
+ */
+ public int getMaxConnectionsPerHost()
+ {
+ return getInteger(HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, DEFAULT_MAX_HOST_CONNECTIONS);
+ }
+}
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java Sun Sep 13 06:26:23 2009
@@ -254,8 +254,7 @@
{
if (fs.getFileSystemOptions() != null)
{
- int maxSize = RamFileSystemConfigBuilder.getInstance().getMaxSize(
- fs.getFileSystemOptions());
+ int maxSize = fs.getFileSystemOptions().getMaxSize();
if (fs.size() + newSize - this.size() > maxSize)
{
throw new IOException("FileSystem capacity (" + maxSize
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileProvider.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileProvider.java Sun Sep 13 06:26:23 2009
@@ -27,6 +27,7 @@
import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.provider.AbstractOriginatingFileProvider;
import org.apache.commons.vfs.provider.FileProvider;
+import org.apache.commons.vfs.provider.ftp.FtpFileSystemOptions;
/**
* RAM File Provider
@@ -46,12 +47,14 @@
Capability.APPEND_CONTENT, Capability.RANDOM_ACCESS_READ,
Capability.RANDOM_ACCESS_WRITE }));
+ private static final Class<? extends FileSystemOptions> FSOPTIONS_CLASS = RamFileSystemOptions.class;
+
/**
* Constructor
*/
public RamFileProvider()
{
- super();
+ super(FSOPTIONS_CLASS);
}
/*
@@ -63,7 +66,7 @@
protected FileSystem doCreateFileSystem(FileName name,
FileSystemOptions fileSystemOptions) throws FileSystemException
{
- return new RamFileSystem(name, fileSystemOptions);
+ return new RamFileSystem(name, fileSystemOptions, FSOPTIONS_CLASS);
}
/*
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java Sun Sep 13 06:26:23 2009
@@ -49,10 +49,10 @@
* @param rootName
* @param fileSystemOptions
*/
- protected RamFileSystem(FileName rootName,
- FileSystemOptions fileSystemOptions)
+ protected RamFileSystem(FileName rootName, FileSystemOptions fileSystemOptions,
+ final Class<? extends FileSystemOptions> optionsClass)
{
- super(rootName, null, fileSystemOptions);
+ super(rootName, null, fileSystemOptions, optionsClass);
this.cache = Collections.synchronizedMap(new HashMap());
// create root
RamFileData rootData = new RamFileData(rootName) ;
@@ -82,6 +82,11 @@
caps.addAll(RamFileProvider.capabilities);
}
+ public RamFileSystemOptions getFileSystemOptions()
+ {
+ return super.getOptions();
+ }
+
/**
* @param name
* @return children
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemConfigBuilder.java Sun Sep 13 06:26:23 2009
@@ -21,13 +21,12 @@
/**
* Config Builder for the RAM filesystem.
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ * @deprecated Use RamFileSystemOptions instead.
*/
public class RamFileSystemConfigBuilder extends FileSystemConfigBuilder
{
- /** max size key */
- private static final String MAX_SIZE_KEY = "maxsize";
-
/** config builder singleton */
private static RamFileSystemConfigBuilder singleton = new RamFileSystemConfigBuilder();
@@ -56,24 +55,24 @@
}
/**
- * @param opts
- * @return
+ * @param opts The FileSystemOptions.
+ * @return The Maximum size of the filesystem.
* @see #setMaxSize
*/
public int getMaxSize(FileSystemOptions opts)
{
- return getInteger(opts, MAX_SIZE_KEY, Integer.MAX_VALUE);
+ return RamFileSystemOptions.getInstance(opts).getMaxSize();
}
/**
* sets the maximum size of the file system
*
- * @param opts
- * @param sizeInBytes
+ * @param opts The FileSystemOptions.
+ * @param sizeInBytes The maximum size in bytes of the file system.
*/
public void setMaxSize(FileSystemOptions opts, int sizeInBytes)
{
- setParam(opts, MAX_SIZE_KEY, new Integer(sizeInBytes));
+ RamFileSystemOptions.getInstance(opts).setMaxSize(sizeInBytes);
}
}
[VFS] Re: svn commit: r814264 [1/2] - in /commons/proper/vfs/branches/VFS281: ./ core/src/main/java/org/apache/commons/vfs/ core/src/main/java/org/apache/commons/vfs/impl/ core/src/main/java/org/apache/commons/vfs/provider/ core/src/main/java/org/apache/commons/...
Posted by Ralph Goers <ra...@dslextreme.com>.
I'd appreciate feedback on this. I tried to maintain compatibility but
I did this on a branch so it could be reviewed before breaking
anything. The major change is that FileSystems with their own options
extend FileSystemOptions instead of having a configbuilder class.
FileSystemOptions for various providers can still be merged.
Also, I haven't tested "remote" file systems yet (ftp, http, webdav,
etc).
Ralph
On Sep 12, 2009, at 11:26 PM, rgoers@apache.org wrote:
> Author: rgoers
> Date: Sun Sep 13 06:26:23 2009
> New Revision: 814264
>
> URL: http://svn.apache.org/viewvc?rev=814264&view=rev
> Log:
> Implement changes to address VFS-281
>
> Added:
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/DefaultFileSystemOptions.java (contents, props changed)
> - copied, changed from r805870, commons/proper/vfs/trunk/core/
> src/main/java/org/apache/commons/vfs/FileSystemConfigBuilder.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpFileSystemOptions.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpFileSystemOptions.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileSystemOptions.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/res/ResourceFileSystemOptions.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/sftp/ProxyType.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/sftp/SftpFileSystemOptions.java
> - copied, changed from r812334, commons/proper/vfs/branches/
> VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/
> SftpFileSystemConfigBuilder.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/webdav/WebdavFileSystemOptions.java
> Modified:
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/FileSystemConfigBuilder.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/FileSystemManager.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/FileSystemOptions.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/impl/DefaultFileSystemConfigBuilder.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/impl/DefaultFileSystemManager.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/AbstractFileProvider.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/AbstractFileSystem.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/AbstractOriginatingFileProvider.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/FileProvider.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FTPClientWrapper.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpClientFactory.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpFileProvider.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpFileSystem.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpClientFactory.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpFileProvider.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpFileSystem.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpFileSystemConfigBuilder.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileObject.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileProvider.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileSystem.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileSystemConfigBuilder.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/res/ResourceFileProvider.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/res/ResourceFileSystemConfigBuilder.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/sftp/SftpClientFactory.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/sftp/SftpFileProvider.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/sftp/SftpFileSystem.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/webdav/WebdavFileObject.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/webdav/WebdavFileProvider.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/webdav/WebdavFileSystem.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java
> commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/util/UserAuthenticatorUtils.java
> commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/
> commons/vfs/provider/ftp/test/FtpProviderTestCase.java
> commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/
> commons/vfs/provider/ram/test/CustomRamProviderTest.java
> commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/
> commons/vfs/provider/sftp/test/SftpProviderTestCase.java
> commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/
> commons/vfs/provider/webdav/test/WebdavProviderTestCase.java
> commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/
> commons/vfs/provider/webdav/test/WebdavVersioningTests.java
> commons/proper/vfs/branches/VFS281/core/src/test/java/org/apache/
> commons/vfs/util/DelegatingFileSystemOptionsBuilderTest.java
> commons/proper/vfs/branches/VFS281/pom.xml
>
> Copied: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/DefaultFileSystemOptions.java (from r805870,
> commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/
> FileSystemConfigBuilder.java)
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/DefaultFileSystemOptions.java?p2=commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/DefaultFileSystemOptions.java&p1=commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileSystemConfigBuilder.java&r1=805870&r2=814264&rev=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/
> vfs/FileSystemConfigBuilder.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/DefaultFileSystemOptions.java Sun Sep 13 06:26:23 2009
> @@ -19,10 +19,10 @@
> /**
> * Abstract class which has the right to fill FileSystemOptions.
> *
> - * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
> + * @author <a href="http://commons.apache.org/vfs/team-
> list.html">Commons VFS team</a>
> * @version $Revision$ $Date$
> */
> -public abstract class FileSystemConfigBuilder
> +public class DefaultFileSystemOptions extends FileSystemOptions
> {
> /** Default prefix to use when resolving system properties */
> private static final String PREFIX = "vfs.";
> @@ -33,74 +33,93 @@
> /** The prefix to use when resolving system properties */
> private final String prefix;
>
> - protected FileSystemConfigBuilder()
> + /**
> + *
> + */
> + protected DefaultFileSystemOptions()
> {
> this.prefix = PREFIX;
> }
> - protected FileSystemConfigBuilder(String component)
> +
> + /**
> + * @param component The component String;
> + */
> + protected DefaultFileSystemOptions(String component)
> {
> this.prefix = PREFIX + component;
> }
>
> /**
> * The root URI of the file system.
> - * @param opts The FileSystem options
> * @param rootURI The creator name to be associated with the file.
> */
> - public void setRootURI(FileSystemOptions opts, String rootURI)
> + public void setRootURI(String rootURI)
> {
> - setParam(opts, ROOTURI, rootURI);
> + setParam(ROOTURI, rootURI);
> }
>
> /**
> * Return the root URI of the file system.
> - * @param opts The FileSystem options
> * @return The root URI.
> */
> - public String getRootURI(FileSystemOptions opts)
> + public String getRootURI()
> {
> - return getString(opts, ROOTURI);
> + return getString(ROOTURI);
> }
>
> + /**
> + * Sets the user authenticator to get authentication
> informations.
> + * @param userAuthenticator The UserAuthenticator.
> + * @throws FileSystemException if an error occurs setting the
> UserAuthenticator.
> + */
> + public void setUserAuthenticator(UserAuthenticator
> userAuthenticator)
> + throws FileSystemException
> + {
> + setParam("userAuthenticator", userAuthenticator);
> + }
>
> - protected void setParam(FileSystemOptions opts, String name,
> Object value)
> + /**
> + * @see #setUserAuthenticator
> + * @return The UserAuthenticator.
> + */
> + public UserAuthenticator getUserAuthenticator()
> {
> - opts.setOption(getConfigClass(), name, value);
> + return (UserAuthenticator) getParam("userAuthenticator");
> }
>
> - protected Object getParam(FileSystemOptions opts, String name)
> + protected void setParam(String name, Object value)
> {
> - if (opts == null)
> - {
> - return null;
> - }
> + setOption(this.getClass(), name, value);
> + }
>
> - return opts.getOption(getConfigClass(), name);
> + protected Object getParam(String name)
> + {
> + return getOption(this.getClass(), name);
> }
>
> - protected boolean hasParam(FileSystemOptions opts, String name)
> + protected boolean hasParam(String name)
> {
> - return opts != null && opts.hasOption(getConfigClass(),
> name);
> + return hasOption(this.getClass(), name);
> }
>
> - protected boolean hasObject(FileSystemOptions opts, String name)
> + protected boolean hasObject(String name)
> {
> - return hasParam(opts, name) || System.getProperties
> ().containsKey(PREFIX + name);
> + return hasParam(name) || System.getProperties().containsKey
> (PREFIX + name);
> }
>
> - protected Boolean getBoolean(FileSystemOptions opts, String name)
> + protected Boolean getBoolean(String name)
> {
> - return getBoolean(opts, name, null);
> + return getBoolean(name, null);
> }
>
> - protected boolean getBoolean(FileSystemOptions opts, String
> name, boolean defaultValue)
> + protected boolean getBoolean(String name, boolean defaultValue)
> {
> - return getBoolean(opts, name, new Boolean
> (defaultValue)).booleanValue();
> + return getBoolean(name, new Boolean
> (defaultValue)).booleanValue();
> }
>
> - protected Boolean getBoolean(FileSystemOptions opts, String
> name, Boolean defaultValue)
> + protected Boolean getBoolean(String name, Boolean defaultValue)
> {
> - Boolean value = (Boolean) getParam(opts, name);
> + Boolean value = (Boolean) getParam(name);
> if (value == null)
> {
> String str = System.getProperty(PREFIX + name);
> @@ -113,19 +132,19 @@
> return value;
> }
>
> - protected Byte getByte(FileSystemOptions opts, String name)
> + protected Byte getByte(String name)
> {
> - return getByte(opts, name, null);
> + return getByte(name, null);
> }
>
> - protected byte getByte(FileSystemOptions opts, String name,
> byte defaultValue)
> + protected byte getByte(String name, byte defaultValue)
> {
> - return getByte(opts, name, new Byte(defaultValue)).byteValue
> ();
> + return getByte(name, new Byte(defaultValue)).byteValue();
> }
>
> - protected Byte getByte(FileSystemOptions opts, String name,
> Byte defaultValue)
> + protected Byte getByte(String name, Byte defaultValue)
> {
> - Byte value = (Byte) getParam(opts, name);
> + Byte value = (Byte) getParam(name);
> if (value == null)
> {
> String str = System.getProperty(this.prefix + name);
> @@ -138,19 +157,19 @@
> return value;
> }
>
> - protected Character getCharacter(FileSystemOptions opts, String
> name)
> + protected Character getCharacter(String name)
> {
> - return getCharacter(opts, name, null);
> + return getCharacter(name, null);
> }
>
> - protected char getCharacter(FileSystemOptions opts, String
> name, char defaultValue)
> + protected char getCharacter(String name, char defaultValue)
> {
> - return getCharacter(opts, name, new Character
> (defaultValue)).charValue();
> + return getCharacter(name, new Character
> (defaultValue)).charValue();
> }
>
> - protected Character getCharacter(FileSystemOptions opts, String
> name, Character defaultValue)
> + protected Character getCharacter(String name, Character
> defaultValue)
> {
> - Character value = (Character) getParam(opts, name);
> + Character value = (Character) getParam(name);
> if (value == null)
> {
> String str = System.getProperty(this.prefix + name);
> @@ -163,19 +182,19 @@
> return value;
> }
>
> - protected Double getDouble(FileSystemOptions opts, String name)
> + protected Double getDouble(String name)
> {
> - return getDouble(opts, name, null);
> + return getDouble(name, null);
> }
>
> - protected double getDouble(FileSystemOptions opts, String name,
> double defaultValue)
> + protected double getDouble(String name, double defaultValue)
> {
> - return getDouble(opts, name, new Double
> (defaultValue)).doubleValue();
> + return getDouble(name, new Double(defaultValue)).doubleValue
> ();
> }
>
> - protected Double getDouble(FileSystemOptions opts, String name,
> Double defaultValue)
> + protected Double getDouble(String name, Double defaultValue)
> {
> - Double value = (Double) getParam(opts, name);
> + Double value = (Double) getParam(name);
> if (value == null)
> {
> String str = System.getProperty(this.prefix + name);
> @@ -188,19 +207,19 @@
> return value;
> }
>
> - protected Float getFloat(FileSystemOptions opts, String name)
> + protected Float getFloat(String name)
> {
> - return getFloat(opts, name, null);
> + return getFloat(name, null);
> }
>
> - protected float getFloat(FileSystemOptions opts, String name,
> float defaultValue)
> + protected float getFloat(String name, float defaultValue)
> {
> - return getFloat(opts, name, new Float
> (defaultValue)).floatValue();
> + return getFloat(name, new Float(defaultValue)).floatValue();
> }
>
> - protected Float getFloat(FileSystemOptions opts, String name,
> Float defaultValue)
> + protected Float getFloat(String name, Float defaultValue)
> {
> - Float value = (Float) getParam(opts, name);
> + Float value = (Float) getParam(name);
> if (value == null)
> {
> String str = System.getProperty(this.prefix + name);
> @@ -213,19 +232,19 @@
> return value;
> }
>
> - protected Integer getInteger(FileSystemOptions opts, String name)
> + protected Integer getInteger(String name)
> {
> - return getInteger(opts, name, null);
> + return getInteger(name, null);
> }
>
> - protected int getInteger(FileSystemOptions opts, String name,
> int defaultValue)
> + protected int getInteger(String name, int defaultValue)
> {
> - return getInteger(opts, name, new Integer
> (defaultValue)).intValue();
> + return getInteger(name, new Integer(defaultValue)).intValue
> ();
> }
>
> - protected Integer getInteger(FileSystemOptions opts, String
> name, Integer defaultValue)
> + protected Integer getInteger(String name, Integer defaultValue)
> {
> - Integer value = (Integer) getParam(opts, name);
> + Integer value = (Integer) getParam(name);
> if (value == null)
> {
> String str = System.getProperty(this.prefix + name);
> @@ -238,19 +257,19 @@
> return value;
> }
>
> - protected Long getLong(FileSystemOptions opts, String name)
> + protected Long getLong(String name)
> {
> - return getLong(opts, name, null);
> + return getLong(name, null);
> }
>
> - protected long getLong(FileSystemOptions opts, String name,
> long defaultValue)
> + protected long getLong(String name, long defaultValue)
> {
> - return getLong(opts, name, new Long(defaultValue)).longValue
> ();
> + return getLong(name, new Long(defaultValue)).longValue();
> }
>
> - protected Long getLong(FileSystemOptions opts, String name,
> Long defaultValue)
> + protected Long getLong(String name, Long defaultValue)
> {
> - Long value = (Long) getParam(opts, name);
> + Long value = (Long) getParam(name);
> if (value == null)
> {
> String str = System.getProperty(this.prefix + name);
> @@ -263,19 +282,19 @@
> return value;
> }
>
> - protected Short getShort(FileSystemOptions opts, String name)
> + protected Short getShort(String name)
> {
> - return getShort(opts, name, null);
> + return getShort(name, null);
> }
>
> - protected short getShort(FileSystemOptions opts, String name,
> short defaultValue)
> + protected short getShort(String name, short defaultValue)
> {
> - return getShort(opts, name, new Short
> (defaultValue)).shortValue();
> + return getShort(name, new Short(defaultValue)).shortValue();
> }
>
> - protected Short getShort(FileSystemOptions opts, String name,
> Short defaultValue)
> + protected Short getShort(String name, Short defaultValue)
> {
> - Short value = (Short) getParam(opts, name);
> + Short value = (Short) getParam(name);
> if (value == null)
> {
> String str = System.getProperty(this.prefix + name);
> @@ -288,14 +307,14 @@
> return value;
> }
>
> - protected String getString(FileSystemOptions opts, String name)
> + protected String getString(String name)
> {
> - return getString(opts, name, null);
> + return getString(name, null);
> }
>
> - protected String getString(FileSystemOptions opts, String name,
> String defaultValue)
> + protected String getString(String name, String defaultValue)
> {
> - String value = (String) getParam(opts, name);
> + String value = (String) getParam(name);
> if (value == null)
> {
> value = System.getProperty(this.prefix + name);
> @@ -306,6 +325,4 @@
> }
> return value;
> }
> -
> - protected abstract Class getConfigClass();
> -}
> +}
> \ No newline at end of file
>
> Propchange: commons/proper/vfs/branches/VFS281/core/src/main/java/
> org/apache/commons/vfs/DefaultFileSystemOptions.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Propchange: commons/proper/vfs/branches/VFS281/core/src/main/java/
> org/apache/commons/vfs/DefaultFileSystemOptions.java
> ------------------------------------------------------------------------------
> svn:keywords = Date Author Id Revision HeadURL
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/FileSystemConfigBuilder.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/FileSystemConfigBuilder.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/FileSystemConfigBuilder.java Sun Sep 13 06:26:23 2009
> @@ -21,6 +21,7 @@
> *
> * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
> * @version $Revision$ $Date$
> + * @deprecated Use FileSystemOptions classes instead.
> */
> public abstract class FileSystemConfigBuilder
> {
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/FileSystemManager.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemManager.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/FileSystemManager.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/FileSystemManager.java Sun Sep 13 06:26:23 2009
> @@ -297,6 +297,14 @@
> FileSystemConfigBuilder getFileSystemConfigBuilder(final String
> scheme) throws FileSystemException;
>
> /**
> + * Get the FileSystemOptions for the specified scheme.
> + * @param scheme The protocol.
> + * @return The FileSystemOptions for the specified scheme.
> + * @throws FileSystemException if an error occurs.
> + */
> + FileSystemOptions getFileSystemOptions(final String scheme)
> throws FileSystemException;
> +
> + /**
> * Resolve the uri to a filename.
> *
> * @param uri The uri to resolve.
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/FileSystemOptions.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/FileSystemOptions.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/FileSystemOptions.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/FileSystemOptions.java Sun Sep 13 06:26:23 2009
> @@ -26,14 +26,34 @@
> *
> * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
> * @version $Revision$ $Date$
> - * @see
> org.apache.commons.vfs.provider.sftp.SftpFileSystemConfigBuilder
> - * @see
> org.apache.commons.vfs.provider.ftp.FtpFileSystemConfigBuilder
> */
> -public final class FileSystemOptions implements Cloneable
> +public class FileSystemOptions implements Cloneable
> {
> /** The options */
> private Map options = new TreeMap();
>
> + public static <T extends FileSystemOptions> T makeSpecific
> (Class<T> clazz, FileSystemOptions fsOptions)
> + {
> + if (fsOptions == null)
> + {
> + return null;
> + }
> + if (clazz.isAssignableFrom(fsOptions.getClass()))
> + {
> + return (T) fsOptions;
> + }
> + try
> + {
> + T obj = clazz.newInstance();
> + obj.options = fsOptions.options;
> + return obj;
> + }
> + catch (Exception ex)
> + {
> + return null;
> + }
> + }
> +
> /**
> * Keys in the options Map.
> */
> @@ -165,10 +185,11 @@
> /**
> * {@inheritDoc}
> */
> - public Object clone() {
> - FileSystemOptions clone = new FileSystemOptions();
> + public Object clone() throws CloneNotSupportedException
> + {
> + FileSystemOptions clone = (FileSystemOptions) super.clone();
> clone.options = new TreeMap(options);
> return clone;
> }
> -
> +
> }
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/impl/DefaultFileSystemConfigBuilder.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/impl/DefaultFileSystemConfigBuilder.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/impl/DefaultFileSystemConfigBuilder.java Sun Sep 13
> 06:26:23 2009
> @@ -24,6 +24,7 @@
> /**
> * Default options usable for all filesystems.
> * @author <a href="http://commons.apache.org/vfs/team-
> list.html">Commons VFS team</a>
> + * @deprecated Use AbstractFileSystemOptions
> */
> public class DefaultFileSystemConfigBuilder extends
> FileSystemConfigBuilder
> {
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/impl/DefaultFileSystemManager.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/impl/DefaultFileSystemManager.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/impl/DefaultFileSystemManager.java Sun Sep 13 06:26:23
> 2009
> @@ -81,7 +81,7 @@
> /**
> * Mapping from URI scheme to FileProvider.
> */
> - private final Map providers = new HashMap();
> + private final Map<String, FileProvider> providers = new
> HashMap<String, FileProvider>();
>
> /**
> * All components used by this manager.
> @@ -1077,6 +1077,7 @@
> * @param scheme The scheme to locate.
> * @return The FileSystemConfigBuilder for the scheme.
> * @throws FileSystemException if the given scheme is not konwn
> + * @deprecated - Use the FileSystemOptions for the scheme.
> */
> public FileSystemConfigBuilder getFileSystemConfigBuilder(final
> String scheme)
> throws FileSystemException
> @@ -1090,6 +1091,23 @@
> return provider.getConfigBuilder();
> }
>
> + /**
> + * Get the FileSystemOptions for the specified scheme.
> + * @param scheme The protocol.
> + * @return The FileSystemOptions for the specified scheme.
> + * @throws FileSystemException if an error occurs.
> + */
> + public FileSystemOptions getFileSystemOptions(final String
> scheme)
> + throws FileSystemException
> + {
> + FileProvider provider = providers.get(scheme);
> + if (provider == null)
> + {
> + throw new FileSystemException("vfs.impl/unknown-
> scheme.error", new Object[] {scheme});
> + }
> + return provider.getFileSystemOptions();
> + }
> +
> // -- OPERATIONS --
>
> /**
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/AbstractFileProvider.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/AbstractFileProvider.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/AbstractFileProvider.java Sun Sep 13 06:26:23
> 2009
> @@ -16,12 +16,7 @@
> */
> package org.apache.commons.vfs.provider;
>
> -import org.apache.commons.vfs.FileName;
> -import org.apache.commons.vfs.FileObject;
> -import org.apache.commons.vfs.FileSystem;
> -import org.apache.commons.vfs.FileSystemConfigBuilder;
> -import org.apache.commons.vfs.FileSystemException;
> -import org.apache.commons.vfs.FileSystemOptions;
> +import org.apache.commons.vfs.*;
> import org.apache.commons.vfs.provider.local.GenericFileNameParser;
>
> import java.util.Map;
> @@ -45,11 +40,26 @@
> // private final Map fileSystems = new HashMap();
> private final Map fileSystems = new TreeMap();
>
> + private final Class<? extends FileSystemOptions>
> fileSystemOptionsClass;
> +
> private FileNameParser parser;
>
> public AbstractFileProvider()
> {
> parser = GenericFileNameParser.getInstance();
> + fileSystemOptionsClass = DefaultFileSystemOptions.class;
> + }
> +
> + protected AbstractFileProvider(Class<? extends
> FileSystemOptions> optionsClass)
> + {
> + parser = GenericFileNameParser.getInstance();
> + fileSystemOptionsClass = optionsClass;
> + }
> +
> + protected AbstractFileProvider(FileNameParser fileNameParser,
> Class<? extends FileSystemOptions> optionsClass)
> + {
> + parser = fileNameParser;
> + fileSystemOptionsClass = optionsClass;
> }
>
> protected FileNameParser getFileNameParser()
> @@ -191,4 +201,20 @@
> throw new FileSystemException("vfs.provider/filename-parser-
> missing.error");
> // return GenericFileName.parseUri(getFileNameParser(), uri,
> 0);
> }
> +
> + /**
> + * Returns a FileSystemOptions instance appropriate for this
> provider.
> + * @return The FileSystemOptions.
> + */
> + public FileSystemOptions getFileSystemOptions()
> + {
> + try
> + {
> + return fileSystemOptionsClass.newInstance();
> + }
> + catch (Exception ex)
> + {
> + return null;
> + }
> + }
> }
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/AbstractFileSystem.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileSystem.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/AbstractFileSystem.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/AbstractFileSystem.java Sun Sep 13 06:26:23 2009
> @@ -18,20 +18,7 @@
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> -import org.apache.commons.vfs.CacheStrategy;
> -import org.apache.commons.vfs.Capability;
> -import org.apache.commons.vfs.FileListener;
> -import org.apache.commons.vfs.FileName;
> -import org.apache.commons.vfs.FileObject;
> -import org.apache.commons.vfs.FileSelector;
> -import org.apache.commons.vfs.FileSystem;
> -import org.apache.commons.vfs.FileSystemException;
> -import org.apache.commons.vfs.FileSystemManager;
> -import org.apache.commons.vfs.FileSystemOptions;
> -import org.apache.commons.vfs.FilesCache;
> -import org.apache.commons.vfs.VfsLog;
> -import org.apache.commons.vfs.FileSystemConfigBuilder;
> -import org.apache.commons.vfs.impl.DefaultFileSystemConfigBuilder;
> +import org.apache.commons.vfs.*;
> import org.apache.commons.vfs.cache.OnCallRefreshFileObject;
> import org.apache.commons.vfs.events.AbstractFileChangeEvent;
> import org.apache.commons.vfs.events.ChangedEvent;
> @@ -107,12 +94,40 @@
> final FileObject parentLayer,
> final FileSystemOptions
> fileSystemOptions)
> {
> + this(rootName, parentLayer, fileSystemOptions, null);
> + }
> +
> + protected AbstractFileSystem(final FileName rootName,
> + final FileObject parentLayer,
> + final FileSystemOptions
> fileSystemOptions,
> + final Class<? extends
> FileSystemOptions> optionsClass)
> + {
> // this.parentLayer = parentLayer;
> this.parentLayer = parentLayer;
> this.rootName = rootName;
> - this.fileSystemOptions = fileSystemOptions;
> - FileSystemConfigBuilder builder =
> DefaultFileSystemConfigBuilder.getInstance();
> - String uri = builder.getRootURI(fileSystemOptions);
> + if (optionsClass == null)
> + {
> + this.fileSystemOptions = fileSystemOptions == null ?
> new PrivateFileSystemOptions() : fileSystemOptions;
> + }
> + else
> + {
> + if (fileSystemOptions != null)
> + {
> + this.fileSystemOptions =
> FileSystemOptions.makeSpecific(optionsClass, fileSystemOptions);
> + }
> + else
> + {
> + try
> + {
> + this.fileSystemOptions =
> optionsClass.newInstance();
> + }
> + catch (Exception ex)
> + {
> + throw new IllegalArgumentException("Invalid
> optiosn class", ex);
> + }
> + }
> + }
> + String uri = ((DefaultFileSystemOptions)
> this.fileSystemOptions).getRootURI();
> if (uri == null)
> {
> uri = rootName.getURI();
> @@ -437,6 +452,11 @@
> return fileSystemOptions;
> }
>
> + protected <T extends FileSystemOptions> T getOptions()
> + {
> + return (T) fileSystemOptions;
> + }
> +
> /**
> * Return the FileSystemManager used to instantiate this
> filesystem.
> * @return the FileSystemManager.
> @@ -679,4 +699,9 @@
> return openStreams > 0;
> }
> }
> +
> + private class PrivateFileSystemOptions extends
> DefaultFileSystemOptions
> + {
> +
> + }
> }
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/AbstractOriginatingFileProvider.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/AbstractOriginatingFileProvider.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/AbstractOriginatingFileProvider.java Sun Sep 13
> 06:26:23 2009
> @@ -38,6 +38,16 @@
> super();
> }
>
> + protected AbstractOriginatingFileProvider(Class<? extends
> FileSystemOptions> optionsClass)
> + {
> + super(optionsClass);
> + }
> +
> + protected AbstractOriginatingFileProvider(FileNameParser
> fileNameParser, Class<? extends FileSystemOptions> optionsClass)
> + {
> + super(fileNameParser, optionsClass);
> + }
> +
> /**
> * Locates a file object, by absolute URI.
> *
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/FileProvider.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/FileProvider.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/FileProvider.java Sun Sep 13 06:26:23 2009
> @@ -64,6 +64,7 @@
> /**
> * Gets the configbuilder useable to collect the needed
> fileSystemOptions.
> * @return a FileSystemConfigBuilder for the particular file
> system.
> + * @deprecated - Use FileSystemOptions specific to the scheme
> instead.
> */
> FileSystemConfigBuilder getConfigBuilder();
>
> @@ -83,4 +84,10 @@
> * @throws FileSystemException if an error occurs.
> */
> FileName parseUri(FileName root, String uri) throws
> FileSystemException;
> -}
> +
> + /**
> + * Return FileSystemOptions appropriate for the specific
> provider.
> + * @return A FileSystemOptions instance.
> + */
> + FileSystemOptions getFileSystemOptions();
> +}
> \ No newline at end of file
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/ftp/FTPClientWrapper.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FTPClientWrapper.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FTPClientWrapper.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FTPClientWrapper.java Sun Sep 13 06:26:23
> 2009
> @@ -37,11 +37,11 @@
> class FTPClientWrapper implements FtpClient
> {
> private final GenericFileName root;
> - private final FileSystemOptions fileSystemOptions;
> + private final FtpFileSystemOptions fileSystemOptions;
>
> private FTPClient ftpClient;
>
> - FTPClientWrapper(final GenericFileName root, final
> FileSystemOptions fileSystemOptions) throws FileSystemException
> + FTPClientWrapper(final GenericFileName root, final
> FtpFileSystemOptions fileSystemOptions) throws FileSystemException
> {
> this.root = root;
> this.fileSystemOptions = fileSystemOptions;
> @@ -53,7 +53,7 @@
> return root;
> }
>
> - public FileSystemOptions getFileSystemOptions()
> + public FtpFileSystemOptions getFileSystemOptions()
> {
> return fileSystemOptions;
> }
> @@ -74,7 +74,7 @@
> UserAuthenticatorUtils.getData(authData,
> UserAuthenticationData.PASSWORD,
> UserAuthenticatorUtils.toChar
> (rootName.getPassword())),
> rootName.getPath(),
> - getFileSystemOptions());
> + fileSystemOptions);
> }
> finally
> {
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/ftp/FtpClientFactory.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpClientFactory.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpClientFactory.java Sun Sep 13 06:26:23
> 2009
> @@ -52,7 +52,7 @@
> * @throws FileSystemException if an error occurs while
> connecting.
> */
> public static FTPClient createConnection(String hostname, int
> port, char[] username, char[] password,
> - String
> workingDirectory, FileSystemOptions fileSystemOptions)
> + String
> workingDirectory, FtpFileSystemOptions fileSystemOptions)
> throws FileSystemException
> {
> // Determine the username and password to use
> @@ -70,37 +70,32 @@
> {
> final FTPClient client = new FTPClient();
>
> - String key = FtpFileSystemConfigBuilder.getInstance
> ().getEntryParser(fileSystemOptions);
> + String key = fileSystemOptions.getEntryParser();
> if (key != null)
> {
> FTPClientConfig config = new FTPClientConfig(key);
>
> - String serverLanguageCode =
> - FtpFileSystemConfigBuilder.getInstance
> ().getServerLanguageCode(fileSystemOptions);
> + String serverLanguageCode =
> fileSystemOptions.getServerLanguageCode();
> if (serverLanguageCode != null)
> {
> config.setServerLanguageCode(serverLanguageCode);
> }
> - String defaultDateFormat =
> - FtpFileSystemConfigBuilder.getInstance
> ().getDefaultDateFormat(fileSystemOptions);
> + String defaultDateFormat =
> fileSystemOptions.getDefaultDateFormat();
> if (defaultDateFormat != null)
> {
> config.setDefaultDateFormatStr(defaultDateFormat);
> }
> - String recentDateFormat =
> - FtpFileSystemConfigBuilder.getInstance
> ().getRecentDateFormat(fileSystemOptions);
> + String recentDateFormat =
> fileSystemOptions.getRecentDateFormat();
> if (recentDateFormat != null)
> {
> config.setRecentDateFormatStr(recentDateFormat);
> }
> - String serverTimeZoneId =
> - FtpFileSystemConfigBuilder.getInstance
> ().getServerTimeZoneId(fileSystemOptions);
> + String serverTimeZoneId =
> fileSystemOptions.getServerTimeZoneId();
> if (serverTimeZoneId != null)
> {
> config.setServerTimeZoneId(serverTimeZoneId);
> }
> - String[] shortMonthNames =
> - FtpFileSystemConfigBuilder.getInstance
> ().getShortMonthNames(fileSystemOptions);
> + String[] shortMonthNames =
> fileSystemOptions.getShortMonthNames();
> if (shortMonthNames != null)
> {
> StringBuffer shortMonthNamesStr = new
> StringBuffer(BUFSZ);
> @@ -118,8 +113,7 @@
> client.configure(config);
> }
>
> - FTPFileEntryParserFactory myFactory =
> - FtpFileSystemConfigBuilder.getInstance
> ().getEntryParserFactory(fileSystemOptions);
> + FTPFileEntryParserFactory myFactory =
> fileSystemOptions.getEntryParserFactory();
> if (myFactory != null)
> {
> client.setParserFactory(myFactory);
> @@ -151,7 +145,7 @@
> }
>
> // Set dataTimeout value
> - Integer dataTimeout =
> FtpFileSystemConfigBuilder.getInstance().getDataTimeout
> (fileSystemOptions);
> + Integer dataTimeout =
> fileSystemOptions.getDataTimeout();
> if (dataTimeout != null)
> {
> client.setDataTimeout(dataTimeout.intValue());
> @@ -161,7 +155,7 @@
> // All file operations a relative to the filesystem-
> root
> // String root = getRoot().getName().getPath();
>
> - Boolean userDirIsRoot =
> FtpFileSystemConfigBuilder.getInstance().getUserDirIsRoot
> (fileSystemOptions);
> + Boolean userDirIsRoot =
> fileSystemOptions.getUserDirIsRoot();
> if (workingDirectory != null && (userDirIsRoot ==
> null || !userDirIsRoot.booleanValue()))
> {
> if (!client.changeWorkingDirectory
> (workingDirectory))
> @@ -170,7 +164,7 @@
> }
> }
>
> - Boolean passiveMode =
> FtpFileSystemConfigBuilder.getInstance().getPassiveMode
> (fileSystemOptions);
> + Boolean passiveMode =
> fileSystemOptions.getPassiveMode();
> if (passiveMode != null && passiveMode.booleanValue())
> {
> client.enterLocalPassiveMode();
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/ftp/FtpFileProvider.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpFileProvider.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpFileProvider.java Sun Sep 13 06:26:23 2009
> @@ -67,10 +67,11 @@
> Capability.RANDOM_ACCESS_READ,
> }));
>
> + private static final Class<? extends FileSystemOptions>
> FSOPTIONS_CLASS = FtpFileSystemOptions.class;
> +
> public FtpFileProvider()
> {
> - super();
> - setFileNameParser(FtpFileNameParser.getInstance());
> + super(FtpFileNameParser.getInstance(), FSOPTIONS_CLASS);
> }
>
> /**
> @@ -82,7 +83,9 @@
> // Create the file system
> final GenericFileName rootName = (GenericFileName) name;
>
> - FTPClientWrapper ftpClient = new FTPClientWrapper(rootName,
> fileSystemOptions);
> + FtpFileSystemOptions options =
> FileSystemOptions.makeSpecific(FtpFileSystemOptions.class,
> fileSystemOptions);
> +
> + FTPClientWrapper ftpClient = new FTPClientWrapper(rootName,
> options);
> /*
> FTPClient ftpClient = FtpClientFactory.createConnection
> (rootName.getHostName(),
> rootName.getPort(),
> @@ -92,7 +95,7 @@
> fileSystemOptions);
> */
>
> - return new FtpFileSystem(rootName, ftpClient,
> fileSystemOptions);
> + return new FtpFileSystem(rootName, ftpClient, options,
> FSOPTIONS_CLASS);
> }
>
> public FileSystemConfigBuilder getConfigBuilder()
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/ftp/FtpFileSystem.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpFileSystem.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpFileSystem.java Sun Sep 13 06:26:23 2009
> @@ -35,8 +35,7 @@
> * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
> * @version $Revision$ $Date$
> */
> -public class FtpFileSystem
> - extends AbstractFileSystem
> +public class FtpFileSystem extends AbstractFileSystem
> {
> private static final Log LOG = LogFactory.getLog
> (FtpFileSystem.class);
>
> @@ -49,9 +48,10 @@
> private FtpClient idleClient;
>
> protected FtpFileSystem(final GenericFileName rootName, final
> FtpClient ftpClient,
> - final FileSystemOptions
> fileSystemOptions)
> + final FileSystemOptions
> fileSystemOptions,
> + final Class<? extends
> FileSystemOptions> optionsClass)
> {
> - super(rootName, null, fileSystemOptions);
> + super(rootName, null, fileSystemOptions, optionsClass);
> // hostname = rootName.getHostName();
> // port = rootName.getPort();
>
> @@ -149,4 +149,9 @@
> {
> return new FtpFileObject(name, this, getRootName());
> }
> +
> + public FtpFileSystemOptions getFileSystemOptions()
> + {
> + return super.getOptions();
> + }
> }
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java Sun Sep 13
> 06:26:23 2009
> @@ -25,27 +25,12 @@
> *
> * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
> * @version $Revision$ $Date$
> + * @deprecated Use FTPFileSystemOptions instead.
> */
> public final class FtpFileSystemConfigBuilder extends
> FileSystemConfigBuilder
> {
> private static final FtpFileSystemConfigBuilder builder = new
> FtpFileSystemConfigBuilder();
>
> - private static final String FACTORY_KEY =
> FTPFileEntryParserFactory.class.getName() + ".KEY";
> - private static final String PASSIVE_MODE =
> FtpFileSystemConfigBuilder.class.getName() + ".PASSIVE";
> - private static final String USER_DIR_IS_ROOT =
> FtpFileSystemConfigBuilder.class.getName() + ".USER_DIR_IS_ROOT";
> - private static final String DATA_TIMEOUT =
> FtpFileSystemConfigBuilder.class.getName() + ".DATA_TIMEOUT";
> -
> - private static final String SERVER_LANGUAGE_CODE =
> - FtpFileSystemConfigBuilder.class.getName() +
> ".SERVER_LANGUAGE_CODE";
> - private static final String DEFAULT_DATE_FORMAT =
> - FtpFileSystemConfigBuilder.class.getName() +
> ".DEFAULT_DATE_FORMAT";
> - private static final String RECENT_DATE_FORMAT =
> - FtpFileSystemConfigBuilder.class.getName() +
> ".RECENT_DATE_FORMAT";
> - private static final String SERVER_TIME_ZONE_ID =
> - FtpFileSystemConfigBuilder.class.getName() +
> ".SERVER_TIME_ZONE_ID";
> - private static final String SHORT_MONTH_NAMES =
> - FtpFileSystemConfigBuilder.class.getName() +
> ".SHORT_MONTH_NAMES";
> -
> private FtpFileSystemConfigBuilder()
> {
> super("ftp.");
> @@ -64,7 +49,7 @@
> */
> public void setEntryParserFactory(FileSystemOptions opts,
> FTPFileEntryParserFactory factory)
> {
> - setParam(opts, FTPFileEntryParserFactory.class.getName(),
> factory);
> + FtpFileSystemOptions.getInstance(opts).setEntryParserFactory
> (factory);
> }
>
> /**
> @@ -74,7 +59,7 @@
> */
> public FTPFileEntryParserFactory getEntryParserFactory
> (FileSystemOptions opts)
> {
> - return (FTPFileEntryParserFactory) getParam(opts,
> FTPFileEntryParserFactory.class.getName());
> + return FtpFileSystemOptions.getInstance
> (opts).getEntryParserFactory();
> }
>
> /**
> @@ -89,7 +74,7 @@
> */
> public void setEntryParser(FileSystemOptions opts, String key)
> {
> - setParam(opts, FACTORY_KEY, key);
> + FtpFileSystemOptions.getInstance(opts).setEntryParser(key);
> }
>
> /**
> @@ -99,7 +84,7 @@
> */
> public String getEntryParser(FileSystemOptions opts)
> {
> - return getString(opts, FACTORY_KEY);
> + return FtpFileSystemOptions.getInstance(opts).getEntryParser
> ();
> }
>
> protected Class getConfigClass()
> @@ -115,7 +100,7 @@
> */
> public void setPassiveMode(FileSystemOptions opts, boolean
> passiveMode)
> {
> - setParam(opts, PASSIVE_MODE, passiveMode ? Boolean.TRUE :
> Boolean.FALSE);
> + FtpFileSystemOptions.getInstance(opts).setPassiveMode
> (passiveMode);
> }
>
> /**
> @@ -125,7 +110,7 @@
> */
> public Boolean getPassiveMode(FileSystemOptions opts)
> {
> - return getBoolean(opts, PASSIVE_MODE);
> + return FtpFileSystemOptions.getInstance(opts).getPassiveMode
> ();
> }
>
> /**
> @@ -136,7 +121,7 @@
> */
> public void setUserDirIsRoot(FileSystemOptions opts, boolean
> userDirIsRoot)
> {
> - setParam(opts, USER_DIR_IS_ROOT, userDirIsRoot ?
> Boolean.TRUE : Boolean.FALSE);
> + FtpFileSystemOptions.getInstance(opts).setUserDirIsRoot
> (userDirIsRoot);
> }
>
> /**
> @@ -146,7 +131,7 @@
> */
> public Boolean getUserDirIsRoot(FileSystemOptions opts)
> {
> - return getBoolean(opts, USER_DIR_IS_ROOT);
> + return FtpFileSystemOptions.getInstance
> (opts).getUserDirIsRoot();
> }
>
> /**
> @@ -156,7 +141,7 @@
> */
> public Integer getDataTimeout(FileSystemOptions opts)
> {
> - return getInteger(opts, DATA_TIMEOUT);
> + return FtpFileSystemOptions.getInstance(opts).getDataTimeout
> ();
> }
>
> /**
> @@ -169,7 +154,7 @@
> */
> public void setDataTimeout(FileSystemOptions opts, Integer
> dataTimeout)
> {
> - setParam(opts, DATA_TIMEOUT, dataTimeout);
> + FtpFileSystemOptions.getInstance(opts).setDataTimeout
> (dataTimeout);
> }
>
> /**
> @@ -180,7 +165,7 @@
> */
> public String getServerLanguageCode(FileSystemOptions opts)
> {
> - return getString(opts, SERVER_LANGUAGE_CODE);
> + return FtpFileSystemOptions.getInstance
> (opts).getServerLanguageCode();
> }
>
> /**
> @@ -191,7 +176,7 @@
> */
> public void setServerLanguageCode(FileSystemOptions opts, String
> serverLanguageCode)
> {
> - setParam(opts, SERVER_LANGUAGE_CODE, serverLanguageCode);
> + FtpFileSystemOptions.getInstance(opts).setServerLanguageCode
> (serverLanguageCode);
> }
>
> /**
> @@ -202,7 +187,7 @@
> */
> public String getDefaultDateFormat(FileSystemOptions opts)
> {
> - return getString(opts, DEFAULT_DATE_FORMAT);
> + return FtpFileSystemOptions.getInstance
> (opts).getDefaultDateFormat();
> }
>
> /**
> @@ -213,7 +198,7 @@
> */
> public void setDefaultDateFormat(FileSystemOptions opts, String
> defaultDateFormat)
> {
> - setParam(opts, DEFAULT_DATE_FORMAT, defaultDateFormat);
> + FtpFileSystemOptions.getInstance(opts).setDefaultDateFormat
> (defaultDateFormat);
> }
>
> /**
> @@ -223,7 +208,7 @@
> */
> public String getRecentDateFormat(FileSystemOptions opts)
> {
> - return getString(opts, RECENT_DATE_FORMAT);
> + return FtpFileSystemOptions.getInstance
> (opts).getRecentDateFormat();
> }
>
> /**
> @@ -233,7 +218,7 @@
> */
> public void setRecentDateFormat(FileSystemOptions opts, String
> recentDateFormat)
> {
> - setParam(opts, RECENT_DATE_FORMAT, recentDateFormat);
> + FtpFileSystemOptions.getInstance(opts).setRecentDateFormat
> (recentDateFormat);
> }
>
> /**
> @@ -243,7 +228,7 @@
> */
> public String getServerTimeZoneId(FileSystemOptions opts)
> {
> - return getString(opts, SERVER_TIME_ZONE_ID);
> + return FtpFileSystemOptions.getInstance
> (opts).getServerTimeZoneId();
> }
>
> /**
> @@ -253,7 +238,7 @@
> */
> public void setServerTimeZoneId(FileSystemOptions opts, String
> serverTimeZoneId)
> {
> - setParam(opts, SERVER_TIME_ZONE_ID, serverTimeZoneId);
> + FtpFileSystemOptions.getInstance(opts).setServerTimeZoneId
> (serverTimeZoneId);
> }
>
> /**
> @@ -263,7 +248,7 @@
> */
> public String[] getShortMonthNames(FileSystemOptions opts)
> {
> - return (String[]) getParam(opts, SHORT_MONTH_NAMES);
> + return FtpFileSystemOptions.getInstance
> (opts).getShortMonthNames();
> }
>
> /**
> @@ -273,13 +258,6 @@
> */
> public void setShortMonthNames(FileSystemOptions opts, String[]
> shortMonthNames)
> {
> - String[] clone = null;
> - if (shortMonthNames != null)
> - {
> - clone = new String[shortMonthNames.length];
> - System.arraycopy(shortMonthNames, 0, clone, 0,
> shortMonthNames.length);
> - }
> -
> - setParam(opts, SHORT_MONTH_NAMES, clone);
> + FtpFileSystemOptions.getInstance(opts).setShortMonthNames
> (shortMonthNames);
> }
> }
>
> Added: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/ftp/FtpFileSystemOptions.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemOptions.java?rev=814264&view=auto
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpFileSystemOptions.java (added)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ftp/FtpFileSystemOptions.java Sun Sep 13
> 06:26:23 2009
> @@ -0,0 +1,261 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements. See the NOTICE file distributed
> with
> + * this work for additional information regarding copyright
> ownership.
> + * The ASF licenses this file to You under the Apache License,
> Version 2.0
> + * (the "License"); you may not use this file except in compliance
> with
> + * the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions
> and
> + * limitations under the License.
> + */
> +package org.apache.commons.vfs.provider.ftp;
> +
> +import org.apache.commons.vfs.FileSystemOptions;
> +import org.apache.commons.vfs.DefaultFileSystemOptions;
> +import org.apache.commons.net.ftp.parser.FTPFileEntryParserFactory;
> +
> +/**
> + * FTP File System Options
> + * @author <a href="http://commons.apache.org/vfs/team-
> list.html">Commons VFS team</a>
> + */
> +public class FtpFileSystemOptions extends DefaultFileSystemOptions
> +{
> + // Why are these keys prefixed with a class name?
> FileSystemOptionsKey does that automatically.
> + private static final String FACTORY_KEY =
> FTPFileEntryParserFactory.class.getName() + ".KEY";
> + private static final String PASSIVE_MODE =
> FtpFileSystemConfigBuilder.class.getName() + ".PASSIVE";
> + private static final String USER_DIR_IS_ROOT =
> FtpFileSystemConfigBuilder.class.getName() + ".USER_DIR_IS_ROOT";
> + private static final String DATA_TIMEOUT =
> FtpFileSystemConfigBuilder.class.getName() + ".DATA_TIMEOUT";
> +
> + private static final String SERVER_LANGUAGE_CODE =
> + FtpFileSystemConfigBuilder.class.getName() +
> ".SERVER_LANGUAGE_CODE";
> + private static final String DEFAULT_DATE_FORMAT =
> + FtpFileSystemConfigBuilder.class.getName() +
> ".DEFAULT_DATE_FORMAT";
> + private static final String RECENT_DATE_FORMAT =
> + FtpFileSystemConfigBuilder.class.getName() +
> ".RECENT_DATE_FORMAT";
> + private static final String SERVER_TIME_ZONE_ID =
> + FtpFileSystemConfigBuilder.class.getName() +
> ".SERVER_TIME_ZONE_ID";
> + private static final String SHORT_MONTH_NAMES =
> + FtpFileSystemConfigBuilder.class.getName() +
> ".SHORT_MONTH_NAMES";
> +
> + public FtpFileSystemOptions()
> + {
> + this("ftp.");
> + }
> +
> + protected FtpFileSystemOptions(String scheme)
> + {
> + super(scheme);
> + }
> +
> + public static FtpFileSystemOptions getInstance
> (FileSystemOptions opts)
> + {
> + return FileSystemOptions.makeSpecific
> (FtpFileSystemOptions.class, opts);
> + }
> + /**
> + * FTPFileEntryParserFactory which will be used for ftp-entry
> parsing.
> + *
> + * @param factory instance of your factory
> + */
> + public void setEntryParserFactory(FTPFileEntryParserFactory
> factory)
> + {
> + setParam(FTPFileEntryParserFactory.class.getName(), factory);
> + }
> +
> + /**
> + * @see #setEntryParserFactory
> + * @return An FTPFileEntryParserFactory.
> + */
> + public FTPFileEntryParserFactory getEntryParserFactory()
> + {
> + return (FTPFileEntryParserFactory) getParam
> (FTPFileEntryParserFactory.class.getName());
> + }
> +
> + /**
> + * set the FQCN of your FileEntryParser used to parse the
> directory listing from your server.<br />
> + * <br />
> + * <i>If you do not use the default commons-net
> FTPFileEntryParserFactory e.g. by using
> + * {@link #setEntryParserFactory}
> + * this is the "key" parameter passed as argument into your
> custom factory</i>
> + *
> + * @param key The key.
> + */
> + public void setEntryParser(String key)
> + {
> + setParam(FACTORY_KEY, key);
> + }
> +
> + /**
> + * @see #setEntryParser
> + * @return the key to the EntryParser.
> + */
> + public String getEntryParser()
> + {
> + return getString(FACTORY_KEY);
> + }
> +
> + /**
> + * enter into passive mode.
> + *
> + * @param passiveMode true if passive mode should be used.
> + */
> + public void setPassiveMode(boolean passiveMode)
> + {
> + setParam(PASSIVE_MODE, passiveMode ? Boolean.TRUE :
> Boolean.FALSE);
> + }
> +
> + /**
> + * @return true if passive mode is set.
> + * @see #setPassiveMode
> + */
> + public Boolean getPassiveMode()
> + {
> + return getBoolean(PASSIVE_MODE);
> + }
> +
> + /**
> + * use user directory as root (do not change to fs root).
> + *
> + * @param userDirIsRoot true if the user directory should be
> treated as the root.
> + */
> + public void setUserDirIsRoot(boolean userDirIsRoot)
> + {
> + setParam(USER_DIR_IS_ROOT, userDirIsRoot ? Boolean.TRUE :
> Boolean.FALSE);
> + }
> +
> + /**
> + * @return true if the user directory is treated as the root.
> + * @see #setUserDirIsRoot
> + */
> + public Boolean getUserDirIsRoot()
> + {
> + return getBoolean(USER_DIR_IS_ROOT);
> + }
> +
> + /**
> + * @return The timeout as an Integer.
> + * @see #setDataTimeout
> + */
> + public Integer getDataTimeout()
> + {
> + return getInteger(DATA_TIMEOUT);
> + }
> +
> + /**
> + * set the data timeout for the ftp client.<br />
> + * If you set the dataTimeout to <code>null</code> no
> dataTimeout will be set on the
> + * ftp client.
> + *
> + * @param dataTimeout The timeout value.
> + */
> + public void setDataTimeout(Integer dataTimeout)
> + {
> + setParam(DATA_TIMEOUT, dataTimeout);
> + }
> +
> + /**
> + * get the language code used by the server. see {@link
> org.apache.commons.net.ftp.FTPClientConfig}
> + * for details and examples.
> + * @return The language code of the server.
> + */
> + public String getServerLanguageCode()
> + {
> + return getString(SERVER_LANGUAGE_CODE);
> + }
> +
> + /**
> + * set the language code used by the server. see {@link
> org.apache.commons.net.ftp.FTPClientConfig}
> + * for details and examples.
> + * @param serverLanguageCode The servers language code.
> + */
> + public void setServerLanguageCode(String serverLanguageCode)
> + {
> + setParam(SERVER_LANGUAGE_CODE, serverLanguageCode);
> + }
> +
> + /**
> + * get the language code used by the server. see {@link
> org.apache.commons.net.ftp.FTPClientConfig}
> + * for details and examples.
> + * @return The default date format.
> + */
> + public String getDefaultDateFormat()
> + {
> + return getString(DEFAULT_DATE_FORMAT);
> + }
> +
> + /**
> + * set the language code used by the server. see {@link
> org.apache.commons.net.ftp.FTPClientConfig}
> + * for details and examples.
> + * @param defaultDateFormat The default date format.
> + */
> + public void setDefaultDateFormat(String defaultDateFormat)
> + {
> + setParam(DEFAULT_DATE_FORMAT, defaultDateFormat);
> + }
> +
> + /**
> + * see {@link org.apache.commons.net.ftp.FTPClientConfig} for
> details and examples.
> + * @return The recent date format.
> + */
> + public String getRecentDateFormat()
> + {
> + return getString(RECENT_DATE_FORMAT);
> + }
> +
> + /**
> + * see {@link org.apache.commons.net.ftp.FTPClientConfig} for
> details and examples.
> + * @param recentDateFormat The recent date format.
> + */
> + public void setRecentDateFormat(String recentDateFormat)
> + {
> + setParam(RECENT_DATE_FORMAT, recentDateFormat);
> + }
> +
> + /**
> + * see {@link org.apache.commons.net.ftp.FTPClientConfig} for
> details and examples.
> + * @return The server timezone id.
> + */
> + public String getServerTimeZoneId()
> + {
> + return getString(SERVER_TIME_ZONE_ID);
> + }
> +
> + /**
> + * see {@link org.apache.commons.net.ftp.FTPClientConfig} for
> details and examples.
> + * @param serverTimeZoneId The server timezone id.
> + */
> + public void setServerTimeZoneId(String serverTimeZoneId)
> + {
> + setParam(SERVER_TIME_ZONE_ID, serverTimeZoneId);
> + }
> +
> + /**
> + * see {@link org.apache.commons.net.ftp.FTPClientConfig} for
> details and examples.
> + * @return An array of short month names.
> + */
> + public String[] getShortMonthNames()
> + {
> + return (String[]) getParam(SHORT_MONTH_NAMES);
> + }
> +
> + /**
> + * see {@link org.apache.commons.net.ftp.FTPClientConfig} for
> details and examples.
> + * @param shortMonthNames an array of short month name Strings.
> + */
> + public void setShortMonthNames(String[] shortMonthNames)
> + {
> + String[] clone = null;
> + if (shortMonthNames != null)
> + {
> + clone = new String[shortMonthNames.length];
> + System.arraycopy(shortMonthNames, 0, clone, 0,
> shortMonthNames.length);
> + }
> +
> + setParam(SHORT_MONTH_NAMES, clone);
> + }
> +}
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/http/HttpClientFactory.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpClientFactory.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpClientFactory.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpClientFactory.java Sun Sep 13 06:26:23
> 2009
> @@ -42,22 +42,43 @@
> {
> }
>
> - public static HttpClient createConnection(String scheme, String
> hostname, int port, String username,
> + /**
> + * Creates a new connection to the server.
> + * @param builder The configuration builder.
> + * @param scheme The protocol.
> + * @param hostname The name of the host to connect to.
> + * @param port The port number to connect to.
> + * @param username The user name for authentication.
> + * @param password The password.
> + * @param fileSystemOptions FileSystemOptions.
> + * @return an HttpClient.
> + * @throws FileSystemException if an error occurs.
> + * @deprecated - HttpFileSystemConfigBuilder is not needed.
> + */
> + public static HttpClient createConnection
> (HttpFileSystemConfigBuilder builder, String scheme, String hostname,
> + int port, String
> username,
> String password,
> FileSystemOptions fileSystemOptions)
> throws FileSystemException
> {
> - return createConnection
> (HttpFileSystemConfigBuilder.getInstance(), scheme, hostname, port,
> - username, password, fileSystemOptions);
> + return createConnection(scheme, hostname, port, username,
> password, fileSystemOptions);
> }
>
> /**
> * Creates a new connection to the server.
> + * @param scheme The protocol.
> + * @param hostname The name of the host to connect to.
> + * @param port The port number to connect to.
> + * @param username The user name for authentication.
> + * @param password The password.
> + * @param fileSystemOptions FileSystemOptions.
> + * @return an HttpClient.
> + * @throws FileSystemException if an error occurs.
> */
> - public static HttpClient createConnection
> (HttpFileSystemConfigBuilder builder, String scheme,
> - String hostname, int
> port, String username,
> + public static HttpClient createConnection(String scheme, String
> hostname, int port, String username,
> String password,
> FileSystemOptions fileSystemOptions)
> throws FileSystemException
> {
> + HttpFileSystemOptions httpOpts =
> HttpFileSystemOptions.getInstance(fileSystemOptions);
> HttpClient client;
> try
> {
> @@ -71,15 +92,15 @@
>
> if (fileSystemOptions != null)
> {
> - String proxyHost = builder.getProxyHost
> (fileSystemOptions);
> - int proxyPort = builder.getProxyPort
> (fileSystemOptions);
> + String proxyHost = httpOpts.getProxyHost();
> + int proxyPort = httpOpts.getProxyPort();
>
> if (proxyHost != null && proxyHost.length() > 0 &&
> proxyPort > 0)
> {
> config.setProxy(proxyHost, proxyPort);
> }
>
> - UserAuthenticator proxyAuth =
> builder.getProxyAuthenticator(fileSystemOptions);
> + UserAuthenticator proxyAuth =
> httpOpts.getProxyAuthenticator();
> if (proxyAuth != null)
> {
> UserAuthenticationData authData =
> UserAuthenticatorUtils.authenticate(proxyAuth, new
> UserAuthenticationData.Type[]
> @@ -99,7 +120,7 @@
> }
> }
>
> - Cookie[] cookies = builder.getCookies
> (fileSystemOptions);
> + Cookie[] cookies = httpOpts.getCookies();
> if (cookies != null)
> {
> client.getState().addCookies(cookies);
> @@ -110,8 +131,8 @@
> * are set in the HostConfiguration. They are all used
> as part of the key when HttpConnectionManagerParams
> * tries to locate the host configuration.
> */
> - connectionMgrParams.setMaxConnectionsPerHost(config,
> builder.getMaxConnectionsPerHost(fileSystemOptions));
> - connectionMgrParams.setMaxTotalConnections
> (builder.getMaxTotalConnections(fileSystemOptions));
> + connectionMgrParams.setMaxConnectionsPerHost(config,
> httpOpts.getMaxConnectionsPerHost());
> + connectionMgrParams.setMaxTotalConnections
> (httpOpts.getMaxTotalConnections());
>
> client.setHostConfiguration(config);
>
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/http/HttpFileProvider.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpFileProvider.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpFileProvider.java Sun Sep 13 06:26:23
> 2009
> @@ -26,6 +26,7 @@
> import org.apache.commons.vfs.UserAuthenticationData;
> import
> org.apache.commons.vfs.provider.AbstractOriginatingFileProvider;
> import org.apache.commons.vfs.provider.GenericFileName;
> +import org.apache.commons.vfs.provider.FileNameParser;
> import org.apache.commons.vfs.util.UserAuthenticatorUtils;
>
> import java.util.Arrays;
> @@ -58,10 +59,16 @@
> UserAuthenticationData.USERNAME,
> UserAuthenticationData.PASSWORD
> };
>
> + private static final Class<? extends FileSystemOptions>
> FSOPTIONS_CLASS = HttpFileSystemOptions.class;
> +
> public HttpFileProvider()
> {
> - super();
> - setFileNameParser(HttpFileNameParser.getInstance());
> + super(HttpFileNameParser.getInstance(), FSOPTIONS_CLASS);
> + }
> +
> + protected HttpFileProvider(FileNameParser fileNameParser,
> Class<? extends FileSystemOptions> optionsClass)
> + {
> + super(fileNameParser, optionsClass);
> }
>
> /**
> @@ -92,9 +99,15 @@
> UserAuthenticatorUtils.cleanup(authData);
> }
>
> - return new HttpFileSystem(rootName, httpClient,
> fileSystemOptions);
> + return new HttpFileSystem(rootName, httpClient,
> fileSystemOptions, FSOPTIONS_CLASS);
> }
>
> + /**
> + * Get ConfigurationBuilder
> + * @return The FileSystemConfigBuilder.
> + * @deprecated - Use HttpFileSystemOptions instead.
> + */
> +
> public FileSystemConfigBuilder getConfigBuilder()
> {
> return HttpFileSystemConfigBuilder.getInstance();
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/http/HttpFileSystem.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystem.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpFileSystem.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpFileSystem.java Sun Sep 13 06:26:23 2009
> @@ -40,9 +40,11 @@
> {
> private final HttpClient client;
>
> - protected HttpFileSystem(final GenericFileName rootName, final
> HttpClient client, final FileSystemOptions fileSystemOptions)
> + protected HttpFileSystem(final GenericFileName rootName, final
> HttpClient client,
> + final FileSystemOptions
> fileSystemOptions,
> + final Class<? extends
> FileSystemOptions> optionsClass)
> {
> - super(rootName, null, fileSystemOptions);
> + super(rootName, null, fileSystemOptions, optionsClass);
> this.client = client;
> }
>
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpFileSystemConfigBuilder.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpFileSystemConfigBuilder.java Sun Sep
> 13 06:26:23 2009
> @@ -27,6 +27,7 @@
> *
> * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
> * @version $Revision$ $Date$
> + * @deprecated Use HttpFileSystemOptions instead.
> */
> public class HttpFileSystemConfigBuilder extends
> FileSystemConfigBuilder
> {
> @@ -37,10 +38,6 @@
> return builder;
> }
>
> - private static final int DEFAULT_MAX_HOST_CONNECTIONS = 5;
> -
> - private static final int DEFAULT_MAX_CONNECTIONS = 50;
> -
> protected HttpFileSystemConfigBuilder(String prefix)
> {
> super(prefix);
> @@ -58,7 +55,7 @@
> */
> public void setUrlCharset(FileSystemOptions opts, String chaset)
> {
> - setParam(opts, "urlCharset", chaset);
> + HttpFileSystemOptions.getInstance(opts).setUrlCharset
> (chaset);
> }
>
> /**
> @@ -68,7 +65,7 @@
> */
> public String getUrlCharset(FileSystemOptions opts)
> {
> - return getString(opts, "urlCharset");
> + return HttpFileSystemOptions.getInstance(opts).getUrlCharset
> ();
> }
>
> /**
> @@ -80,7 +77,7 @@
> */
> public void setProxyHost(FileSystemOptions opts, String proxyHost)
> {
> - setParam(opts, "proxyHost", proxyHost);
> + HttpFileSystemOptions.getInstance(opts).setProxyHost
> (proxyHost);
> }
>
> /**
> @@ -92,7 +89,7 @@
> */
> public void setProxyPort(FileSystemOptions opts, int proxyPort)
> {
> - setParam(opts, "proxyPort", new Integer(proxyPort));
> + HttpFileSystemOptions.getInstance(opts).setProxyPort
> (proxyPort);
> }
>
> /**
> @@ -104,7 +101,7 @@
> */
> public String getProxyHost(FileSystemOptions opts)
> {
> - return getString(opts, "proxyHost");
> + return HttpFileSystemOptions.getInstance(opts).getProxyHost
> ();
> }
>
> /**
> @@ -116,7 +113,7 @@
> */
> public int getProxyPort(FileSystemOptions opts)
> {
> - return getInteger(opts, "proxyPort", 0);
> + return HttpFileSystemOptions.getInstance(opts).getProxyPort
> ();
> }
>
> /**
> @@ -124,7 +121,7 @@
> */
> public void setProxyAuthenticator(FileSystemOptions opts,
> UserAuthenticator authenticator)
> {
> - setParam(opts, "proxyAuthenticator", authenticator);
> + HttpFileSystemOptions.getInstance
> (opts).setProxyAuthenticator(authenticator);
> }
>
> /**
> @@ -132,7 +129,7 @@
> */
> public UserAuthenticator getProxyAuthenticator(FileSystemOptions
> opts)
> {
> - return (UserAuthenticator) getParam(opts,
> "proxyAuthenticator");
> + return HttpFileSystemOptions.getInstance
> (opts).getProxyAuthenticator();
> }
>
> /**
> @@ -140,7 +137,7 @@
> */
> public void setCookies(FileSystemOptions opts, Cookie[] cookies)
> {
> - setParam(opts, "cookies", cookies);
> + HttpFileSystemOptions.getInstance(opts).setCookies(cookies);
> }
>
> /**
> @@ -148,7 +145,7 @@
> */
> public Cookie[] getCookies(FileSystemOptions opts)
> {
> - return (Cookie[]) getParam(opts, "cookies");
> + return HttpFileSystemOptions.getInstance(opts).getCookies();
> }
>
> /**
> @@ -156,7 +153,7 @@
> */
> public void setMaxTotalConnections(FileSystemOptions opts, int
> maxTotalConnections)
> {
> - setParam(opts,
> HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, new Integer
> (maxTotalConnections));
> + HttpFileSystemOptions.getInstance
> (opts).setMaxTotalConnections(maxTotalConnections);
> }
>
> /**
> @@ -166,7 +163,7 @@
> */
> public int getMaxTotalConnections(FileSystemOptions opts)
> {
> - return getInteger(opts,
> HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS,
> DEFAULT_MAX_CONNECTIONS);
> + return HttpFileSystemOptions.getInstance
> (opts).getMaxTotalConnections();
> }
>
> /**
> @@ -174,7 +171,7 @@
> */
> public void setMaxConnectionsPerHost(FileSystemOptions opts, int
> maxHostConnections)
> {
> - setParam(opts,
> HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, new Integer
> (maxHostConnections));
> + HttpFileSystemOptions.getInstance
> (opts).setMaxConnectionsPerHost(maxHostConnections);
> }
>
> /**
> @@ -184,7 +181,7 @@
> */
> public int getMaxConnectionsPerHost(FileSystemOptions opts)
> {
> - return getInteger(opts,
> HttpConnectionManagerParams.MAX_HOST_CONNECTIONS,
> DEFAULT_MAX_HOST_CONNECTIONS);
> + return HttpFileSystemOptions.getInstance
> (opts).getMaxConnectionsPerHost();
> }
>
> protected Class getConfigClass()
>
> Added: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/http/HttpFileSystemOptions.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/http/HttpFileSystemOptions.java?rev=814264&view=auto
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpFileSystemOptions.java (added)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/http/HttpFileSystemOptions.java Sun Sep 13
> 06:26:23 2009
> @@ -0,0 +1,183 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements. See the NOTICE file distributed
> with
> + * this work for additional information regarding copyright
> ownership.
> + * The ASF licenses this file to You under the Apache License,
> Version 2.0
> + * (the "License"); you may not use this file except in compliance
> with
> + * the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions
> and
> + * limitations under the License.
> + */
> +package org.apache.commons.vfs.provider.http;
> +
> +import org.apache.commons.vfs.FileSystemOptions;
> +import org.apache.commons.vfs.UserAuthenticator;
> +import org.apache.commons.vfs.DefaultFileSystemOptions;
> +import org.apache.commons.httpclient.Cookie;
> +import
> org.apache.commons.httpclient.params.HttpConnectionManagerParams;
> +
> +/**
> + * HTTP File System Options
> + * @author <a href="http://commons.apache.org/vfs/team-
> list.html">Commons VFS team</a>
> + */
> +public class HttpFileSystemOptions extends DefaultFileSystemOptions
> +{
> + private static final int DEFAULT_MAX_HOST_CONNECTIONS = 5;
> +
> + private static final int DEFAULT_MAX_CONNECTIONS = 50;
> +
> + public HttpFileSystemOptions()
> + {
> + this("http.");
> + }
> +
> + protected HttpFileSystemOptions(String scheme)
> + {
> + super(scheme);
> + }
> +
> + public static HttpFileSystemOptions getInstance
> (FileSystemOptions opts)
> + {
> + return FileSystemOptions.makeSpecific
> (HttpFileSystemOptions.class, opts);
> + }
> +
> + /**
> + * Set the charset used for url encoding<br>
> + *
> + * @param chaset the chaset
> + */
> + public void setUrlCharset(String chaset)
> + {
> + setParam("urlCharset", chaset);
> + }
> +
> + /**
> + * Set the charset used for url encoding<br>
> + *
> + * @return the chaset
> + */
> + public String getUrlCharset()
> + {
> + return getString("urlCharset");
> + }
> +
> + /**
> + * Set the proxy to use for http connection.<br>
> + * You have to set the ProxyPort too if you would like to have
> the proxy relly used.
> + *
> + * @param proxyHost the host
> + * @see #setProxyPort
> + */
> + public void setProxyHost(String proxyHost)
> + {
> + setParam("proxyHost", proxyHost);
> + }
> +
> + /**
> + * Set the proxy-port to use for http connection
> + * You have to set the ProxyHost too if you would like to have
> the proxy relly used.
> + *
> + * @param proxyPort the port
> + * @see #setProxyHost
> + */
> + public void setProxyPort(int proxyPort)
> + {
> + setParam("proxyPort", new Integer(proxyPort));
> + }
> +
> + /**
> + * Get the proxy to use for http connection
> + * You have to set the ProxyPort too if you would like to have
> the proxy relly used.
> + *
> + * @return proxyHost
> + * @see #setProxyPort
> + */
> + public String getProxyHost()
> + {
> + return getString("proxyHost");
> + }
> +
> + /**
> + * Get the proxy-port to use for http the connection
> + * You have to set the ProxyHost too if you would like to have
> the proxy relly used.
> + *
> + * @return proxyPort: the port number or 0 if it is not set
> + * @see #setProxyHost
> + */
> + public int getProxyPort()
> + {
> + return getInteger("proxyPort", 0);
> + }
> +
> + /**
> + * Set the proxy authenticator where the system should get the
> credentials from
> + */
> + public void setProxyAuthenticator(UserAuthenticator
> authenticator)
> + {
> + setParam("proxyAuthenticator", authenticator);
> + }
> +
> + /**
> + * Get the proxy authenticator where the system should get the
> credentials from
> + */
> + public UserAuthenticator getProxyAuthenticator()
> + {
> + return (UserAuthenticator) getParam("proxyAuthenticator");
> + }
> +
> + /**
> + * The cookies to add to the reqest
> + */
> + public void setCookies(Cookie[] cookies)
> + {
> + setParam("cookies", cookies);
> + }
> +
> + /**
> + * The cookies to add to the reqest
> + */
> + public Cookie[] getCookies()
> + {
> + return (Cookie[]) getParam("cookies");
> + }
> +
> + /**
> + * The maximum number of connections allowed
> + */
> + public void setMaxTotalConnections(int maxTotalConnections)
> + {
> + setParam(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS,
> new Integer(maxTotalConnections));
> + }
> +
> + /**
> + * Retrieve the maximum number of connections allowed.
> + * @return The maximum number of connections allowed.
> + */
> + public int getMaxTotalConnections()
> + {
> + return getInteger
> (HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS,
> DEFAULT_MAX_CONNECTIONS);
> + }
> +
> + /**
> + * The maximum number of connections allowed to any host
> + */
> + public void setMaxConnectionsPerHost(int maxHostConnections)
> + {
> + setParam(HttpConnectionManagerParams.MAX_HOST_CONNECTIONS,
> new Integer(maxHostConnections));
> + }
> +
> + /**
> + * Retrieve the maximum number of connections allowed per host.
> + * @return The maximum number of connections allowed per host.
> + */
> + public int getMaxConnectionsPerHost()
> + {
> + return getInteger
> (HttpConnectionManagerParams.MAX_HOST_CONNECTIONS,
> DEFAULT_MAX_HOST_CONNECTIONS);
> + }
> +}
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/ram/RamFileObject.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileObject.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileObject.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileObject.java Sun Sep 13 06:26:23 2009
> @@ -254,8 +254,7 @@
> {
> if (fs.getFileSystemOptions() != null)
> {
> - int maxSize = RamFileSystemConfigBuilder.getInstance
> ().getMaxSize(
> - fs.getFileSystemOptions());
> + int maxSize = fs.getFileSystemOptions().getMaxSize();
> if (fs.size() + newSize - this.size() > maxSize)
> {
> throw new IOException("FileSystem capacity (" +
> maxSize
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/ram/RamFileProvider.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileProvider.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileProvider.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileProvider.java Sun Sep 13 06:26:23 2009
> @@ -27,6 +27,7 @@
> import org.apache.commons.vfs.FileSystemOptions;
> import
> org.apache.commons.vfs.provider.AbstractOriginatingFileProvider;
> import org.apache.commons.vfs.provider.FileProvider;
> +import org.apache.commons.vfs.provider.ftp.FtpFileSystemOptions;
>
> /**
> * RAM File Provider
> @@ -46,12 +47,14 @@
> Capability.APPEND_CONTENT,
> Capability.RANDOM_ACCESS_READ,
> Capability.RANDOM_ACCESS_WRITE }));
>
> + private static final Class<? extends FileSystemOptions>
> FSOPTIONS_CLASS = RamFileSystemOptions.class;
> +
> /**
> * Constructor
> */
> public RamFileProvider()
> {
> - super();
> + super(FSOPTIONS_CLASS);
> }
>
> /*
> @@ -63,7 +66,7 @@
> protected FileSystem doCreateFileSystem(FileName name,
> FileSystemOptions fileSystemOptions) throws
> FileSystemException
> {
> - return new RamFileSystem(name, fileSystemOptions);
> + return new RamFileSystem(name, fileSystemOptions,
> FSOPTIONS_CLASS);
> }
>
> /*
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/ram/RamFileSystem.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileSystem.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileSystem.java Sun Sep 13 06:26:23 2009
> @@ -49,10 +49,10 @@
> * @param rootName
> * @param fileSystemOptions
> */
> - protected RamFileSystem(FileName rootName,
> - FileSystemOptions fileSystemOptions)
> + protected RamFileSystem(FileName rootName, FileSystemOptions
> fileSystemOptions,
> + final Class<? extends
> FileSystemOptions> optionsClass)
> {
> - super(rootName, null, fileSystemOptions);
> + super(rootName, null, fileSystemOptions, optionsClass);
> this.cache = Collections.synchronizedMap(new HashMap());
> // create root
> RamFileData rootData = new RamFileData(rootName) ;
> @@ -82,6 +82,11 @@
> caps.addAll(RamFileProvider.capabilities);
> }
>
> + public RamFileSystemOptions getFileSystemOptions()
> + {
> + return super.getOptions();
> + }
> +
> /**
> * @param name
> * @return children
>
> Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/
> apache/commons/vfs/provider/ram/RamFileSystemConfigBuilder.java
> URL: http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystemConfigBuilder.java?rev=814264&r1=814263&r2=814264&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileSystemConfigBuilder.java (original)
> +++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/
> commons/vfs/provider/ram/RamFileSystemConfigBuilder.java Sun Sep 13
> 06:26:23 2009
> @@ -21,13 +21,12 @@
>
> /**
> * Config Builder for the RAM filesystem.
> + * @author <a href="http://commons.apache.org/vfs/team-
> list.html">Commons VFS team</a>
> + * @deprecated Use RamFileSystemOptions instead.
> */
> public class RamFileSystemConfigBuilder extends
> FileSystemConfigBuilder
> {
>
> - /** max size key */
> - private static final String MAX_SIZE_KEY = "maxsize";
> -
> /** config builder singleton */
> private static RamFileSystemConfigBuilder singleton = new
> RamFileSystemConfigBuilder();
>
> @@ -56,24 +55,24 @@
> }
>
> /**
> - * @param opts
> - * @return
> + * @param opts The FileSystemOptions.
> + * @return The Maximum size of the filesystem.
> * @see #setMaxSize
> */
> public int getMaxSize(FileSystemOptions opts)
> {
> - return getInteger(opts, MAX_SIZE_KEY, Integer.MAX_VALUE);
> + return RamFileSystemOptions.getInstance(opts).getMaxSize();
> }
>
> /**
> * sets the maximum size of the file system
> *
> - * @param opts
> - * @param sizeInBytes
> + * @param opts The FileSystemOptions.
> + * @param sizeInBytes The maximum size in bytes of the file
> system.
> */
> public void setMaxSize(FileSystemOptions opts, int sizeInBytes)
> {
> - setParam(opts, MAX_SIZE_KEY, new Integer(sizeInBytes));
> + RamFileSystemOptions.getInstance(opts).setMaxSize
> (sizeInBytes);
> }
>
> }
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org