geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r161563 - in geronimo/trunk/modules: axis-builder/src/java/org/apache/geronimo/axis/builder/ axis/src/java/org/apache/geronimo/axis/server/ axis/src/test/org/apache/geronimo/axis/ jetty/ jetty/src/java/org/apache/geronimo/jetty/
Date Sat, 16 Apr 2005 12:37:49 GMT
Author: gdamour
Date: Sat Apr 16 05:37:47 2005
New Revision: 161563

URL: http://svn.apache.org/viewcvs?view=rev&rev=161563
Log:
A couple of changes to get lightweight types mapping working and properly
register the TypeDesc from the client invoking the WS.

This includes:

o implement TypeDesc builder for lightweight mappings;

o make ReadOnlyServiceDesc Externalizable. The custom deserialization is
used to register the underlying TypeDesc prior to deserialize the contained 
JavaServiceDesc. This is required as JavaServiceDesc contains a bunch of 
BeanXXXFactory requiring the relevant TypeDesc to be registered in order to 
properly recreate their states; and

o remove the dependency to geronimo-axis from geronimo-jetty and roll-back
my previous fix to JettyPOJOWebServiceHolder as it is now redundant. My
previous fix was registering the TypeDesc prior to deserialize the 
JavaServiceDesc contained by WebServiceContainer.

Modified:
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/TypeDescBuilder.java
    geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/ReadOnlyServiceDesc.java
    geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebServiceContainerTest.java
    geronimo/trunk/modules/jetty/project.xml
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyPOJOWebServiceHolder.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=161562&r2=161563
==============================================================================
--- 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
Sat Apr 16 05:37:47 2005
@@ -19,7 +19,6 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectOutputStream;
-import java.io.Serializable;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.MalformedURLException;
@@ -45,7 +44,6 @@
 import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.xml.namespace.QName;
-import javax.xml.rpc.encoding.TypeMapping;
 import javax.xml.rpc.handler.HandlerInfo;
 
 import net.sf.cglib.core.DefaultGeneratorStrategy;
@@ -154,7 +152,6 @@
         //targetGBean.setAttribute("webServiceContainer", axisWebServiceContainer);
         try {
             targetGBean.setAttribute("webServiceContainer", new StoredObject(axisWebServiceContainer));
// Hack!
-            targetGBean.setAttribute("classToTypeDescInfo", new StoredObject((Serializable)
serviceDesc.getProperty(AxisServiceBuilder.CLASS_TO_TYPE_DESC_INFO))); // Hack!
         } catch (IOException e) {
             throw new DeploymentException("Unable to serialize the AxisWebServiceContainer",
e);
         }

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java?view=diff&r1=161562&r2=161563
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
Sat Apr 16 05:37:47 2005
@@ -21,7 +21,6 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -29,6 +28,7 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.jar.JarFile;
+
 import javax.wsdl.Binding;
 import javax.wsdl.BindingInput;
 import javax.wsdl.BindingOperation;
@@ -36,13 +36,12 @@
 import javax.wsdl.Import;
 import javax.wsdl.Port;
 import javax.wsdl.Types;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
 import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.wsdl.extensions.soap.SOAPBody;
-import javax.wsdl.extensions.UnknownExtensibilityElement;
 import javax.xml.namespace.QName;
-import javax.xml.rpc.handler.HandlerInfo;
 
 import org.apache.axis.constants.Style;
 import org.apache.axis.constants.Use;
@@ -65,10 +64,7 @@
 import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.kernel.ClassLoading;
 import org.apache.geronimo.xbeans.j2ee.JavaXmlTypeMappingType;
-import org.apache.geronimo.xbeans.j2ee.ParamValueType;
-import org.apache.geronimo.xbeans.j2ee.PortComponentHandlerType;
 import org.apache.geronimo.xbeans.j2ee.ServiceEndpointMethodMappingType;
-import org.apache.geronimo.xbeans.j2ee.XsdQNameType;
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
@@ -82,8 +78,6 @@
  * @version $Rev$ $Date$
  */
 public class AxisServiceBuilder {
-    public static final String CLASS_TO_TYPE_DESC_INFO = "classToTypeDescInfo";
-    
     public static final String XSD_NS = "http://www.w3.org/2001/XMLSchema";
     public static final QName SCHEMA_QNAME = new QName(XSD_NS, "schema");
 
@@ -194,10 +188,8 @@
             buildHeavyweightTypes(wrapperElementQNames, javaXmlTypeMappings, classLoader,
schemaTypeKeyToSchemaTypeMap, typeMapping, classToTypeDescInfo);
         }
 
-        serviceDesc.setProperty(CLASS_TO_TYPE_DESC_INFO, classToTypeDescInfo);
-        
         serviceDesc.getOperations();
-        return new ReadOnlyServiceDesc(serviceDesc);
+        return new ReadOnlyServiceDesc(serviceDesc, classToTypeDescInfo);
     }
 
     private static void buildHeavyweightTypes(Set wrapperElementQNames, JavaXmlTypeMappingType[]
javaXmlTypeMappings, ClassLoader classLoader, Map schemaTypeKeyToSchemaTypeMap, TypeMapping
typeMapping, Map classToTypeDescInfo) throws DeploymentException {
@@ -273,7 +265,7 @@
         for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.entrySet().iterator(); iterator.hasNext();)
{
             Map.Entry entry = (Map.Entry) iterator.next();
             SchemaTypeKey key = (SchemaTypeKey) entry.getKey();
-//            SchemaType schemaType = (SchemaType) entry.getValue();
+            SchemaType schemaType = (SchemaType) entry.getValue();
             if (!key.isElement() && !key.isAnonymous()) {
                 //default settings
                 QName typeQName = key.getqName();
@@ -297,14 +289,14 @@
                     deserializerFactoryClass = ArrayDeserializerFactory.class;
                 }
 
+                TypeDescInfo typeDescInfo = TypeDescBuilder.getTypeDescInfo(clazz, typeQName,
schemaType);
+                TypeDesc.registerTypeDescForClass(clazz, typeDescInfo.buildTypeDesc());
+                classToTypeDescInfo.put(clazz, typeDescInfo);
+
                 SerializerFactory ser = BaseSerializerFactory.createFactory(serializerFactoryClass,
clazz, typeQName);
                 DeserializerFactory deser = BaseDeserializerFactory.createFactory(deserializerFactoryClass,
clazz, typeQName);
-                typeMapping.register(clazz, typeQName, ser, deser);
-
-                //TODO construct typedesc as well.
-//                TypeDesc typeDesc = getTypeDescriptor(clazz, typeQName, javaXmlTypeMapping,
schemaType);
-//                typeDescriptors.put(clazz, typeDesc);
 
+                typeMapping.register(clazz, typeQName, ser, deser);
             }
         }
     }

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/TypeDescBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/TypeDescBuilder.java?view=diff&r1=161562&r2=161563
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/TypeDescBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/TypeDescBuilder.java
Sat Apr 16 05:37:47 2005
@@ -19,6 +19,7 @@
 import java.beans.PropertyDescriptor;
 import java.beans.Introspector;
 import java.beans.IntrospectionException;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.HashMap;
 import java.lang.reflect.Field;
@@ -32,9 +33,62 @@
 import org.apache.geronimo.xbeans.j2ee.VariableMappingType;
 import org.apache.geronimo.axis.server.TypeDescInfo;
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.xmlbeans.SchemaParticle;
 import org.apache.xmlbeans.SchemaType;
 
 public class TypeDescBuilder {
+    public static TypeDescInfo getTypeDescInfo(Class javaClass, QName typeQName, SchemaType
schemaType) throws DeploymentException {
+        boolean isRestriction = schemaType.getDerivationType() == SchemaType.DT_RESTRICTION;
+        
+        Map nameToTypeQName = new HashMap();
+        SchemaParticle contentModel = schemaType.getContentModel();
+        int particleType = contentModel.getParticleType();
+        if (SchemaParticle.ALL == particleType || SchemaParticle.CHOICE == particleType ||
+                SchemaParticle.SEQUENCE == particleType) {
+            SchemaParticle[] properties = contentModel.getParticleChildren();
+            for (int i = 0; i < properties.length; i++) {
+                SchemaParticle parameter = properties[i];
+                nameToTypeQName.put(parameter.getName().getLocalPart(), parameter.getType().getName());
+            }
+        } else {
+            throw new DeploymentException("Only all, choice and sequence particle types are
supported." +
+                    " SchemaType name =" + schemaType.getName());
+        }
+        
+        PropertyDescriptor[] descriptors;
+        try {
+            descriptors = Introspector.getBeanInfo(javaClass).getPropertyDescriptors();
+        } catch (IntrospectionException e) {
+            throw new DeploymentException("Class " + javaClass + " is not a valid javabean",
e);
+        }
+        Map nameToClass = new HashMap();
+        for (int i = 0; i < descriptors.length; i++) {
+            nameToClass.put(descriptors[i].getName(), descriptors[i].getPropertyType());
+        }
+
+        int idx = 0;
+        FieldDesc[] fields = new FieldDesc[nameToTypeQName.size()];
+        for (Iterator iter = nameToTypeQName.entrySet().iterator(); iter.hasNext();) {
+            Map.Entry entry = (Map.Entry) iter.next();
+
+            String fieldName = (String) entry.getKey();
+            ElementDesc elementDesc = new ElementDesc();
+            elementDesc.setFieldName(fieldName);
+            
+            Class javaType = (Class) nameToClass.get(fieldName);
+            if (null == javaType) {
+                throw new DeploymentException("Field " + fieldName + " is not defined by
class " + javaClass.getName());
+            }
+            elementDesc.setJavaType(javaType);
+            elementDesc.setXmlName(new QName("", fieldName));
+            elementDesc.setXmlType((QName) entry.getValue());
+            
+            fields[idx++] = elementDesc;
+        }
+        
+        return new TypeDescInfo(javaClass, isRestriction, typeQName, fields);
+    }
+    
     public static TypeDescInfo getTypeDescInfo(Class javaClass, QName typeQName, JavaXmlTypeMappingType
javaXmlTypeMapping, SchemaType schemaType) throws DeploymentException {
         boolean isRestriction = schemaType.getDerivationType() == SchemaType.DT_RESTRICTION;
         

Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/ReadOnlyServiceDesc.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/ReadOnlyServiceDesc.java?view=diff&r1=161562&r2=161563
==============================================================================
--- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/ReadOnlyServiceDesc.java
(original)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/ReadOnlyServiceDesc.java
Sat Apr 16 05:37:47 2005
@@ -16,25 +16,41 @@
  */
 package org.apache.geronimo.axis.server;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+
 import javax.xml.namespace.QName;
 
 import org.apache.axis.constants.Style;
 import org.apache.axis.constants.Use;
 import org.apache.axis.description.JavaServiceDesc;
 import org.apache.axis.description.OperationDesc;
+import org.apache.axis.description.TypeDesc;
 import org.apache.axis.encoding.TypeMapping;
 import org.apache.axis.encoding.TypeMappingRegistry;
 
 /**
  * @version $Rev$ $Date$
  */
-public class ReadOnlyServiceDesc extends JavaServiceDesc {
-    private final JavaServiceDesc serviceDesc;
+public class ReadOnlyServiceDesc extends JavaServiceDesc implements Externalizable {
+    private JavaServiceDesc serviceDesc;
+    private Map classToTypeDescInfo;
+
+    /**
+     * Only required as Externalizable.
+     */
+    public ReadOnlyServiceDesc() {
+    }
 
-    public ReadOnlyServiceDesc(JavaServiceDesc serviceDesc) {
+    public ReadOnlyServiceDesc(JavaServiceDesc serviceDesc, Map classToTypeDescInfo) {
         this.serviceDesc = serviceDesc;
+        this.classToTypeDescInfo = classToTypeDescInfo;
     }
 
     public Class getImplClass() {
@@ -186,4 +202,24 @@
     public void setDisallowedMethods(List disallowedMethods) {
     }
 
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        classToTypeDescInfo = (Map) in.readObject();
+        
+        // one must register the TypeDesc before to deserialize the JavaServiceDesc
+        // as it contains a bunch of BeanXXXFactory instances which need 
+        // them registered to properly recreate the state of the factories.
+        for (Iterator iter = classToTypeDescInfo.entrySet().iterator(); iter.hasNext();)
{
+            Map.Entry entry = (Map.Entry) iter.next();
+            Class clazz = (Class) entry.getKey();
+            TypeDescInfo typeDescInfo = (TypeDescInfo) entry.getValue();
+            TypeDesc.registerTypeDescForClass(clazz, typeDescInfo.buildTypeDesc());
+        }
+        
+        serviceDesc = (JavaServiceDesc) in.readObject();
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(classToTypeDescInfo);
+        out.writeObject(serviceDesc);
+    }
 }

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebServiceContainerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebServiceContainerTest.java?view=diff&r1=161562&r2=161563
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebServiceContainerTest.java
(original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebServiceContainerTest.java
Sat Apr 16 05:37:47 2005
@@ -81,7 +81,7 @@
         serviceDesc.addOperationDesc(op);
 
         serviceDesc.getOperations();
-        ReadOnlyServiceDesc sd = new ReadOnlyServiceDesc(serviceDesc);
+        ReadOnlyServiceDesc sd = new ReadOnlyServiceDesc(serviceDesc, new HashMap());
 
         Class pojoClass = cl.loadClass("org.apache.geronimo.axis.testData.echosample.EchoBean");
 

Modified: geronimo/trunk/modules/jetty/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/project.xml?view=diff&r1=161562&r2=161563
==============================================================================
--- geronimo/trunk/modules/jetty/project.xml (original)
+++ geronimo/trunk/modules/jetty/project.xml Sat Apr 16 05:37:47 2005
@@ -178,19 +178,6 @@
             <version>${tranql_version}</version>
             <url>http://tranql.codehaus.org</url>
         </dependency>
-
-       <!-- TODO Needed for JettyPOJOWebServiceHolder. Move resource to geronimo-axis
-->
-        <dependency>
-            <groupId>geronimo</groupId>
-            <artifactId>geronimo-axis</artifactId>
-            <version>${pom.currentVersion}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>axis</groupId>
-            <artifactId>axis</artifactId>
-            <version>${axis_version}</version>
-        </dependency>
     </dependencies>
 
 

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyPOJOWebServiceHolder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyPOJOWebServiceHolder.java?view=diff&r1=161562&r2=161563
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyPOJOWebServiceHolder.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyPOJOWebServiceHolder.java
Sat Apr 16 05:37:47 2005
@@ -18,25 +18,23 @@
 
 import java.io.IOException;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+
 import javax.security.jacc.PolicyContext;
+import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.UnavailableException;
-import javax.servlet.ServletContext;
 
-import org.apache.axis.description.TypeDesc;
-import org.apache.geronimo.axis.server.TypeDescInfo;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.StoredObject;
-import org.apache.geronimo.webservices.WebServiceContainer;
 import org.apache.geronimo.webservices.POJOWebServiceServlet;
+import org.apache.geronimo.webservices.WebServiceContainer;
 import org.apache.geronimo.webservices.WebServiceContainerInvoker;
 import org.mortbay.jetty.servlet.ServletHolder;
 import org.mortbay.jetty.servlet.ServletHttpRequest;
@@ -50,7 +48,6 @@
  */
 public class JettyPOJOWebServiceHolder extends ServletHolder implements GBeanLifecycle {
     private StoredObject storedWebServiceContainer;
-    private StoredObject storedClassToTypeDescInfo;
     private Set servletMappings;
     private Map webRoleRefPermissions;
     private JettyServletRegistration context;
@@ -67,7 +64,6 @@
                                      Integer loadOnStartup,
                                      Set servletMappings,
                                      Map webRoleRefPermissions,
-                                     StoredObject storedClassToTypeDescInfo,
                                      StoredObject storedWebServiceContainer,
                                      JettyServletRegistration context) throws Exception {
         super(context == null ? null : context.getServletHandler(), servletName, POJOWebServiceServlet.class.getName(),
null);
@@ -84,8 +80,6 @@
             this.servletMappings = servletMappings;
             this.webRoleRefPermissions = webRoleRefPermissions == null ? Collections.EMPTY_MAP
: webRoleRefPermissions;
         }
-
-        this.storedClassToTypeDescInfo = storedClassToTypeDescInfo;
     }
 
     //todo how do we stop/destroy the servlet?
@@ -124,7 +118,6 @@
         infoBuilder.addAttribute("loadOnStartup", Integer.class, true);
         infoBuilder.addAttribute("servletMappings", Set.class, true);
         infoBuilder.addAttribute("webRoleRefPermissions", Map.class, true);
-        infoBuilder.addAttribute("classToTypeDescInfo", StoredObject.class, true);
         infoBuilder.addAttribute("webServiceContainer", StoredObject.class, true);
         infoBuilder.addReference("JettyServletRegistration", JettyServletRegistration.class);
 
@@ -134,7 +127,6 @@
                                                 "loadOnStartup",
                                                 "servletMappings",
                                                 "webRoleRefPermissions",
-                                                "classToTypeDescInfo",
                                                 "webServiceContainer",
                                                 "JettyServletRegistration"});
 
@@ -147,14 +139,6 @@
 
     public void doStart() throws Exception {
         if (context != null) {
-            Map classToTypeDesc = (Map) storedClassToTypeDescInfo.getObject(context.getWebClassLoader());
-            for (Iterator iter = classToTypeDesc.entrySet().iterator(); iter.hasNext();)
{
-                Map.Entry entry = (Map.Entry) iter.next();
-                Class clazz = (Class) entry.getKey();
-                TypeDescInfo typeDescInfo = (TypeDescInfo) entry.getValue();
-                TypeDesc.registerTypeDescForClass(clazz, typeDescInfo.buildTypeDesc());
-            }
-            
             Class pojoClass = context.getWebClassLoader().loadClass(pojoClassName);
             WebServiceContainer webServiceContainer = (WebServiceContainer) storedWebServiceContainer.getObject(context.getWebClassLoader());
 



Mime
View raw message