geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1237961 - /geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationUpdateHelper.java
Date Mon, 30 Jan 2012 20:13:08 GMT
Author: gawor
Date: Mon Jan 30 20:13:08 2012
New Revision: 1237961

URL: http://svn.apache.org/viewvc?rev=1237961&view=rev
Log:
GERONIMO-6209: Class hot swap fixes. Properly handle multiple Bundle-ClassPath entries

Modified:
    geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationUpdateHelper.java

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationUpdateHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationUpdateHelper.java?rev=1237961&r1=1237960&r2=1237961&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationUpdateHelper.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationUpdateHelper.java
Mon Jan 30 20:13:08 2012
@@ -211,8 +211,7 @@ public class ApplicationUpdateHelper {
                 }
                 
                 // compute & load existing class
-                String className = getClassName(classPath, name);
-                Class<?> clazz = bundle.loadClass(className);
+                Class<?> clazz = loadClass(bundle, classPath, name);
                 
                 // get the new class bytes
                 InputStream in = zipFile.getInputStream(entry);
@@ -265,22 +264,34 @@ public class ApplicationUpdateHelper {
         return classPath;
     }
     
-    /*
-     * Get the class name to load based on the Bundle-ClassPath entries.
-     */
-    private String getClassName(String[] classPath, String classEntryName) {
-        if (classPath != null) {
-            /*
-             * It is possible that the class entry name could match multiple class path entries
-             * but that is pretty rare - so let's ignore this case for now.
-             */
-            for (String classPathEntry : classPath) {            
-                if (classEntryName.startsWith(classPathEntry)) {
-                    classEntryName = classEntryName.substring(classPathEntry.length() + 1);
-                    break;
+    private Class<?> loadClass(Bundle bundle, String[] classPath, String classEntryName)
throws ClassNotFoundException {
+        if (classPath == null) {
+            String className = getClassName("", classEntryName);
+            return bundle.loadClass(className);
+        } else {
+            List<String> classes = null;
+            for (String classPathEntry : classPath) {
+                String className = getClassName(classPathEntry, classEntryName);
+                LOG.debug("Attempting to load {} ", className);
+                try {
+                    return bundle.loadClass(className);
+                } catch (Throwable t) {
+                    LOG.debug("Failed to load " + className, t);
+                    // keep trying
+                    if (classes == null) {
+                        classes =  new ArrayList<String>(classPath.length);
+                    }
+                    classes.add(className);
                 }
             }
+            throw new ClassNotFoundException(classes.toString());
         }
+    }
+        
+    private String getClassName(String classPathEntry, String classEntryName) {
+        if (classPathEntry.length() > 0 && classEntryName.startsWith(classPathEntry))
{
+            classEntryName = classEntryName.substring(classPathEntry.length() + 1);     
      
+        }        
         return classEntryName.substring(0, classEntryName.length() - ".class".length()).replace('/',
'.');
     }
     



Mime
View raw message