axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r724259 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DefaultObjectSupplier.java
Date Mon, 08 Dec 2008 04:59:55 GMT
Author: amilas
Date: Sun Dec  7 20:59:55 2008
New Revision: 724259

URL: http://svn.apache.org/viewvc?rev=724259&view=rev
Log:
Applied the patch AXIS2-4004

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=724259&r1=724258&r2=724259&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
Sun Dec  7 20:59:55 2008
@@ -21,38 +21,28 @@
 
 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 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);
-        }
-    }
+	/* (non-Javadoc)
+	 * @see org.apache.axis2.engine.ObjectSupplier#getObject(java.lang.Class)
+	 */
+	public Object getObject(Class clazz) throws AxisFault {
+		try {
+			Class parent = clazz.getDeclaringClass();
+			Object instance = null;
+
+			if (parent != null) {
+				// if this is an inner class then that can be a non static inner class. 
+				// those classes have to be instantiated in a different way than a normal initialization.
+				instance = clazz.getConstructor(new Class[] { parent })
+						.newInstance(new Object[] { getObject(parent) });
+			} else {
+				instance = clazz.newInstance();
+			}
+
+			return instance;
+		} catch (Exception e) {
+			throw AxisFault.makeFault(e);
+		}
+	}
 }



Mime
View raw message