geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r151214 - in geronimo/trunk/modules/axis-builder/src: java/org/apache/geronimo/axis/builder/AxisBuilder.java test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java
Date Thu, 03 Feb 2005 19:49:14 GMT
Author: djencks
Date: Thu Feb  3 11:49:13 2005
New Revision: 151214

URL: http://svn.apache.org/viewcvs?view=rev&rev=151214
Log:
Fix some problems.  Most calls seem to go out now.  Use ClassLoading for class loading

Modified:
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
    geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java?view=diff&r1=151213&r2=151214
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
Thu Feb  3 11:49:13 2005
@@ -96,6 +96,7 @@
 import org.apache.geronimo.xbeans.j2ee.ServiceEndpointMethodMappingType;
 import org.apache.geronimo.xbeans.j2ee.WsdlMessageMappingType;
 import org.apache.geronimo.xbeans.j2ee.WsdlReturnValueMappingType;
+import org.apache.geronimo.kernel.ClassLoading;
 import org.apache.xmlbeans.XmlException;
 import org.objectweb.asm.Type;
 import org.xml.sax.InputSource;
@@ -128,36 +129,40 @@
 
     public Object createService(Class serviceInterface, URI wsdlURI, URI jaxrpcMappingURI,
QName serviceQName, Map portComponentRefMap, List handlers, DeploymentContext deploymentContext,
Module module, ClassLoader classLoader) throws DeploymentException {
         JarFile moduleFile = module.getModuleFile();
-        JarWSDLLocator wsdlLocator = new JarWSDLLocator(moduleFile, wsdlURI);
-        WSDLFactory wsdlFactory = null;
-        try {
-            wsdlFactory = WSDLFactory.newInstance();
-        } catch (WSDLException e) {
-            throw new DeploymentException("Could not create WSDLFactory", e);
-        }
-        WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
         Definition definition = null;
-        try {
-            definition = wsdlReader.readWSDL(wsdlLocator);
-        } catch (WSDLException e) {
-            throw new DeploymentException("Failed to read wsdl document", e);
-        }
+        JavaWsdlMappingType mapping = null;
+        if (wsdlURI != null) {
+            JarWSDLLocator wsdlLocator = new JarWSDLLocator(moduleFile, wsdlURI);
+            WSDLFactory wsdlFactory = null;
+            try {
+                wsdlFactory = WSDLFactory.newInstance();
+            } catch (WSDLException e) {
+                throw new DeploymentException("Could not create WSDLFactory", e);
+            }
+            WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
+            definition = null;
+            try {
+                definition = wsdlReader.readWSDL(wsdlLocator);
+            } catch (WSDLException e) {
+                throw new DeploymentException("Failed to read wsdl document", e);
+            }
 
-        InputStream jaxrpcInputStream = null;
-        try {
-            jaxrpcInputStream = moduleFile.getInputStream(moduleFile.getEntry(jaxrpcMappingURI.toString()));
-        } catch (IOException e) {
-            throw new DeploymentException("Could not open stream to jaxrpc mapping document",
e);
-        }
-        JavaWsdlMappingDocument mappingDocument = null;
-        try {
-            mappingDocument = JavaWsdlMappingDocument.Factory.parse(jaxrpcInputStream);
-        } catch (XmlException e) {
-            throw new DeploymentException("Could not parse jaxrpc mapping document", e);
-        } catch (IOException e) {
-            throw new DeploymentException("Could not read jaxrpc mapping document", e);
+            InputStream jaxrpcInputStream = null;
+            try {
+                jaxrpcInputStream = moduleFile.getInputStream(moduleFile.getEntry(jaxrpcMappingURI.toString()));
+            } catch (IOException e) {
+                throw new DeploymentException("Could not open stream to jaxrpc mapping document",
e);
+            }
+            JavaWsdlMappingDocument mappingDocument = null;
+            try {
+                mappingDocument = JavaWsdlMappingDocument.Factory.parse(jaxrpcInputStream);
+            } catch (XmlException e) {
+                throw new DeploymentException("Could not parse jaxrpc mapping document",
e);
+            } catch (IOException e) {
+                throw new DeploymentException("Could not read jaxrpc mapping document", e);
+            }
+            mapping = mappingDocument.getJavaWsdlMapping();
         }
-        JavaWsdlMappingType mapping = mappingDocument.getJavaWsdlMapping();
 
         Object service = createService(serviceInterface, definition, mapping, serviceQName,
SOAP_VERSION, deploymentContext, module, classLoader);
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -178,7 +183,9 @@
         Map seiPortNameToFactoryMap = new HashMap();
         Map seiClassNameToFactoryMap = new HashMap();
         Object serviceInstance = createService(serviceInterface, seiPortNameToFactoryMap,
seiClassNameToFactoryMap, context, module, classloader);
-        buildSEIFactoryMap(serviceInterface, definition, mapping, serviceQName, soapVersion,
seiPortNameToFactoryMap, seiClassNameToFactoryMap, serviceInstance, context, module, classloader);
+        if (definition != null) {
+            buildSEIFactoryMap(serviceInterface, definition, mapping, serviceQName, soapVersion,
seiPortNameToFactoryMap, seiClassNameToFactoryMap, serviceInstance, context, module, classloader);
+        }
         return serviceInstance;
     }
 
@@ -308,7 +315,12 @@
 
                     String className = javaXmlTypeMapping.getJavaType().getStringValue().trim();
 
-                    Class clazz = convertJavaTypeName(className, classLoader);
+                    Class clazz = null;
+                    try {
+                        clazz = ClassLoading.loadClass(className, classLoader);
+                    } catch (ClassNotFoundException e) {
+                        throw new DeploymentException("Could not load java type", e);
+                    }
                     if (clazz.isArray()) {
                         serializerFactoryClass = ArraySerializerFactory.class;
                         deserializerFactoryClass = ArrayDeserializerFactory.class;
@@ -339,79 +351,6 @@
         }
     }
 
-    Class convertJavaTypeName(String className, ClassLoader classLoader) throws DeploymentException
{
-        int pos = className.indexOf("[");
-        if (pos > -1) {
-            String baseType = className.substring(0, pos).trim();
-            StringBuffer buf = new StringBuffer(className.length());
-            buf.append("[");
-            while ((pos = className.indexOf("[", pos + 1)) > -1) {
-                buf.append("[");
-            }
-
-            if (baseType.equals("int")) {
-                buf.append("I");
-            } else if (baseType.equals("boolean")) {
-                buf.append("Z");
-            } else if (baseType.equals("byte")) {
-                buf.append("B");
-            } else if (baseType.equals("char")) {
-                buf.append("C");
-            } else if (baseType.equals("short")) {
-                buf.append("S");
-            } else if (baseType.equals("double")) {
-                buf.append("D");
-            } else if (baseType.equals("float")) {
-                buf.append("F");
-            } else if (baseType.equals("long")) {
-                buf.append("J");
-            } else {
-                buf.append("L").append(baseType).append(";");
-            }
-            className = buf.toString();
-        } else {
-            if (className.equals("int")) {
-                return int.class;
-            } else if (className.equals("boolean")) {
-                return boolean.class;
-            } else if (className.equals("byte")) {
-                return byte.class;
-            } else if (className.equals("char")) {
-                return char.class;
-            } else if (className.equals("short")) {
-                return short.class;
-            } else if (className.equals("double")) {
-                return double.class;
-            } else if (className.equals("float")) {
-                return float.class;
-            } else if (className.equals("long")) {
-                return long.class;
-            } else if (className.equals("void")) {
-                return void.class;
-            }
-        }
-        try {
-            return classLoader.loadClass(className);
-        } catch (ClassNotFoundException e) {
-            throw new DeploymentException("Could not load class ", e);
-        }
-    }
-
-//    private Class[] getParameterTypes(ServiceEndpointMethodMappingType methodMapping, ClassLoader
classloader) throws DeploymentException {
-//        MethodParamPartsMappingType[] paramMappings = methodMapping.getMethodParamPartsMappingArray();
-//        Class[] types = new Class[paramMappings.length];
-//        for (int i = 0; i < paramMappings.length; i++) {
-//            MethodParamPartsMappingType paramMapping = paramMappings[i];
-//            String paramType = paramMapping.getParamType().getStringValue().trim();
-//            try {
-//                types[i] = classloader.loadClass(paramType);
-//            } catch (ClassNotFoundException e) {
-//                throw new DeploymentException("Could not load param type", e);
-//            }
-//        }
-//        return types;
-//    }
-
     private ServiceEndpointMethodMappingType getMethodMappingForOperation(Operation operation,
ServiceEndpointMethodMappingType[] methodMappings) throws DeploymentException {
         String operationName = operation.getName();
         for (int i = 0; i < methodMappings.length; i++) {
@@ -640,6 +579,8 @@
 
         Message inputMessage = operation.getInput().getMessage();
 
+        boolean isWrappedElement = methodMapping.isSetWrappedElement();
+
         MethodParamPartsMappingType[] paramMappings = methodMapping.getMethodParamPartsMappingArray();
         Type[] parameterASMTypes = new Type[paramMappings.length];
         ParameterDesc[] parameterDescriptions = new ParameterDesc[paramMappings.length];
@@ -647,7 +588,12 @@
             MethodParamPartsMappingType paramMapping = paramMappings[i];
             int position = paramMapping.getParamPosition().getBigIntegerValue().intValue();
             String paramJavaTypeName = paramMapping.getParamType().getStringValue().trim();
-            Class paramJavaType = convertJavaTypeName(paramJavaTypeName, classLoader);
+            Class paramJavaType = null;
+            try {
+                paramJavaType = ClassLoading.loadClass(paramJavaTypeName, classLoader);
+            } catch (ClassNotFoundException e) {
+                throw new DeploymentException("could not load parameter type", e);
+            }
 
             WsdlMessageMappingType wsdlMessageMappingType = paramMapping.getWsdlMessageMapping();
             String parameterMode = wsdlMessageMappingType.getParameterMode().getStringValue().trim();
@@ -666,7 +612,8 @@
 //            Message inputMessage = definition.getMessage(wsdlMessageQName);
             Part part = inputMessage.getPart(wsdlMessagePartName);
             //TODO this makes little sense but may be correct, see comments in axis Parameter
class
-            QName partQName = part.getElementName();
+            //the part name qname is really odd.
+            QName partQName = isWrappedElement? part.getElementName(): new QName("", part.getName());
             QName partTypeQName = part.getTypeName();
 
             ParameterDesc parameterDesc = new ParameterDesc(partQName, mode, partTypeQName,
paramJavaType, inHeader, outHeader);
@@ -684,7 +631,11 @@
         if (methodMapping.isSetWsdlReturnValueMapping()) {
             WsdlReturnValueMappingType wsdlReturnValueMapping = methodMapping.getWsdlReturnValueMapping();
             String returnClassName = wsdlReturnValueMapping.getMethodReturnValue().getStringValue().trim();
-            returnClass = convertJavaTypeName(returnClassName, classLoader);
+            try {
+                returnClass = ClassLoading.loadClass(returnClassName, classLoader);
+            } catch (ClassNotFoundException e) {
+                throw new DeploymentException("Could not load return type", e);
+            }
 
             QName wsdlMessageQName = wsdlReturnValueMapping.getWsdlMessage().getQNameValue();
 

Modified: geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java?view=diff&r1=151213&r2=151214
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java
Thu Feb  3 11:49:13 2005
@@ -111,35 +111,6 @@
         recursiveDelete(tmpbasedir);
     }
 
-    public void testGetArrayClassName() throws Exception {
-        AxisBuilder builder = new AxisBuilder();
-        ClassLoader classLoader = this.getClass().getClassLoader();
-        assertEquals(Object[].class, builder.convertJavaTypeName("java.lang.Object[]", classLoader));
-        assertEquals(Object[].class, builder.convertJavaTypeName("java.lang.Object [ ] ",
classLoader));
-        assertEquals(Object[][].class, builder.convertJavaTypeName("java.lang.Object [ ]
[]", classLoader));
-
-        assertEquals(boolean[][].class, builder.convertJavaTypeName("boolean [ ] []", classLoader));
-        assertEquals(byte[][].class, builder.convertJavaTypeName("byte [ ] []", classLoader));
-        assertEquals(char[][].class, builder.convertJavaTypeName("char [ ] []", classLoader));
-        assertEquals(double[][].class, builder.convertJavaTypeName("double [ ] []", classLoader));
-        assertEquals(float[][].class, builder.convertJavaTypeName("float [ ] []", classLoader));
-        assertEquals(int[][].class, builder.convertJavaTypeName("int [ ] []", classLoader));
-        assertEquals(long[][].class, builder.convertJavaTypeName("long [ ] []", classLoader));
-        assertEquals(short[][].class, builder.convertJavaTypeName("short [ ] []", classLoader));
-
-        assertEquals(boolean.class, builder.convertJavaTypeName("boolean", classLoader));
-        assertEquals(byte.class, builder.convertJavaTypeName("byte", classLoader));
-        assertEquals(char.class, builder.convertJavaTypeName("char", classLoader));
-        assertEquals(double.class, builder.convertJavaTypeName("double", classLoader));
-        assertEquals(float.class, builder.convertJavaTypeName("float", classLoader));
-        assertEquals(int.class, builder.convertJavaTypeName("int", classLoader));
-        assertEquals(long.class, builder.convertJavaTypeName("long", classLoader));
-        assertEquals(short.class, builder.convertJavaTypeName("short", classLoader));
-        assertEquals(void.class, builder.convertJavaTypeName("void", classLoader));
-
-
-    }
-
     public void testServiceRefCreation() throws Exception {
         AxisBuilder builder = new AxisBuilder();
 



Mime
View raw message