[jboss-cvs] JBossAS SVN: r84092 - in projects/vfs/trunk/src/main/java/org/jboss/virtual: plugins/context/temp and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 11 09:33:42 EST 2009
Author: alesj
Date: 2009-02-11 09:33:42 -0500 (Wed, 11 Feb 2009)
New Revision: 84092
Modified:
projects/vfs/trunk/src/main/java/org/jboss/virtual/VirtualFile.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/temp/BasicTempInfo.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry/DefaultVFSRegistry.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/TempInfo.java
Log:
Remove cleanedup check.
Check if temp is still valid.
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/VirtualFile.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/VirtualFile.java 2009-02-11 12:47:49 UTC (rev 84091)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/VirtualFile.java 2009-02-11 14:33:42 UTC (rev 84092)
@@ -54,9 +54,6 @@
/** The virtual file handler */
private final VirtualFileHandler handler;
- /** Whether we are cleaned */
- private final AtomicBoolean cleaned = new AtomicBoolean(false);
-
/** Whether we are closed */
private final AtomicBoolean closed = new AtomicBoolean(false);
@@ -85,20 +82,6 @@
*/
VirtualFileHandler getHandler()
{
- return getHandler(true);
- }
-
- /**
- * Get the virtual handler.
- *
- * @param checkCleaned should we check cleaned
- * @return the handler
- * @throws IllegalStateException if the file is closed or cleaned
- */
- private VirtualFileHandler getHandler(boolean checkCleaned)
- {
- if (checkCleaned && cleaned.get())
- throw new IllegalStateException("The virtual file is cleaned");
if (closed.get())
throw new IllegalStateException("The virtual file is closed");
@@ -113,7 +96,7 @@
*/
public String getName()
{
- return getHandler(false).getName();
+ return getHandler().getName();
}
/**
@@ -124,7 +107,7 @@
*/
public String getPathName()
{
- return getHandler(false).getPathName();
+ return getHandler().getPathName();
}
/**
@@ -137,7 +120,7 @@
*/
public URL toURL() throws MalformedURLException, URISyntaxException
{
- return getHandler(false).toVfsUrl();
+ return getHandler().toVfsUrl();
}
/**
@@ -220,7 +203,7 @@
*/
public boolean isArchive() throws IOException
{
- return getHandler(false).isArchive();
+ return getHandler().isArchive();
}
/**
@@ -299,24 +282,14 @@
*/
public void cleanup()
{
- if (cleaned.get() == false)
+ try
{
- try
- {
- try
- {
- getHandler().cleanup();
- }
- finally
- {
- VFS.cleanup(this);
- }
- }
- finally
- {
- cleaned.set(true);
- }
+ getHandler().cleanup();
}
+ finally
+ {
+ VFS.cleanup(this);
+ }
}
/**
@@ -340,7 +313,7 @@
public boolean delete() throws IOException
{
// gracePeriod of 2 seconds
- return getHandler(false).delete(2000);
+ return getHandler().delete(2000);
}
/**
@@ -352,7 +325,7 @@
*/
public boolean delete(int gracePeriod) throws IOException
{
- return getHandler(false).delete(gracePeriod);
+ return getHandler().delete(gracePeriod);
}
/**
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/temp/BasicTempInfo.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/temp/BasicTempInfo.java 2009-02-11 12:47:49 UTC (rev 84091)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/temp/BasicTempInfo.java 2009-02-11 14:33:42 UTC (rev 84092)
@@ -22,6 +22,7 @@
package org.jboss.virtual.plugins.context.temp;
import java.io.File;
+import java.io.IOException;
import org.jboss.util.file.Files;
import org.jboss.virtual.spi.TempInfo;
@@ -74,6 +75,18 @@
return handler;
}
+ public boolean isValid()
+ {
+ try
+ {
+ return handler != null && handler.exists() && file != null && file.exists();
+ }
+ catch (IOException e)
+ {
+ return false;
+ }
+ }
+
@Override
public String toString()
{
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry/DefaultVFSRegistry.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry/DefaultVFSRegistry.java 2009-02-11 12:47:49 UTC (rev 84091)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/registry/DefaultVFSRegistry.java 2009-02-11 14:33:42 UTC (rev 84092)
@@ -75,7 +75,7 @@
for (TempInfo ti : context.getTempInfos())
{
String path = ti.getPath();
- if (relativePath.startsWith(path) && ti.getHandler() != null)
+ if (relativePath.startsWith(path) && ti.isValid())
{
String subpath = relativePath.substring(path.length());
VirtualFileHandler child = findHandler(ti.getHandler(), subpath);
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/TempInfo.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/TempInfo.java 2009-02-11 12:47:49 UTC (rev 84091)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/TempInfo.java 2009-02-11 14:33:42 UTC (rev 84092)
@@ -55,4 +55,11 @@
* @return the temp handler
*/
VirtualFileHandler getHandler();
+
+ /**
+ * Is the temp info still valid.
+ *
+ * @return true if still valid, false otherwise
+ */
+ boolean isValid();
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list