cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1505757 - in /cxf/branches/2.7.x-fixes/rt/core/src: main/java/org/apache/cxf/bus/extension/ main/java/org/apache/cxf/bus/osgi/ test/java/org/apache/cxf/bus/extension/
Date Mon, 22 Jul 2013 18:17:48 GMT
Author: dkulp
Date: Mon Jul 22 18:17:47 2013
New Revision: 1505757

URL: http://svn.apache.org/r1505757
Log:
Merged revisions 1505745 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1505745 | dkulp | 2013-07-22 13:52:09 -0400 (Mon, 22 Jul 2013) | 2 lines

  If there is a problem loading an OSGi based extension, keep the original exception.

........

Modified:
    cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Extension.java
    cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionException.java
    cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
    cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/TextExtensionFragmentParser.java
    cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java
    cxf/branches/2.7.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/TextExtensionFragmentParserTest.java

Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Extension.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Extension.java?rev=1505757&r1=1505756&r2=1505757&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Extension.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Extension.java
Mon Jul 22 18:17:47 2013
@@ -32,7 +32,7 @@ import org.apache.cxf.common.logging.Log
 import org.apache.cxf.common.util.StringUtils;
 
 public class Extension {
-    private static final Logger LOG = LogUtils.getL7dLogger(Extension.class);
+    protected static final Logger LOG = LogUtils.getL7dLogger(Extension.class);
     
     protected String className;
     protected ClassLoader classloader;
@@ -61,6 +61,9 @@ public class Extension {
         className = cls.getName();
         classloader = cls.getClassLoader();
     }
+    public Extension(ClassLoader loader) {
+        classloader = loader;
+    }
     
     public Extension(Extension ext) {
         className = ext.className;
@@ -153,7 +156,7 @@ public class Extension {
         args = a;
     }
     
-    private  Class<?> tryClass(String name, ClassLoader cl) {
+    protected Class<?> tryClass(String name, ClassLoader cl) {
         if (classloader != null) {
             try {
                 return classloader.loadClass(name);

Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionException.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionException.java?rev=1505757&r1=1505756&r2=1505757&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionException.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionException.java
Mon Jul 22 18:17:47 2013
@@ -29,7 +29,7 @@ public class ExtensionException extends 
     /**
      * Constructs a <code>ExtensionException</code> with the provided detail
message.
      */
-    ExtensionException(Message msg) {
+    public ExtensionException(Message msg) {
         super(msg);
     }
 
@@ -37,14 +37,14 @@ public class ExtensionException extends 
      * Constructs a <code>ExtensionException</code> with the detail message and
cause
      * provided.
      */
-    ExtensionException(Message msg, Throwable cause) {
+    public ExtensionException(Message msg, Throwable cause) {
         super(msg, cause);
     }
 
     /**
      * Constructs an <code>ExtensionException</code> with the provided cause.
      */
-    ExtensionException(Throwable cause) {
+    public ExtensionException(Throwable cause) {
         super(cause);
     }
 }

Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java?rev=1505757&r1=1505756&r2=1505757&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
Mon Jul 22 18:17:47 2013
@@ -168,7 +168,7 @@ public class ExtensionManagerImpl implem
                             new Object[] {resource, url, BUS_EXTENSION_RESOURCE});
                     exts = new XmlExtensionFragmentParser().getExtensions(is);
                 } else {
-                    exts = new TextExtensionFragmentParser().getExtensions(is);
+                    exts = new TextExtensionFragmentParser(loader).getExtensions(is);
                 }
                 for (Extension e : exts) {
                     if (loader != l) {

Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/TextExtensionFragmentParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/TextExtensionFragmentParser.java?rev=1505757&r1=1505756&r2=1505757&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/TextExtensionFragmentParser.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/TextExtensionFragmentParser.java
Mon Jul 22 18:17:47 2013
@@ -36,6 +36,11 @@ public class TextExtensionFragmentParser
     private static final Logger LOG = LogUtils.getL7dLogger(TextExtensionFragmentParser.class);
     private static Pattern colonPattern = Pattern.compile(":");
     
+    final ClassLoader loader;
+    public TextExtensionFragmentParser(ClassLoader loader) {
+        this.loader = loader;
+    }
+    
     public List<Extension> getExtensions(final URL url) {
         InputStream is = null;
         try {
@@ -83,7 +88,7 @@ public class TextExtensionFragmentParser
         if (line.length() == 0 || line.charAt(0) == '#') {
             return null;
         }
-        final Extension ext = new Extension();
+        final Extension ext = new Extension(loader);
         String[] parts = colonPattern.split(line, 0);
         ext.setClassname(parts[0]);
         if (ext.getClassname() == null) {

Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java?rev=1505757&r1=1505756&r2=1505757&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java
Mon Jul 22 18:17:47 2013
@@ -29,8 +29,10 @@ import java.util.concurrent.CopyOnWriteA
 import java.util.logging.Logger;
 
 import org.apache.cxf.bus.extension.Extension;
+import org.apache.cxf.bus.extension.ExtensionException;
 import org.apache.cxf.bus.extension.ExtensionRegistry;
 import org.apache.cxf.bus.extension.TextExtensionFragmentParser;
+import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -71,7 +73,7 @@ public class CXFExtensionBundleListener 
     protected void register(final Bundle bundle) {
         Enumeration<?> e = bundle.findEntries("META-INF/cxf/", "bus-extensions.txt",
false);
         while (e != null && e.hasMoreElements()) {
-            List<Extension> orig = new TextExtensionFragmentParser().getExtensions((URL)e.nextElement());
+            List<Extension> orig = new TextExtensionFragmentParser(null).getExtensions((URL)e.nextElement());
             addExtensions(bundle, orig);
         }
     }
@@ -122,24 +124,28 @@ public class CXFExtensionBundleListener 
             bundle = b;
         }
 
-        public Class<?> getClassObject(ClassLoader cl) {
-            if (clazz == null) {
+        protected Class<?> tryClass(String name, ClassLoader cl) {
+            Class<?> c = null;
+            ClassNotFoundException origExc = null;
+            try {
+                c = bundle.loadClass(className);
+            } catch (ClassNotFoundException e) {
+                origExc = e;
+            }
+            if (c == null) {
                 try {
-                    clazz = bundle.loadClass(className);
-                } catch (Throwable e) {
-                    //ignore, fall to super
+                    return super.tryClass(name, cl);
+                } catch (ExtensionException ee) {
+                    if (origExc != null) {
+                        throw new ExtensionException(new Message("PROBLEM_LOADING_EXTENSION_CLASS",
+                                                                 Extension.LOG, name),
+                                                     origExc);
+                    } else {
+                        throw ee;
+                    }
                 }
             }
-            return super.getClassObject(cl);
-        }
-
-        public Class<?> loadInterface(ClassLoader cl) {
-            try {
-                return bundle.loadClass(interfaceName);
-            } catch (Throwable e) {
-                //ignore, fall to super
-            }
-            return super.loadInterface(cl);
+            return c;
         }
 
         public Extension cloneNoObject() {

Modified: cxf/branches/2.7.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/TextExtensionFragmentParserTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/TextExtensionFragmentParserTest.java?rev=1505757&r1=1505756&r2=1505757&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/TextExtensionFragmentParserTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/TextExtensionFragmentParserTest.java
Mon Jul 22 18:17:47 2013
@@ -31,7 +31,7 @@ public class TextExtensionFragmentParser
     @Test
     public void testGetExtensions() throws IOException {
         InputStream is = TextExtensionFragmentParserTest.class.getResourceAsStream("extension2.txt");
-        List<Extension> extensions = new TextExtensionFragmentParser().getExtensions(is);
+        List<Extension> extensions = new TextExtensionFragmentParser(null).getExtensions(is);
         assertEquals("Unexpected number of Extension elements.", 3, extensions.size());
         
         Extension e = extensions.get(0);



Mime
View raw message