imario 2004/05/17 10:56:57
Modified: vfs/src/test/org/apache/commons/vfs/test
AbstractTestSuite.java
vfs/xdocs api.xml
vfs/src/java/org/apache/commons/vfs/impl
DefaultFileSystemManager.java providers.xml
vfs/src/java/org/apache/commons/vfs FileSystemManager.java
Resources.properties
Added: vfs/src/java/org/apache/commons/vfs/impl
DefaultProviderConfiguration.java
ProviderConfiguration.java
vfs/src/java/org/apache/commons/vfs GlobalConfiguration.java
Log:
Introduced GlobalConfiguration and moved configuration for FilesCache into it.
Removed configuration-option from providers.xml.
Revision Changes Path
1.2 +6 -5
jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/AbstractTestSuite.java
Index: AbstractTestSuite.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/AbstractTestSuite.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractTestSuite.java 10 May 2004 20:09:44 -0000 1.1
+++ AbstractTestSuite.java 17 May 2004 17:56:57 -0000 1.2
@@ -21,6 +21,7 @@
import org.apache.commons.AbstractVfsTestCase;
import org.apache.commons.vfs.FileName;
import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.GlobalConfiguration;
import org.apache.commons.vfs.impl.DefaultFileReplicator;
import org.apache.commons.vfs.impl.DefaultFileSystemManager;
import org.apache.commons.vfs.impl.PrivilegedFileReplicator;
@@ -127,11 +128,11 @@
checkTempDir("Temp dir not empty before test");
// Create the file system manager
- manager = new DefaultFileSystemManager();
-
- manager.setFilesCache(providerConfig.getFilesCache());
+ GlobalConfiguration config = new GlobalConfiguration();
+ config.setFilesCache(providerConfig.getFilesCache());
- // manager.setFilesCache(new LRUFilesCache());
+ manager = new DefaultFileSystemManager();
+ manager.setGlobalConfiguration(config);
final DefaultFileReplicator replicator = new DefaultFileReplicator(tempDir);
manager.setReplicator(new PrivilegedFileReplicator(replicator));
1.8 +0 -18 jakarta-commons-sandbox/vfs/xdocs/api.xml
Index: api.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/xdocs/api.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- api.xml 3 May 2004 19:48:47 -0000 1.7
+++ api.xml 17 May 2004 17:56:57 -0000 1.8
@@ -173,9 +173,6 @@
<li>An optional
<code><default-provider></code> element.
</li>
- <li>An optional
- <code><files-cache></code> element.
- </li>
<li>Zero or more
<code><extension-map></code> elements.
</li>
@@ -234,21 +231,6 @@
<code><default-provider></code> element defines
the default provider. It has the same format as the
<code><provider></code> element.
- </p>
-
- <p>
- <b>
- <code><files-cache></code>
- </b>
- </p>
- <p>
- The
- <code><files-cache></code> element defines
- the cache implementation to use. It must have a
- <code>class-name</code> attribute,
- which specifies the fully-qualified name of the cache
- class. The cache class must be public, and must have a
- public no-args constructor.
</p>
<p>
1.28 +23 -15
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java
Index: DefaultFileSystemManager.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- DefaultFileSystemManager.java 10 May 2004 20:09:46 -0000 1.27
+++ DefaultFileSystemManager.java 17 May 2004 17:56:57 -0000 1.28
@@ -22,7 +22,7 @@
import org.apache.commons.vfs.FileSystemManager;
import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.FilesCache;
-import org.apache.commons.vfs.cache.DefaultFilesCache;
+import org.apache.commons.vfs.GlobalConfiguration;
import org.apache.commons.vfs.provider.DefaultURLStreamHandler;
import org.apache.commons.vfs.provider.FileProvider;
import org.apache.commons.vfs.provider.FileReplicator;
@@ -94,7 +94,7 @@
private final VirtualFileProvider vfsProvider = new VirtualFileProvider();
private boolean init;
- private FilesCache filesCache;
+ private GlobalConfiguration globalConfiguration = null;
/**
* Returns the logger used by this manager.
@@ -203,18 +203,26 @@
/**
* Sets the filesCache implementation used to cache files.<br>
- * If you do not set the FilesCache, after [EMAIL PROTECTED] #init} the [EMAIL
PROTECTED] DefaultFilesCache} will automatically be set.
*
* @see org.apache.commons.vfs.FilesCache
*/
- public void setFilesCache(FilesCache cache) throws FileSystemException
+ public void setGlobalConfiguration(GlobalConfiguration globalConfiguration)
throws FileSystemException
{
- if (this.filesCache != null)
+ if (this.globalConfiguration != null)
{
- throw new FileSystemException("vfs.impl/cache-already-set.error");
+ throw new
FileSystemException("vfs.impl/configuration-already-set.error");
}
- this.filesCache = cache;
+ this.globalConfiguration = globalConfiguration;
+ }
+
+
+ /**
+ * returns the global configuration
+ */
+ public GlobalConfiguration getGlobalConfiguration()
+ {
+ return globalConfiguration;
}
/**
@@ -222,7 +230,7 @@
*/
public FilesCache getFilesCache()
{
- return this.filesCache;
+ return this.globalConfiguration.getFilesCache();
}
/**
@@ -325,13 +333,13 @@
*/
public void init() throws FileSystemException
{
- setupComponent(vfsProvider);
-
- if (getFilesCache() == null)
+ if (globalConfiguration == null)
{
- // set the cache to the DefaultFilesCache for backward compatibility
- setFilesCache(new DefaultFilesCache());
+ globalConfiguration = new GlobalConfiguration();
}
+ globalConfiguration.init();
+
+ setupComponent(vfsProvider);
init = true;
}
@@ -361,9 +369,9 @@
components.clear();
providers.clear();
- if (filesCache != null)
+ if (this.globalConfiguration.getFilesCache() != null)
{
- filesCache.clear();
+ this.globalConfiguration.getFilesCache().clear();
}
localFileProvider = null;
defaultProvider = null;
1.6 +0 -1
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/providers.xml
Index: providers.xml
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/providers.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- providers.xml 3 May 2004 19:48:47 -0000 1.5
+++ providers.xml 17 May 2004 17:56:57 -0000 1.6
@@ -1,6 +1,5 @@
<providers>
<default-provider
class-name="org.apache.commons.vfs.provider.url.UrlFileProvider"/>
- <files-cache class-name="org.apache.commons.vfs.cache.DefaultFilesCache"/>
<provider
class-name="org.apache.commons.vfs.provider.local.DefaultLocalFileProvider">
<scheme name="file"/>
</provider>
1.1
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/DefaultProviderConfiguration.java
Index: DefaultProviderConfiguration.java
===================================================================
/*
* Copyright 2002, 2003,2004 The Apache Software Foundation.
*
* Licensed 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.impl;
/**
* Same as [EMAIL PROTECTED] ProviderConfiguration} but for the default provider.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Mario Ivanovits</a>
* @version $Revision: 1.1 $ $Date: 2004/05/17 17:56:57 $
*/
public class DefaultProviderConfiguration extends ProviderConfiguration
{
public boolean isDefault()
{
return true;
}
}
1.1
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/ProviderConfiguration.java
Index: ProviderConfiguration.java
===================================================================
/*
* Copyright 2002, 2003,2004 The Apache Software Foundation.
*
* Licensed 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.impl;
import java.util.ArrayList;
import java.util.List;
/**
* This class describes the configuration for a provider.<br>
* Used by digester in StandardFileSystemManager
*
* @author <a href="mailto:[EMAIL PROTECTED]">Mario Ivanovits</a>
* @version $Revision: 1.1 $ $Date: 2004/05/17 17:56:57 $
*/
public class ProviderConfiguration
{
private String className;
private List schemes = new ArrayList(10);
private List dependenies = new ArrayList(10);
public ProviderConfiguration()
{
}
public String getClassName()
{
return className;
}
public void setClassName(String className)
{
this.className = className;
}
public void setScheme(String scheme)
{
schemes.add(scheme);
}
public List getSchemes()
{
return schemes;
}
public void setDependency(String dependency)
{
dependenies.add(dependency);
}
public List getDependencies()
{
return dependenies;
}
public boolean isDefault()
{
return false;
}
}
1.17 +5 -0
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FileSystemManager.java
Index: FileSystemManager.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FileSystemManager.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- FileSystemManager.java 10 May 2004 20:09:45 -0000 1.16
+++ FileSystemManager.java 17 May 2004 17:56:57 -0000 1.17
@@ -194,4 +194,9 @@
* Get the cache used to cache fileobjects.
*/
FilesCache getFilesCache();
+
+ /**
+ * Get the global configuration
+ */
+ GlobalConfiguration getGlobalConfiguration();
}
1.32 +2 -1
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/Resources.properties
Index: Resources.properties
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/Resources.properties,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- Resources.properties 15 May 2004 09:15:11 -0000 1.31
+++ Resources.properties 17 May 2004 17:56:57 -0000 1.32
@@ -89,7 +89,8 @@
vfs.impl/unknown-scheme.error=Unknown scheme "{0}" in URI "{1}".
vfs.impl/find-rel-file.error=Could not find file with URI "{0}" because it is a
relative path, and no base URI was provided.
vfs.impl/multiple-providers-for-scheme.error=Multiple providers registered for URL
scheme "{0}".
-vfs.impl/cache-already-set.error=FilesCache implementation already set.
+vfs.impl/configuration-already-set.error=FilesCache implementation already set.
+vfs.impl/configuration-already-in-use.error=The configuration is already attached
to an filesystemmanager. You cant change it anymore.
vfs.impl/unknown-provider.error=No file provider is registered with URI scheme
"{0}" to handle file "{1}".
vfs.impl/no-provider-for-file.error=Could not find a file provider that can handle
file "{0}".
vfs.impl/no-local-file-provider.error=Could not find a file provider which can
handle local files.
1.1
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/GlobalConfiguration.java
Index: GlobalConfiguration.java
===================================================================
/*
* Copyright 2002, 2003,2004 The Apache Software Foundation.
*
* Licensed 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;
import org.apache.commons.vfs.cache.DefaultFilesCache;
/**
* Global parameters to configure the VFS system.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Mario Ivanovits</a>
* @version $Revision: 1.1 $ $Date: 2004/05/17 17:56:57 $
*/
public final class GlobalConfiguration
{
private boolean inUse = false;
private FilesCache filesCache = new DefaultFilesCache();
public GlobalConfiguration()
{
}
/**
* checks to see if this configuration is already attached to an
filesystemmanager.
*
* @throws FileSystemException if is is already attached
*/
private void assertNotInUse() throws FileSystemException
{
if (inUse)
{
throw new
FileSystemException("vfs.impl/configuration-already-in-use.error");
}
}
/**
* init
* marks this configuration as "in use"
*/
public void init()
{
inUse = true;
}
/**
* Sets the filesCache implementation used to cache files.
*
* @param filesCache
* @throws FileSystemException if this configuration is already attached to an
filesystemmanager
*/
public void setFilesCache(FilesCache filesCache) throws FileSystemException
{
assertNotInUse();
this.filesCache = filesCache;
}
/**
* Returns the filesCache implementation.<br>
* Default: [EMAIL PROTECTED] DefaultFilesCache}
*/
public FilesCache getFilesCache()
{
return filesCache;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]