geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r706578 - in /geronimo/gshell/trunk: gshell-application/src/main/java/org/apache/geronimo/gshell/application/ gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ gshell-wisdom/gshell-wisdom-cor...
Date Tue, 21 Oct 2008 11:23:11 GMT
Author: jdillon
Date: Tue Oct 21 04:23:11 2008
New Revision: 706578

URL: http://svn.apache.org/viewvc?rev=706578&view=rev
Log:
Add ClassPath.isValid() to validate the loaded cache still references valid files

Modified:
    geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/ClassPath.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java

Modified: geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/ClassPath.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/ClassPath.java?rev=706578&r1=706577&r2=706578&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/ClassPath.java
(original)
+++ geronimo/gshell/trunk/gshell-application/src/main/java/org/apache/geronimo/gshell/application/ClassPath.java
Tue Oct 21 04:23:11 2008
@@ -34,4 +34,6 @@
     Collection<Artifact> getArtifacts();
 
     Collection<URL> getUrls();
+
+    boolean isValid();
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java?rev=706578&r1=706577&r2=706578&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ApplicationManagerImpl.java
Tue Oct 21 04:23:11 2008
@@ -153,7 +153,7 @@
 
         // FIXME: Get state directory from application/branding
         File file = new File(new File(System.getProperty("gshell.home")), "var/classpath.ser");
-        ClassPath classPath;
+        ClassPath classPath = null;
 
         //
         // HACK: Using a serialized object here, for lack of a better choice.  XStream is
not on the classpath yet, and the java.beans.XMLEncoder sucks my balls.
@@ -161,19 +161,33 @@
 
         if (file.exists()) {
             ObjectInputStream input = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
-            classPath = (ClassPath)input.readObject();
-            log.debug("Loaded classpath from cache: {}", file);
-            Closer.close(input);
+            try {
+                classPath = (ClassPath)input.readObject();
+                log.debug("Loaded classpath from cache: {}", file);
+            }
+            finally {
+                Closer.close(input);
+            }
+
+            if (!classPath.isValid()) {
+                classPath = null;
+                log.debug("Classpath is not valid; reloading");
+            }
         }
-        else {
+
+        if (classPath == null) {
             Set<Artifact> artifacts = resolveArtifacts(model);
             classPath = new ClassPathImpl(artifacts);
             log.debug("Saving classpath to cache: {}", file);
             // noinspection ResultOfMethodCallIgnored
             file.getParentFile().mkdirs();
             ObjectOutputStream output = new ObjectOutputStream(new BufferedOutputStream(new
FileOutputStream(file)));
-            output.writeObject(classPath);
-            Closer.close(output);
+            try {
+                output.writeObject(classPath);
+            }
+            finally {
+                Closer.close(output);
+            }
         }
         
         if (log.isDebugEnabled()) {

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.java?rev=706578&r1=706577&r2=706578&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/src/main/java/org/apache/geronimo/gshell/wisdom/application/ClassPathImpl.java
Tue Oct 21 04:23:11 2008
@@ -80,4 +80,15 @@
 
         return urls;
     }
+
+    public boolean isValid() {
+        for (Artifact artifact : artifacts) {
+            File file = artifact.getFile();
+            if (file != null && !file.exists()) {
+                return false;
+            }
+        }
+
+        return true;
+    }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java?rev=706578&r1=706577&r2=706578&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginManagerImpl.java
Tue Oct 21 04:23:11 2008
@@ -172,14 +172,20 @@
         assert application != null;
         assert artifact != null;
 
-        ClassPath classPath;
+        ClassPath classPath = null;
         // FIXME: Get state directory from application/branding
         XStoreRecord record = xstore.resolveRecord(artifact.getGroupId() + "/" + artifact.getArtifactId()
+ "/classpath.xml");
         if (record.exists()) {
             classPath = record.get(ClassPathImpl.class);
             log.debug("Loaded classpath from cache: {}", record);
+
+            if (!classPath.isValid()) {
+                classPath = null;
+                log.debug("Classpath is not valid; reloading");
+            }
         }
-        else {
+
+        if (classPath == null) {
             Set<Artifact> artifacts = resolveArtifacts(application, artifact);
             classPath = new ClassPathImpl(artifacts);
             log.debug("Saving classpath to cache: {}", record);



Mime
View raw message