[jboss-cvs] JBossAS SVN: r94266 - in projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual: plugins/context and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 2 08:02:03 EDT 2009
Author: alesj
Date: 2009-10-02 08:02:03 -0400 (Fri, 02 Oct 2009)
New Revision: 94266
Added:
projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/TempStore.java
Modified:
projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/VFS.java
projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/AbstractVFSContext.java
projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java
projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/copy/AbstractCopyMechanism.java
projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/VFSContext.java
Log:
[JBVFS-125]; initial TempStore commit.
Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/VFS.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/VFS.java 2009-10-02 11:04:18 UTC (rev 94265)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/VFS.java 2009-10-02 12:02:03 UTC (rev 94266)
@@ -33,6 +33,7 @@
import org.jboss.virtual.spi.VFSContextFactory;
import org.jboss.virtual.spi.VFSContextFactoryLocator;
import org.jboss.virtual.spi.VirtualFileHandler;
+import org.jboss.virtual.spi.TempStore;
import org.jboss.virtual.spi.registry.VFSRegistry;
/**
@@ -118,6 +119,16 @@
}
/**
+ * Set temp store
+ *
+ * @param store the temp store
+ */
+ public void setTempStore(TempStore store)
+ {
+ context.setTempStore(store);
+ }
+
+ /**
* Cleanup any resources tied to this file.
* e.g. vfs cache
*
@@ -145,6 +156,12 @@
{
VFSRegistry registry = VFSRegistry.getInstance();
registry.removeContext(context);
+
+ TempStore store = context.getTempStore();
+ if (store != null)
+ {
+ store.clear();
+ }
}
}
catch (Exception e)
Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/AbstractVFSContext.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/AbstractVFSContext.java 2009-10-02 11:04:18 UTC (rev 94265)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/AbstractVFSContext.java 2009-10-02 12:02:03 UTC (rev 94266)
@@ -49,6 +49,7 @@
import org.jboss.virtual.spi.VirtualFileHandler;
import org.jboss.virtual.spi.VirtualFileHandlerVisitor;
import org.jboss.virtual.spi.VFSContextConstraints;
+import org.jboss.virtual.spi.TempStore;
/**
* AbstractVFSContext.
@@ -549,6 +550,16 @@
setOption(ExceptionHandler.class.getName(), exceptionHandler);
}
+ public void setTempStore(TempStore store)
+ {
+ setOption(TempStore.class.getName(), store);
+ }
+
+ public TempStore getTempStore()
+ {
+ return getOption(TempStore.class);
+ }
+
@Override
public String toString()
{
Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java 2009-10-02 11:04:18 UTC (rev 94265)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipEntryContext.java 2009-10-02 12:02:03 UTC (rev 94266)
@@ -64,6 +64,7 @@
import org.jboss.virtual.spi.ExceptionHandler;
import org.jboss.virtual.spi.Options;
import org.jboss.virtual.spi.TempInfo;
+import org.jboss.virtual.spi.TempStore;
import org.jboss.virtual.spi.VFSContext;
import org.jboss.virtual.spi.VFSContextConstraints;
import org.jboss.virtual.spi.VirtualFileHandler;
@@ -546,7 +547,16 @@
if (createNewTempInfo)
{
// extract it to temp dir
- dest = new File(getTempDir() + "/" + getTempFileName(entryName));
+ String tempName = getTempFileName(entryName);
+ TempStore store = (context != null) ? context.getTempStore() : null;
+ if (store != null)
+ {
+ File tempDir = store.createTempFolder(zipSource.getName(), ent.getName());
+ if (tempDir != null)
+ dest = new File(tempDir, tempName);
+ }
+ if (dest == null)
+ dest = new File(getTempDir() + "/" + tempName);
dest.deleteOnExit();
if (trace)
Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/copy/AbstractCopyMechanism.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/copy/AbstractCopyMechanism.java 2009-10-02 11:04:18 UTC (rev 94265)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/copy/AbstractCopyMechanism.java 2009-10-02 12:02:03 UTC (rev 94266)
@@ -40,6 +40,7 @@
import org.jboss.virtual.plugins.context.file.FileSystemContext;
import org.jboss.virtual.plugins.context.temp.BasicTempInfo;
import org.jboss.virtual.spi.Options;
+import org.jboss.virtual.spi.TempStore;
import org.jboss.virtual.spi.VFSContext;
import org.jboss.virtual.spi.VirtualFileHandler;
@@ -129,13 +130,22 @@
return file;
}
+ // old vfs context
+ VFSContext oldVFSContext = handler.getVFSContext();
+
//create guid dir
- File guidDir = createTempDirectory(getTempDirectory(), GUID.asString());
+ File guidDir = null;
+ TempStore store = oldVFSContext.getTempStore();
+ if (store != null)
+ guidDir = store.createTempFolder(file);
+
+ if (guidDir == null)
+ guidDir = createTempDirectory(getTempDirectory(), GUID.asString());
+
// unpack handler
File copy = copy(guidDir, handler);
String path = handler.getPathName();
- VFSContext oldVFSContext = handler.getVFSContext();
// create new handler
FileSystemContext fileSystemContext = new TempContext(copy, oldVFSContext, path);
Copied: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/TempStore.java (from rev 93905, projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/TempInfo.java)
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/TempStore.java (rev 0)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/TempStore.java 2009-10-02 12:02:03 UTC (rev 94266)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.virtual.spi;
+
+import java.io.File;
+
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * The temp store
+ *
+ * @author ales.justin at jboss.org
+ */
+public interface TempStore
+{
+ /**
+ * Create temp folder into which contents of this file will be temp copied.
+ * This folder should be unique as the file name will remain the same.
+ *
+ * This method can return null, which means we fall back to default temp dir mechanism.
+ *
+ * @param file the file to copy
+ * @return new temp folder or null if we fall back to default temp dir
+ */
+ File createTempFolder(VirtualFile file);
+
+ /**
+ * Create temp folder for nested zip file.
+ * The folder doesn't have to be unique as the nested file's name will be joined with GUID.
+ *
+ * This method can return null, which means we fall back to default temp dir mechanism.
+ *
+ * @param outerName outer file's name
+ * @param innerName nested file's name
+ * @return temp folder or null if we fall back to default temp dir
+ */
+ File createTempFolder(String outerName, String innerName);
+
+ /**
+ * Clear newly created temp folders.
+ * This will be invoked once VFSContext is no longer used.
+ *
+ * But it's probably better to mark newly created temp dir
+ * to be deleted on JVM exit (File::deleteOnExit).
+ */
+ void clear();
+}
\ No newline at end of file
Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/VFSContext.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/VFSContext.java 2009-10-02 11:04:18 UTC (rev 94265)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/spi/VFSContext.java 2009-10-02 12:02:03 UTC (rev 94266)
@@ -175,4 +175,18 @@
* @param path the path to cleanup
*/
void cleanupTempInfo(String path);
+
+ /**
+ * Set temp store.
+ *
+ * @param store the store
+ */
+ void setTempStore(TempStore store);
+
+ /**
+ * Get temp store.
+ *
+ * @return the temp store
+ */
+ TempStore getTempStore();
}
More information about the jboss-cvs-commits
mailing list