imario 2004/05/17 13:13:20
Modified: vfs/src/java/org/apache/commons/vfs/cache
DefaultFilesCache.java NullFilesCache.java
SoftRefFilesCache.java
vfs/src/java/org/apache/commons/vfs/provider
AbstractFileSystem.java AbstractVfsComponent.java
vfs/src/java/org/apache/commons/vfs/impl
DefaultFileReplicator.java
DefaultFileSystemManager.java
StandardFileSystemManager.java
vfs/src/java/org/apache/commons/vfs FilesCache.java
GlobalConfiguration.java VFS.java
vfs/src/java/org/apache/commons/vfs/provider/ftp
FtpFileSystem.java
vfs/src/java/org/apache/commons/vfs/provider/zip
ZipFileSystem.java
Added: vfs/src/java/org/apache/commons/vfs/cache
AbstractFilesCache.java
vfs/src/java/org/apache/commons/vfs VfsLog.java
Removed: vfs/src/java/org/apache/commons/vfs/cache
FilesCacheConfigBuilder.java
Log:
Refactored to make them VfsComponents to get the context&logger.
Changed logging to correctly use commons-logging.
The user could override this by set its own logger using setLogger(). (have had to
keep this to be able to handle AntLogger)
Revision Changes Path
1.5 +5 -4
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/cache/DefaultFilesCache.java
Index: DefaultFilesCache.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/cache/DefaultFilesCache.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultFilesCache.java 14 May 2004 18:35:37 -0000 1.4
+++ DefaultFilesCache.java 17 May 2004 20:13:19 -0000 1.5
@@ -18,7 +18,6 @@
import org.apache.commons.vfs.FileName;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystem;
-import org.apache.commons.vfs.FilesCache;
import java.util.HashMap;
import java.util.Map;
@@ -31,7 +30,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Mario Ivanovits</a>
* @version $Revision$ $Date$
*/
-public class DefaultFilesCache implements FilesCache
+public class DefaultFilesCache extends AbstractFilesCache
{
private final Map filesystemCache = new HashMap(10);
@@ -65,8 +64,10 @@
return files;
}
- public void clear()
+ public void close()
{
+ super.close();
+
filesystemCache.clear();
}
1.5 +4 -4
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/cache/NullFilesCache.java
Index: NullFilesCache.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/cache/NullFilesCache.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- NullFilesCache.java 14 May 2004 18:35:37 -0000 1.4
+++ NullFilesCache.java 17 May 2004 20:13:19 -0000 1.5
@@ -18,7 +18,6 @@
import org.apache.commons.vfs.FileName;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystem;
-import org.apache.commons.vfs.FilesCache;
/**
* <p/>
@@ -33,7 +32,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Mario Ivanovits</a>
* @version $Revision$ $Date$
*/
-public class NullFilesCache implements FilesCache
+public class NullFilesCache extends AbstractFilesCache
{
public void putFile(final FileObject file)
{
@@ -48,8 +47,9 @@
{
}
- public void clear()
+ public void close()
{
+ super.close();
}
public void removeFile(FileSystem filesystem, FileName name)
1.5 +7 -5
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/cache/SoftRefFilesCache.java
Index: SoftRefFilesCache.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/cache/SoftRefFilesCache.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SoftRefFilesCache.java 14 May 2004 18:35:37 -0000 1.4
+++ SoftRefFilesCache.java 17 May 2004 20:13:19 -0000 1.5
@@ -20,7 +20,7 @@
import org.apache.commons.vfs.FileName;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystem;
-import org.apache.commons.vfs.FilesCache;
+import org.apache.commons.vfs.VfsLog;
import org.apache.commons.vfs.util.Messages;
import java.lang.ref.Reference;
@@ -39,7 +39,7 @@
* @version $Revision$ $Date$
* @see SoftReference
*/
-public class SoftRefFilesCache implements FilesCache
+public class SoftRefFilesCache extends AbstractFilesCache
{
/**
* The logger to use.
@@ -86,7 +86,7 @@
}
catch (InterruptedException e)
{
-
log.info(Messages.getString("vfs.impl/SoftRefReleaseThread-interrupt.info"));
+ VfsLog.warn(getLogger(), log,
Messages.getString("vfs.impl/SoftRefReleaseThread-interrupt.info"));
break loop;
}
}
@@ -178,8 +178,10 @@
}
}
- public void clear()
+ public void close()
{
+ super.close();
+
synchronized (this)
{
endThread();
1.1
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/cache/AbstractFilesCache.java
Index: AbstractFilesCache.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.cache;
import org.apache.commons.vfs.FilesCache;
import org.apache.commons.vfs.provider.AbstractVfsComponent;
/**
* Description
*
* @author <a href="mailto:[EMAIL PROTECTED]">Mario Ivanovits</a>
* @version $Revision: 1.1 $ $Date: 2004/05/17 20:13:19 $
*/
public abstract class AbstractFilesCache extends AbstractVfsComponent implements
FilesCache
{
}
1.26 +7 -1
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
Index: AbstractFileSystem.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- AbstractFileSystem.java 10 May 2004 20:09:42 -0000 1.25
+++ AbstractFileSystem.java 17 May 2004 20:13:20 -0000 1.26
@@ -15,6 +15,8 @@
*/
package org.apache.commons.vfs.provider;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.commons.vfs.Capability;
import org.apache.commons.vfs.FileChangeEvent;
import org.apache.commons.vfs.FileListener;
@@ -26,6 +28,7 @@
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.util.Messages;
import java.io.File;
@@ -45,6 +48,8 @@
extends AbstractVfsComponent
implements FileSystem
{
+ private final static Log log = LogFactory.getLog(AbstractFileSystem.class);
+
private final FileName rootName;
private FileObject parentLayer;
private FileObject root;
@@ -372,7 +377,8 @@
catch (final Exception e)
{
final String message =
Messages.getString("vfs.provider/notify-listener.warn", file);
- getLogger().warn(message, e);
+ // getLogger().warn(message, e);
+ VfsLog.warn(getLogger(), log, message, e);
}
}
}
1.8 +1 -1
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractVfsComponent.java
Index: AbstractVfsComponent.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractVfsComponent.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
1.18 +6 -1
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java
Index: DefaultFileReplicator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- DefaultFileReplicator.java 17 May 2004 17:53:08 -0000 1.17
+++ DefaultFileReplicator.java 17 May 2004 20:13:20 -0000 1.18
@@ -15,10 +15,13 @@
*/
package org.apache.commons.vfs.impl;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSelector;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.Selectors;
+import org.apache.commons.vfs.VfsLog;
import org.apache.commons.vfs.provider.AbstractVfsComponent;
import org.apache.commons.vfs.provider.FileReplicator;
import org.apache.commons.vfs.provider.TemporaryFileStore;
@@ -38,6 +41,7 @@
extends AbstractVfsComponent
implements FileReplicator, TemporaryFileStore
{
+ private final static Log log = LogFactory.getLog(DefaultFileReplicator.class);
private final ArrayList copies = new ArrayList();
private File tempDir;
@@ -87,7 +91,8 @@
catch (final FileSystemException e)
{
final String message =
Messages.getString("vfs.impl/delete-temp.warn", file.getName());
- getLogger().warn(message, e);
+ // getLogger().warn(message, e);
+ VfsLog.warn(getLogger(), log, message, e);
}
}
1.29 +5 -13
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.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- DefaultFileSystemManager.java 17 May 2004 17:56:57 -0000 1.28
+++ DefaultFileSystemManager.java 17 May 2004 20:13:20 -0000 1.29
@@ -16,7 +16,6 @@
package org.apache.commons.vfs.impl;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileSystemManager;
@@ -81,7 +80,7 @@
/**
* The logger to use.
*/
- private Log log = LogFactory.getLog(DefaultFileSystemManager.class);
+ private Log log;
/**
* The context to pass to providers.
@@ -99,12 +98,8 @@
/**
* Returns the logger used by this manager.
*/
- protected Log getLog()
+ protected Log getLogger()
{
- if (log == null)
- {
- log = LogFactory.getLog(this.getClass());
- }
return log;
}
@@ -214,6 +209,7 @@
}
this.globalConfiguration = globalConfiguration;
+ setupComponent(this.globalConfiguration);
}
@@ -274,7 +270,7 @@
if (component instanceof VfsComponent)
{
final VfsComponent vfsComponent = (VfsComponent) component;
- vfsComponent.setLogger(getLog());
+ vfsComponent.setLogger(getLogger());
vfsComponent.setContext(context);
vfsComponent.init();
}
@@ -335,7 +331,7 @@
{
if (globalConfiguration == null)
{
- globalConfiguration = new GlobalConfiguration();
+ setGlobalConfiguration(new GlobalConfiguration());
}
globalConfiguration.init();
@@ -369,10 +365,6 @@
components.clear();
providers.clear();
- if (this.globalConfiguration.getFilesCache() != null)
- {
- this.globalConfiguration.getFilesCache().clear();
- }
localFileProvider = null;
defaultProvider = null;
fileReplicator = null;
1.20 +7 -2
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/StandardFileSystemManager.java
Index: StandardFileSystemManager.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/StandardFileSystemManager.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- StandardFileSystemManager.java 17 May 2004 17:56:35 -0000 1.19
+++ StandardFileSystemManager.java 17 May 2004 20:13:20 -0000 1.20
@@ -15,7 +15,10 @@
*/
package org.apache.commons.vfs.impl;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.VfsLog;
import org.apache.commons.vfs.provider.FileProvider;
import org.apache.commons.vfs.util.Messages;
import org.w3c.dom.Element;
@@ -39,6 +42,8 @@
public class StandardFileSystemManager
extends DefaultFileSystemManager
{
+ private Log log = LogFactory.getLog(StandardFileSystemManager.class);
+
private static final String CONFIG_RESOURCE = "providers.xml";
private String configUri;
@@ -191,7 +196,7 @@
{
final String msg =
Messages.getString("vfs.impl/skipping-provider.debug",
new String[]{classname, requiredClass});
- getLog().debug(msg);
+ VfsLog.debug(getLogger(), log, msg);
return;
}
}
1.5 +2 -2
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FilesCache.java
Index: FilesCache.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FilesCache.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FilesCache.java 14 May 2004 18:35:37 -0000 1.4
+++ FilesCache.java 17 May 2004 20:13:20 -0000 1.5
@@ -47,7 +47,7 @@
/**
* purge the whole cache
*/
- public void clear();
+ public void close();
/**
* removes a file from cache
1.2 +30 -3
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/GlobalConfiguration.java
Index: GlobalConfiguration.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/GlobalConfiguration.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GlobalConfiguration.java 17 May 2004 17:56:57 -0000 1.1
+++ GlobalConfiguration.java 17 May 2004 20:13:20 -0000 1.2
@@ -16,6 +16,8 @@
package org.apache.commons.vfs;
import org.apache.commons.vfs.cache.DefaultFilesCache;
+import org.apache.commons.vfs.provider.AbstractVfsComponent;
+import org.apache.commons.vfs.provider.VfsComponent;
/**
* Global parameters to configure the VFS system.
@@ -23,7 +25,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Mario Ivanovits</a>
* @version $Revision$ $Date$
*/
-public final class GlobalConfiguration
+public final class GlobalConfiguration extends AbstractVfsComponent
{
private boolean inUse = false;
@@ -50,9 +52,34 @@
* init
* marks this configuration as "in use"
*/
- public void init()
+ public void init() throws FileSystemException
{
+ super.init();
+
+ setupComponent(this.filesCache);
+
inUse = true;
+ }
+
+ private void setupComponent(final Object component) throws FileSystemException
+ {
+ if (component instanceof VfsComponent)
+ {
+ final VfsComponent vfsComponent = (VfsComponent) component;
+ vfsComponent.setLogger(getLogger());
+ vfsComponent.setContext(getContext());
+ vfsComponent.init();
+ }
+ }
+
+ /**
+ * close this component
+ */
+ public void close()
+ {
+ super.close();
+
+ filesCache.close();
}
/**
1.8 +3 -4
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/VFS.java
Index: VFS.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/VFS.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- VFS.java 10 May 2004 20:09:46 -0000 1.7
+++ VFS.java 17 May 2004 20:13:20 -0000 1.8
@@ -15,9 +15,6 @@
*/
package org.apache.commons.vfs;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -61,6 +58,7 @@
final Class mgrClass = Class.forName(managerClassName);
final FileSystemManager mgr = (FileSystemManager)
mgrClass.newInstance();
+ /*
try
{
// Set the logger
@@ -72,6 +70,7 @@
{
// Ignore; don't set the logger
}
+ */
try
{
1.1
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/VfsLog.java
Index: VfsLog.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.logging.Log;
/**
* This class is to keep the old logging behaviour (for ant-task) and to be able to
* correctly use commons-logging.<br>
* I hope i could remove it sometimes.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Mario Ivanovits</a>
* @version $Revision: 1.1 $ $Date: 2004/05/17 20:13:20 $
*/
public class VfsLog
{
/**
* warning
*/
public static void warn(Log vfslog, Log commonslog, String message, Throwable t)
{
if (vfslog != null)
{
vfslog.warn(message, t);
}
else if (commonslog != null)
{
commonslog.warn(message, t);
}
}
/**
* warning
*/
public static void warn(Log vfslog, Log commonslog, String message)
{
if (vfslog != null)
{
vfslog.warn(message);
}
else if (commonslog != null)
{
commonslog.warn(message);
}
}
/**
* debug
*/
public static void debug(Log vfslog, Log commonslog, String message)
{
if (vfslog != null)
{
vfslog.debug(message);
}
else if (commonslog != null)
{
commonslog.debug(message);
}
}
}
1.27 +7 -1
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java
Index: FtpFileSystem.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystem.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- FtpFileSystem.java 10 May 2004 20:09:49 -0000 1.26
+++ FtpFileSystem.java 17 May 2004 20:13:20 -0000 1.27
@@ -15,6 +15,8 @@
*/
package org.apache.commons.vfs.provider.ftp;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
@@ -23,6 +25,7 @@
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.VfsLog;
import org.apache.commons.vfs.provider.AbstractFileSystem;
import org.apache.commons.vfs.provider.GenericFileName;
@@ -38,6 +41,8 @@
final class FtpFileSystem
extends AbstractFileSystem
{
+ private final static Log log = LogFactory.getLog(FtpFileSystem.class);
+
private final String hostname;
private final int port;
private final String username;
@@ -115,7 +120,8 @@
}
catch (final IOException e)
{
- getLogger().warn("vfs.provider.ftp/close-connection.error", e);
+ // getLogger().warn("vfs.provider.ftp/close-connection.error", e);
+ VfsLog.warn(getLogger(), log,
"vfs.provider.ftp/close-connection.error", e);
}
}
1.29 +7 -1
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java
Index: ZipFileSystem.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- ZipFileSystem.java 10 May 2004 20:09:54 -0000 1.28
+++ ZipFileSystem.java 17 May 2004 20:13:20 -0000 1.29
@@ -15,6 +15,8 @@
*/
package org.apache.commons.vfs.provider.zip;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.commons.vfs.Capability;
import org.apache.commons.vfs.FileName;
import org.apache.commons.vfs.FileObject;
@@ -22,6 +24,7 @@
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.Selectors;
+import org.apache.commons.vfs.VfsLog;
import org.apache.commons.vfs.provider.AbstractFileSystem;
import java.io.File;
@@ -41,6 +44,8 @@
extends AbstractFileSystem
implements FileSystem
{
+ private final static Log log = LogFactory.getLog(ZipFileSystem.class);
+
private final File file;
protected final ZipFile zipFile;
@@ -140,7 +145,8 @@
}
catch (final IOException e)
{
- getLogger().warn("vfs.provider.zip/close-zip-file.error :" + file, e);
+ // getLogger().warn("vfs.provider.zip/close-zip-file.error :" + file,
e);
+ VfsLog.warn(getLogger(), log, "vfs.provider.zip/close-zip-file.error :"
+ file, e);
}
super.close();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]