cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1383527 - in /cxf/branches/2.6.x-fixes/rt/core/src: main/java/org/apache/cxf/bus/extension/Extension.java main/java/org/apache/cxf/bus/extension/Messages.properties test/java/org/apache/cxf/bus/extension/ExtensionTest.java
Date Tue, 11 Sep 2012 18:39:12 GMT
Author: dkulp
Date: Tue Sep 11 18:39:11 2012
New Revision: 1383527

URL: http://svn.apache.org/viewvc?rev=1383527&view=rev
Log:
Merged revisions 1382103 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1382103 | dkulp | 2012-09-07 13:56:51 -0400 (Fri, 07 Sep 2012) | 2 lines

  More error message updates

........

Modified:
    cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Extension.java
    cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Messages.properties
    cxf/branches/2.6.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionTest.java

Modified: cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Extension.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Extension.java?rev=1383527&r1=1383526&r2=1383527&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Extension.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Extension.java
Tue Sep 11 18:39:11 2012
@@ -23,6 +23,7 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 import java.util.logging.Logger;
 
 import org.apache.cxf.Bus;
@@ -222,16 +223,35 @@ public class Extension {
                                              ex.getCause());
             } catch (InstantiationException ex) {
                 throw new ExtensionException(new Message("PROBLEM_CREATING_EXTENSION_CLASS",
LOG, cls.getName()), ex);
-            } catch (Exception ex) {
+            } catch (SecurityException ex) {
+                throw new ExtensionException(new Message("PROBLEM_CREATING_EXTENSION_CLASS",
LOG, cls.getName()), ex);
+            } catch (NoSuchMethodException e) {
                 //ignore
             }
-            obj = cls.newInstance();
+            obj = cls.getConstructor().newInstance();
         } catch (ExtensionException ex) {
             throw ex;
         } catch (IllegalAccessException ex) {
             throw new ExtensionException(new Message("PROBLEM_CREATING_EXTENSION_CLASS",
LOG, cls.getName()), ex);
         } catch (InstantiationException ex) {
             throw new ExtensionException(new Message("PROBLEM_CREATING_EXTENSION_CLASS",
LOG, cls.getName()), ex);
+        } catch (IllegalArgumentException e) {
+            throw new ExtensionException(new Message("PROBLEM_CREATING_EXTENSION_CLASS",
LOG, cls.getName()), e);
+        } catch (SecurityException e) {
+            throw new ExtensionException(new Message("PROBLEM_CREATING_EXTENSION_CLASS",
LOG, cls.getName()), e);
+        } catch (InvocationTargetException ex) {
+            throw new ExtensionException(new Message("PROBLEM_CREATING_EXTENSION_CLASS",
LOG, cls.getName()), 
+                                         ex.getCause());
+        } catch (NoSuchMethodException ex) {
+            List<Object> a = new ArrayList<Object>();
+            if (b != null) {
+                a.add(b);
+            }
+            if (args != null) {
+                a.add(args);
+            }
+            throw new ExtensionException(new Message("PROBLEM_FINDING_CONSTRUCTOR", LOG,
+                                                     cls.getName(), a), ex);
         }
         return obj;
     }

Modified: cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Messages.properties?rev=1383527&r1=1383526&r2=1383527&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Messages.properties
(original)
+++ cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/extension/Messages.properties
Tue Sep 11 18:39:11 2012
@@ -20,4 +20,5 @@
 #
 DEPRECATED_EXTENSIONS = Loading Bus extensions via {0} (found url {1}) is deprecated.  Use
{2} instead.
 PROBLEM_LOADING_EXTENSION_CLASS = Could not load extension class {0}.
-PROBLEM_CREATING_EXTENSION_CLASS = Could not create object of extension class {0}.
\ No newline at end of file
+PROBLEM_CREATING_EXTENSION_CLASS = Could not create object of extension class {0}.
+PROBLEM_FINDING_CONSTRUCTOR = Could not find constructor for class {0} for args {1}.
\ No newline at end of file

Modified: cxf/branches/2.6.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionTest.java?rev=1383527&r1=1383526&r2=1383527&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionTest.java
Tue Sep 11 18:39:11 2012
@@ -60,15 +60,15 @@ public class ExtensionTest extends Asser
         try {
             e.load(cl, null);                  
         } catch (ExtensionException ex) {
-            assertTrue("ExtensionException does not wrap IllegalAccessException",
-                       ex.getCause() instanceof IllegalAccessException);
+            assertTrue("ExtensionException does not wrap NoSuchMethodException " + ex.getCause(),
+                       ex.getCause() instanceof NoSuchMethodException);
         } 
         e.setClassname(MyServiceConstructorThrowsException.class.getName());
         try {
             e.load(cl, null);                  
         } catch (ExtensionException ex) {
-            assertTrue("ExtensionException does not wrap InstantiationException",
-                       ex.getCause() instanceof InstantiationException);
+            assertTrue("ExtensionException does not wrap IllegalArgumentException",
+                       ex.getCause() instanceof IllegalArgumentException);
         } 
         e.setClassname("java.lang.String");
         Object obj = e.load(cl, null);
@@ -92,7 +92,7 @@ public class ExtensionTest extends Asser
         assertNotNull(cls);
     }
     
-    class MyServiceConstructorThrowsException {
+    static class MyServiceConstructorThrowsException {
         public MyServiceConstructorThrowsException() {
             throw new IllegalArgumentException();
         }



Mime
View raw message