axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r691112 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DefaultObjectSupplier.java
Date Tue, 02 Sep 2008 06:07:08 GMT
Author: amilas
Date: Mon Sep  1 23:07:07 2008
New Revision: 691112

URL: http://svn.apache.org/viewvc?rev=691112&view=rev
Log:
fixed Axis2 4004. Instantiate not static inner classes

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DefaultObjectSupplier.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DefaultObjectSupplier.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DefaultObjectSupplier.java?rev=691112&r1=691111&r2=691112&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DefaultObjectSupplier.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DefaultObjectSupplier.java
Mon Sep  1 23:07:07 2008
@@ -21,13 +21,38 @@
 
 import org.apache.axis2.AxisFault;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
 public class DefaultObjectSupplier implements ObjectSupplier {
 
     public Object getObject(Class clazz) throws AxisFault {
         try {
             return clazz.newInstance();
-        } catch (Exception e) {
-            throw AxisFault.makeFault(e);
+        } catch (Exception exception) {
+            String className = clazz.getName();
+            // if this is an inner class then that can be a non static inner class. those
classes have to be instanciate
+            // in a different way than a normal initialization
+            if (className.indexOf("$") > 0) {
+                String outerClassName = className.substring(0, className.indexOf("$"));
+                try {
+                    Class outerClass = Class.forName(outerClassName);
+                    Object outerClassObject = outerClass.newInstance();
+                    Constructor innterClassConstructor = clazz.getConstructor(new Class[]{outerClass});
+                    return innterClassConstructor.newInstance(new Object[]{outerClassObject});
+                } catch (ClassNotFoundException e) {
+                    throw AxisFault.makeFault(e);
+                } catch (IllegalAccessException e) {
+                    throw AxisFault.makeFault(e);
+                } catch (InstantiationException e) {
+                    throw AxisFault.makeFault(e);
+                } catch (NoSuchMethodException e) {
+                    throw AxisFault.makeFault(e);
+                } catch (InvocationTargetException e) {
+                    throw AxisFault.makeFault(e);
+                }
+            }
+            throw AxisFault.makeFault(exception);
         }
     }
 }



Mime
View raw message