You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by am...@apache.org on 2007/08/21 05:06:13 UTC

svn commit: r567923 [2/3] - in /webservices/axis2/trunk/java/modules/rmi: src/org/apache/axis2/rmi/ src/org/apache/axis2/rmi/config/ src/org/apache/axis2/rmi/databind/ src/org/apache/axis2/rmi/deploy/ src/org/apache/axis2/rmi/deploy/config/ src/org/apa...

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Field.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Field.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Field.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Field.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.metadata;
+
+import org.apache.axis2.rmi.metadata.xml.XmlElement;
+import org.apache.axis2.rmi.util.Constants;
+import org.apache.axis2.rmi.util.Util;
+import org.apache.axis2.rmi.Configurator;
+import org.apache.axis2.rmi.types.MapType;
+import org.apache.axis2.rmi.exception.MetaDataPopulateException;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+
+public abstract class Field {
+
+    /**
+     * property descriptor for this attribute
+     */
+    protected PropertyDescriptor propertyDescriptor;
+    /**
+     * name of the attribute this is the name of the XmlElement as well
+     */
+    protected String name;
+
+    /**
+     * namespce of this attribute
+     * this is always the namespace of the parent type
+     */
+    protected String namespace;
+
+    /**
+     * getter method of the attribute
+     */
+    protected Method getterMethod;
+
+    /**
+     * setter method of the attribute
+     */
+    protected Method setterMethod;
+
+    /**
+     * attribute metadata type
+     */
+    protected Type type;
+
+    /**
+     * boolean variable to check to see whether we generated the
+     * element for this schema.
+     * although we can check for null value of the element we prefer
+     * to keep a seperate variable.
+     */
+    protected boolean isSchemaGenerated;
+
+    /**
+     * default constructor
+     */
+    public Field() {
+    }
+
+    /**
+     * constructor with the property descriptor
+     *
+     * @param propertyDescriptor
+     */
+    public Field(PropertyDescriptor propertyDescriptor,
+                 String namespace) {
+        this.propertyDescriptor = propertyDescriptor;
+        if (Constants.RMI_TYPE_NAMSPACE.equals(namespace)) {
+            // for rmi defined type elements we keep attributes as unqualified
+            this.namespace = null;
+        } else {
+            this.namespace = namespace;
+        }
+
+    }
+
+    public void populateMetaData(Configurator configurator,
+                                 Map processedTypeMap)
+            throws MetaDataPopulateException {
+        this.name = this.propertyDescriptor.getName();
+        this.getterMethod = this.propertyDescriptor.getReadMethod();
+        this.setterMethod = this.propertyDescriptor.getWriteMethod();
+
+    }
+
+
+    /**
+     * this method sets the XMLElement correctly. this method should be called only
+     * if this is not processed
+     *
+     * @param configurator
+     * @param schemaMap
+     * @throws org.apache.axis2.rmi.exception.SchemaGenerationException
+     *
+     */
+    public void generateSchema(Configurator configurator,
+                               Map schemaMap)
+            throws SchemaGenerationException {
+        // here we have to send the XmlElement correctly
+        this.isSchemaGenerated = true;
+
+        if (!this.type.isSchemaGenerated()) {
+            this.type.generateSchema(configurator, schemaMap);
+        }
+
+    }
+
+    public PropertyDescriptor getPropertyDescriptor() {
+        return propertyDescriptor;
+    }
+
+    public void setPropertyDescriptor(PropertyDescriptor propertyDescriptor) {
+        this.propertyDescriptor = propertyDescriptor;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Method getGetterMethod() {
+        return getterMethod;
+    }
+
+    public void setGetterMethod(Method getterMethod) {
+        this.getterMethod = getterMethod;
+    }
+
+    public Method getSetterMethod() {
+        return setterMethod;
+    }
+
+    public void setSetterMethod(Method setterMethod) {
+        this.setterMethod = setterMethod;
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+    public void setType(Type type) {
+        this.type = type;
+    }
+
+    public boolean isSchemaGenerated() {
+        return isSchemaGenerated;
+    }
+
+    public void setSchemaGenerated(boolean schemaGenerated) {
+        isSchemaGenerated = schemaGenerated;
+    }
+
+    public String getNamespace() {
+        return namespace;
+    }
+
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
+    }
+
+}

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Operation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Operation.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Operation.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Operation.java Mon Aug 20 20:06:10 2007
@@ -19,6 +19,8 @@
 import org.apache.axis2.rmi.metadata.xml.XmlSchema;
 import org.apache.axis2.rmi.metadata.xml.XmlImport;
 import org.apache.axis2.rmi.metadata.xml.XmlType;
+import org.apache.axis2.rmi.metadata.xml.impl.XmlTypeImpl;
+import org.apache.axis2.rmi.metadata.xml.impl.XmlElementImpl;
 import org.apache.axis2.rmi.Configurator;
 import org.apache.axis2.rmi.util.Constants;
 import org.apache.axis2.rmi.exception.MetaDataPopulateException;
@@ -150,14 +152,14 @@
         if (!configurator.isBare()) {
 
             // generating the input element
-            this.inputElement = new XmlElement(false);
+            this.inputElement = new XmlElementImpl(false);
             this.inputElement.setName(this.name);
             this.inputElement.setNamespace(this.namespace);
             this.inputElement.setTopElement(true);
             xmlSchema.addElement(this.inputElement);
 
             // set the complex type for this element
-            XmlType xmlType = new XmlType();
+            XmlType xmlType = new XmlTypeImpl();
             xmlType.setAnonymous(true);
             xmlType.setSimpleType(false);
 
@@ -183,13 +185,13 @@
             this.inputElement.setType(xmlType);
 
             // generate the output Element
-            this.outPutElement = new XmlElement(false);
+            this.outPutElement = new XmlElementImpl(false);
             this.outPutElement.setName(this.name + "Response");
             this.outPutElement.setNamespace(this.namespace);
             this.outPutElement.setTopElement(true);
             xmlSchema.addElement(this.outPutElement);
 
-            xmlType = new XmlType();
+            xmlType = new XmlTypeImpl();
             xmlType.setAnonymous(true);
             xmlType.setSimpleType(false);
             if (this.outputParameter != null) {

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Parameter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Parameter.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Parameter.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Parameter.java Mon Aug 20 20:06:10 2007
@@ -16,15 +16,20 @@
 package org.apache.axis2.rmi.metadata;
 
 import org.apache.axis2.rmi.Configurator;
+import org.apache.axis2.rmi.databind.RMIBean;
 import org.apache.axis2.rmi.types.MapType;
 import org.apache.axis2.rmi.util.Util;
 import org.apache.axis2.rmi.util.Constants;
 import org.apache.axis2.rmi.metadata.xml.XmlElement;
+import org.apache.axis2.rmi.metadata.xml.impl.XmlElementImpl;
+import org.apache.axis2.rmi.metadata.impl.TypeImpl;
 import org.apache.axis2.rmi.exception.MetaDataPopulateException;
 import org.apache.axis2.rmi.exception.SchemaGenerationException;
 
 import java.util.Map;
 import java.util.List;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
 
 /**
  * this class is used to keep the Parameter details of a java method
@@ -86,7 +91,7 @@
 
 
     public Parameter(Class javaClass, String name) {
-        this(javaClass,name,null);
+        this(javaClass, name, null);
     }
 
     public void populateMetaData(Configurator configurator,
@@ -118,8 +123,29 @@
             if (processedTypeMap.containsKey(baseClass)) {
                 // i.e we have already process this type
                 this.type = (Type) processedTypeMap.get(baseClass);
+            } else if (RMIBean.class.isAssignableFrom(baseClass)) {
+                // if this bean is an RMIBean we have to use the type return
+                // from that bean.
+                try {
+                    Method getBeanClassMethod = baseClass.getMethod("getBeanClass", new Class[]{});
+                    Class rmiBeanType = (Class) getBeanClassMethod.invoke(null, new Object[]{});
+                    if (rmiBeanType != null) {
+                        this.type = (Type) rmiBeanType.newInstance();
+                        processedTypeMap.put(baseClass, this.type);
+                        this.type.populateMetaData(configurator, processedTypeMap);
+                    } else {
+                        throw new MetaDataPopulateException("there is no type class for rmi class "
+                                + baseClass.getName());
+                    }
+                } catch (NoSuchMethodException e) {
+                    throw new MetaDataPopulateException("No getBeanClass method is not defined for " +
+                            " rmi bean class " + baseClass.getName());
+                } catch (InvocationTargetException e) {
+                    throw new MetaDataPopulateException("No getBeanClass method is not defined for " +
+                            " rmi bean class " + baseClass.getName());
+                }
             } else {
-                this.type = new Type(baseClass);
+                this.type = new TypeImpl(baseClass);
                 // we have to do this before calling to populate meta data
                 // to avoid cirecular references
                 processedTypeMap.put(baseClass, this.type);
@@ -147,14 +173,16 @@
                                Map schemaMap)
             throws SchemaGenerationException {
         // here we have to send the XmlElement correctly
+
         this.isSchemaGenerated = true;
-        this.element = new XmlElement(!this.isArray && this.type.getJavaClass().isPrimitive());
-        this.element.setName(this.name);
-        this.element.setNamespace(this.namespace);
 
         if (!this.type.isSchemaGenerated()) {
             this.type.generateSchema(configurator, schemaMap);
         }
+
+        this.element = new XmlElementImpl(!this.isArray && this.type.getJavaClass().isPrimitive());
+        this.element.setName(this.name);
+        this.element.setNamespace(this.namespace);
         this.element.setType(this.type.getXmlType());
         this.element.setArray(this.isArray);
 

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Service.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Service.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Service.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Service.java Mon Aug 20 20:06:10 2007
@@ -20,6 +20,7 @@
 import org.apache.axis2.rmi.util.Constants;
 import org.apache.axis2.rmi.metadata.xml.XmlSchema;
 import org.apache.axis2.rmi.metadata.xml.XmlImport;
+import org.apache.axis2.rmi.metadata.impl.TypeImpl;
 import org.apache.axis2.rmi.exception.MetaDataPopulateException;
 import org.apache.axis2.rmi.exception.SchemaGenerationException;
 
@@ -125,7 +126,7 @@
         for (Iterator iter = this.configurator.getExtensionClasses().iterator(); iter.hasNext();) {
             extensionClass = (Class) iter.next();
             if (!this.processedTypeMap.containsKey(extensionClass)) {
-                extensionType = new Type(extensionClass);
+                extensionType = new TypeImpl(extensionClass);
                 this.processedTypeMap.put(extensionClass, extensionType);
                 extensionType.populateMetaData(this.configurator, this.processedTypeMap);
             }

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Type.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Type.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Type.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Type.java Mon Aug 20 20:06:10 2007
@@ -16,264 +16,68 @@
 package org.apache.axis2.rmi.metadata;
 
 import org.apache.axis2.rmi.Configurator;
-import org.apache.axis2.rmi.metadata.xml.XmlType;
-import org.apache.axis2.rmi.metadata.xml.XmlSchema;
-import org.apache.axis2.rmi.metadata.xml.XmlImport;
 import org.apache.axis2.rmi.exception.MetaDataPopulateException;
 import org.apache.axis2.rmi.exception.SchemaGenerationException;
-import org.apache.axis2.rmi.util.JavaTypeToQNameMap;
-import org.apache.axis2.rmi.util.Constants;
+import org.apache.axis2.rmi.metadata.xml.XmlType;
 
-import javax.xml.namespace.QName;
 import java.util.List;
-import java.util.ArrayList;
 import java.util.Map;
-import java.util.Iterator;
-import java.beans.BeanInfo;
-import java.beans.Introspector;
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
 
-public class Type {
+public interface Type {
 
     /**
-     * java class corresponds to this XmlType object
+     * popualate the meta data corresponding to this type
+     * @param configurator
      */
-    private Class javaClass;
+    public void populateMetaData(Configurator configurator, Map processedTypeMap) throws MetaDataPopulateException;
 
     /**
-     * list of attribute objects for this java class
+     * this method sets the xmlType correctly. this method should only be invoked
+     * if it has not already processed
+     * @param configurator
+     * @param schemaMap
      */
-    private List attributes;
 
-    /**
-     * name of the Type : class name
-     */
-    private String name;
+    public void generateSchema(Configurator configurator, Map schemaMap) throws SchemaGenerationException;
 
-    /**
-     * namespace of the type : depends on the package
-     */
-    private String namespace;
+    public void populateAllElementFields(List elementFieldsList);
 
-    /**
-     * parent type for this type
-     */
-    private Type parentType;
+    public void populateAllAttributeFields(List attributeFieldsList);
 
-    /**
-     * xml metadata type correponding to this type object
-     */
-    private XmlType xmlType;
+    public List getAllElementFields();
 
-    private boolean isSchemaGenerated;
+    public List getAllAttributeFields();
 
+    public boolean isSchemaGenerated();
 
-    public Type() {
-        this.attributes = new ArrayList();
-    }
+    public void setSchemaGenerated(boolean schemaGenerated);
 
-    public Type(Class javaClass) {
-        this();
-        this.javaClass = javaClass;
-    }
+    public Class getJavaClass();
 
-    /**
-     * popualate the meta data corresponding to this type
-     * @param configurator
-     */
-    public void populateMetaData(Configurator configurator,
-                                 Map processedTypeMap)
-            throws MetaDataPopulateException {
-        // java class should alrady have populated.
-
-        // if javaTypeToQNameMap contains this key then this is an either
-        // primitive type or a Simple known type. we don't have to populate
-        // the attribues
-        try {
-            if (!JavaTypeToQNameMap.containsKey(this.javaClass)) {
-                this.name = this.javaClass.getName();
-                this.name = this.name.substring(this.name.lastIndexOf(".") + 1);
-                this.namespace = configurator.getNamespace(this.javaClass.getPackage().getName());
-
-                Class superClass = this.javaClass.getSuperclass();
-
-                // if the supper class is Object class nothing to warry
-                if (!superClass.equals(Object.class) && !superClass.equals(Exception.class)) {
-                    // then this is an extension class and we have to processit
-                    if (!processedTypeMap.containsKey(superClass)) {
-                        Type superClassType = new Type(superClass);
-                        processedTypeMap.put(superClass, superClassType);
-                        superClassType.populateMetaData(configurator, processedTypeMap);
-                    }
-                    this.setParentType((Type) processedTypeMap.get(superClass));
-                }
-
-                // we need informatin only about this class
-                // supper class information is processed in the super class type
-                BeanInfo beanInfo = Introspector.getBeanInfo(this.javaClass, this.javaClass.getSuperclass());
-                PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
-                Attribute attribute;
-                for (int i = 0; i < propertyDescriptors.length; i++) {
-                    // remove the class descriptor
-                    attribute = new Attribute(propertyDescriptors[i], this.namespace);
-                    attribute.populateMetaData(configurator, processedTypeMap);
-                    this.attributes.add(attribute);
-                }
-            }
-        } catch (IntrospectionException e) {
-            throw new MetaDataPopulateException(
-                    "Error Occured while getting the Bean info of the class " + this.javaClass.getName(), e);
-        }
+    public void setJavaClass(Class javaClass);
 
-    }
+    public List getElementFields();
 
-    /**
-     * this method sets the xmlType correctly. this method should only be invoked
-     * if it has not already processed
-     * @param configurator
-     * @param schemaMap
-     */
+    public void setElementFields(List elementFields);
+
+    public String getName();
+
+    public void setName(String name);
+
+    public String getNamespace();
+
+    public void setNamespace(String namespace);
+
+    public XmlType getXmlType();
+
+    public void setXmlType(XmlType xmlType);
+
+    public Type getParentType();
+
+    public void setParentType(Type parentType);
+
+    public List getAttributeFields();
 
-    public void generateSchema(Configurator configurator,
-                               Map schemaMap)
-            throws SchemaGenerationException {
-
-        // here we have to populate the xmlType object properly
-        this.isSchemaGenerated = true;
-        if (JavaTypeToQNameMap.containsKey(this.javaClass)){
-            // i.e. this is a basic type
-            // no need to process or add this to schema list
-            this.xmlType = new XmlType(JavaTypeToQNameMap.getTypeQName(this.javaClass));
-            this.xmlType.setSimpleType(true);
-        } else {
-
-            // get the schema to add the complex type
-            if (schemaMap.get(this.namespace) == null){
-                // create a new namespace for this schema
-                schemaMap.put(this.namespace, new XmlSchema(this.namespace));
-            }
-            XmlSchema xmlSchema = (XmlSchema) schemaMap.get(this.namespace);
-
-            // we have to generate a complex type for this
-            this.xmlType = new XmlType(new QName(this.namespace,this.name));
-            this.xmlType.setSimpleType(false);
-
-             // set the parent type for this type
-            if (this.parentType != null){
-                Type parentType = this.parentType;
-                if (!parentType.isSchemaGenerated()){
-                    parentType.generateSchema(configurator,schemaMap);
-                }
-                this.xmlType.setParentType(parentType.getXmlType());
-                // import the complex type namespace if needed.
-                if (!xmlSchema.containsNamespace(this.xmlType.getParentType().getQname().getNamespaceURI())){
-                    // if the element namespace does not exists we have to add it
-                    if (!this.xmlType.getParentType().getQname().getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) {
-                        XmlImport xmlImport = new XmlImport(this.xmlType.getParentType().getQname().getNamespaceURI());
-                        xmlSchema.addImport(xmlImport);
-                    }
-                    xmlSchema.addNamespace(this.xmlType.getParentType().getQname().getNamespaceURI());
-                }
-
-            }
-
-            // add elements of the attributes
-            Attribute attribute;
-            for (Iterator iter = this.attributes.iterator();iter.hasNext();){
-                attribute = (Attribute) iter.next();
-                if (!attribute.isSchemaGenerated()){
-                    // if it is not already processed process it.
-                    attribute.generateSchema(configurator,schemaMap);
-                }
-                this.xmlType.addElement(attribute.getElement());
-                // we have to set the namespaces of these element complex types properly
-                QName elementTypeQName = attribute.getElement().getType().getQname();
-                if (!xmlSchema.containsNamespace(elementTypeQName.getNamespaceURI())){
-                    // if the element namespace does not exists we have to add it
-                    if (!elementTypeQName.getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) {
-                        XmlImport xmlImport = new XmlImport(elementTypeQName.getNamespaceURI());
-                        xmlSchema.addImport(xmlImport);
-                    }
-                    xmlSchema.addNamespace(elementTypeQName.getNamespaceURI());
-                }
-
-            }
-            // finally add this complex type to schema map
-            xmlSchema.addComplexType(this.xmlType);
-
-        }
-
-    }
-
-    public void populateAllAttributes(List attributesList){
-        // we have to first add the parent details to keep the order.
-        if (this.parentType != null){
-            this.parentType.populateAllAttributes(attributesList);
-        }
-        attributesList.addAll(this.attributes);
-    }
-
-    public List getAllAttributes(){
-        List allAttributesList = new ArrayList();
-        populateAllAttributes(allAttributesList);
-        return allAttributesList;
-    }
-
-    public boolean isSchemaGenerated() {
-        return isSchemaGenerated;
-    }
-
-    public void setSchemaGenerated(boolean schemaGenerated) {
-        isSchemaGenerated = schemaGenerated;
-    }
-
-    public Class getJavaClass() {
-        return javaClass;
-    }
-
-    public void setJavaClass(Class javaClass) {
-        this.javaClass = javaClass;
-    }
-
-    public List getAttributes() {
-        return attributes;
-    }
-
-    public void setAttributes(List attributes) {
-        this.attributes = attributes;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getNamespace() {
-        return namespace;
-    }
-
-    public void setNamespace(String namespace) {
-        this.namespace = namespace;
-    }
-
-    public XmlType getXmlType() {
-        return xmlType;
-    }
-
-    public void setXmlType(XmlType xmlType) {
-        this.xmlType = xmlType;
-    }
-
-    public Type getParentType() {
-        return parentType;
-    }
-
-    public void setParentType(Type parentType) {
-        this.parentType = parentType;
-    }
+    public void setAttributeFields(List attributeFields);
 
 }

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/impl/TypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/impl/TypeImpl.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/impl/TypeImpl.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/impl/TypeImpl.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,354 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.metadata.impl;
+
+import org.apache.axis2.rmi.metadata.xml.XmlType;
+import org.apache.axis2.rmi.metadata.xml.XmlSchema;
+import org.apache.axis2.rmi.metadata.xml.XmlImport;
+import org.apache.axis2.rmi.metadata.xml.impl.XmlTypeImpl;
+import org.apache.axis2.rmi.metadata.Type;
+import org.apache.axis2.rmi.metadata.ElementField;
+import org.apache.axis2.rmi.metadata.Field;
+import org.apache.axis2.rmi.metadata.AttributeField;
+import org.apache.axis2.rmi.Configurator;
+import org.apache.axis2.rmi.config.ClassInfo;
+import org.apache.axis2.rmi.config.FieldInfo;
+import org.apache.axis2.rmi.util.JavaTypeToQNameMap;
+import org.apache.axis2.rmi.util.Constants;
+import org.apache.axis2.rmi.exception.MetaDataPopulateException;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+
+import javax.xml.namespace.QName;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Iterator;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.IntrospectionException;
+
+
+public class TypeImpl implements Type {
+    /**
+     * java class corresponds to this XmlType object
+     */
+    private Class javaClass;
+
+    /**
+     * list of element Field objects for this java class
+     */
+    private List elementFields;
+
+    /**
+     * list of attribute Field objects for this java class
+     */
+    private List attributeFields;
+
+    /**
+     * name of the Type : class name
+     */
+    private String name;
+
+    /**
+     * namespace of the type : depends on the package
+     */
+    private String namespace;
+
+    /**
+     * parent type for this type
+     */
+    private Type parentType;
+
+    /**
+     * xml metadata type correponding to this type object
+     */
+    private XmlType xmlType;
+
+    private boolean isSchemaGenerated;
+
+
+    public TypeImpl() {
+        this.elementFields = new ArrayList();
+        this.attributeFields = new ArrayList();
+    }
+
+    public TypeImpl(Class javaClass) {
+        this();
+        this.javaClass = javaClass;
+    }
+
+    /**
+     * popualate the meta data corresponding to this type
+     * @param configurator
+     */
+    public void populateMetaData(Configurator configurator,
+                                 Map processedTypeMap)
+            throws MetaDataPopulateException {
+        // java class should alrady have populated.
+
+        // if javaTypeToQNameMap contains this key then this is an either
+        // primitive type or a Simple known type. we don't have to populate
+        // the attribues
+        try {
+            if (!JavaTypeToQNameMap.containsKey(this.javaClass)) {
+                this.name = this.javaClass.getName();
+                this.name = this.name.substring(this.name.lastIndexOf(".") + 1);
+                this.namespace = configurator.getNamespace(this.javaClass.getPackage().getName());
+
+                Class superClass = this.javaClass.getSuperclass();
+
+                // if the supper class is Object class nothing to warry
+                if (!superClass.equals(Object.class) && !superClass.equals(Exception.class)) {
+                    // then this is an extension class and we have to processit
+                    if (!processedTypeMap.containsKey(superClass)) {
+                        Type superClassType = new TypeImpl(superClass);
+                        processedTypeMap.put(superClass, superClassType);
+                        superClassType.populateMetaData(configurator, processedTypeMap);
+                    }
+                    this.setParentType((Type) processedTypeMap.get(superClass));
+                }
+
+                // we need informatin only about this class
+                // supper class information is processed in the super class type
+                ClassInfo customClassInfo = configurator.getClassInfo(this.javaClass);
+                BeanInfo beanInfo = Introspector.getBeanInfo(this.javaClass, this.javaClass.getSuperclass());
+                PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+                Field field;
+                for (int i = 0; i < propertyDescriptors.length; i++) {
+                    // remove the class descriptor
+                    if ((customClassInfo != null) &&
+                            (customClassInfo.getFieldInfo(propertyDescriptors[i].getName()) != null)) {
+                        FieldInfo fieldInfo = customClassInfo.getFieldInfo(propertyDescriptors[i].getName());
+                        if (fieldInfo.isElement()) {
+                            field = new ElementField(propertyDescriptors[i], this.namespace);
+                            field.populateMetaData(configurator, processedTypeMap);
+                            this.elementFields.add(field);
+                        } else {
+                            // we use the attribute name space as null
+                            field = new AttributeField(propertyDescriptors[i], null);
+                            field.populateMetaData(configurator, processedTypeMap);
+                            this.attributeFields.add(field);
+                        }
+                        if (fieldInfo.getXmlName() != null) {
+                            field.setName(fieldInfo.getXmlName());
+                        }
+                    } else {
+                        field = new ElementField(propertyDescriptors[i], this.namespace);
+                        field.populateMetaData(configurator, processedTypeMap);
+                        this.elementFields.add(field);
+                    }
+                }
+            }
+        } catch (IntrospectionException e) {
+            throw new MetaDataPopulateException(
+                    "Error Occured while getting the Bean info of the class " + this.javaClass.getName(), e);
+        }
+
+    }
+
+    /**
+     * this method sets the xmlType correctly. this method should only be invoked
+     * if it has not already processed
+     * @param configurator
+     * @param schemaMap
+     */
+
+    public void generateSchema(Configurator configurator,
+                               Map schemaMap)
+            throws SchemaGenerationException {
+
+        // here we have to populate the xmlType object properly
+        this.isSchemaGenerated = true;
+        if (JavaTypeToQNameMap.containsKey(this.javaClass)){
+            // i.e. this is a basic type
+            // no need to process or add this to schema list
+            this.xmlType = new XmlTypeImpl(JavaTypeToQNameMap.getTypeQName(this.javaClass));
+            this.xmlType.setSimpleType(true);
+        } else {
+
+            // get the schema to add the complex type
+            if (schemaMap.get(this.namespace) == null){
+                // create a new namespace for this schema
+                schemaMap.put(this.namespace, new XmlSchema(this.namespace));
+            }
+            XmlSchema xmlSchema = (XmlSchema) schemaMap.get(this.namespace);
+
+            // we have to generate a complex type for this
+            this.xmlType = new XmlTypeImpl(new QName(this.namespace,this.name));
+            this.xmlType.setSimpleType(false);
+
+             // set the parent type for this type
+            if (this.parentType != null){
+                Type parentType = this.parentType;
+                if (!parentType.isSchemaGenerated()){
+                    parentType.generateSchema(configurator,schemaMap);
+                }
+                this.xmlType.setParentType(parentType.getXmlType());
+                // import the complex type namespace if needed.
+                if (!xmlSchema.containsNamespace(this.xmlType.getParentType().getQname().getNamespaceURI())){
+                    // if the element namespace does not exists we have to add it
+                    if (!this.xmlType.getParentType().getQname().getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) {
+                        XmlImport xmlImport = new XmlImport(this.xmlType.getParentType().getQname().getNamespaceURI());
+                        xmlSchema.addImport(xmlImport);
+                    }
+                    xmlSchema.addNamespace(this.xmlType.getParentType().getQname().getNamespaceURI());
+                }
+
+            }
+
+            // add elements of the elementFields
+            ElementField elementField;
+            for (Iterator iter = this.elementFields.iterator();iter.hasNext();){
+                elementField = (ElementField) iter.next();
+                if (!elementField.isSchemaGenerated()){
+                    // if it is not already processed process it.
+                    elementField.generateSchema(configurator,schemaMap);
+                }
+                this.xmlType.addElement(elementField.getElement());
+                // we have to set the namespaces of these element complex types properly
+                QName elementTypeQName = elementField.getElement().getType().getQname();
+                if (!xmlSchema.containsNamespace(elementTypeQName.getNamespaceURI())){
+                    // if the element namespace does not exists we have to add it
+                    if (!elementTypeQName.getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) {
+                        XmlImport xmlImport = new XmlImport(elementTypeQName.getNamespaceURI());
+                        xmlSchema.addImport(xmlImport);
+                    }
+                    xmlSchema.addNamespace(elementTypeQName.getNamespaceURI());
+                }
+
+            }
+
+            //add attribute fields
+            AttributeField attributeField;
+            for (Iterator iter = this.attributeFields.iterator(); iter.hasNext();){
+                attributeField = (AttributeField) iter.next();
+                if (!attributeField.isSchemaGenerated()){
+                    // if it is not already processed process it.
+                    attributeField.generateSchema(configurator,schemaMap);
+                }
+                this.xmlType.addAttribute(attributeField.getAttribute());
+                // we have to set the namespaces of these element complex types properly
+                QName attributeTypeQName = attributeField.getAttribute().getType().getQname();
+                if (!xmlSchema.containsNamespace(attributeTypeQName.getNamespaceURI())){
+                    // if the element namespace does not exists we have to add it
+                    if (!attributeTypeQName.getNamespaceURI().equals(Constants.URI_2001_SCHEMA_XSD)) {
+                        XmlImport xmlImport = new XmlImport(attributeTypeQName.getNamespaceURI());
+                        xmlSchema.addImport(xmlImport);
+                    }
+                    xmlSchema.addNamespace(attributeTypeQName.getNamespaceURI());
+                }
+
+            }
+            // finally add this complex type to schema map
+            xmlSchema.addComplexType(this.xmlType);
+
+        }
+
+    }
+
+    public void populateAllElementFields(List elementFieldsList){
+        // we have to first add the parent details to keep the order.
+        if (this.parentType != null){
+            this.parentType.populateAllElementFields(elementFieldsList);
+        }
+        elementFieldsList.addAll(this.elementFields);
+    }
+
+    public void populateAllAttributeFields(List attributeFieldsList) {
+        // we have to first add the parent details to keep the order.
+        if (this.parentType != null){
+            this.parentType.populateAllAttributeFields(attributeFieldsList);
+        }
+        attributeFieldsList.addAll(this.attributeFields);
+    }
+
+    public List getAllElementFields(){
+        List allElementsList = new ArrayList();
+        populateAllElementFields(allElementsList);
+        return allElementsList;
+    }
+
+    public List getAllAttributeFields() {
+        List allAttributesList = new ArrayList();
+        populateAllAttributeFields(allAttributesList);
+        return allAttributesList;
+    }
+
+    public boolean isSchemaGenerated() {
+        return isSchemaGenerated;
+    }
+
+    public void setSchemaGenerated(boolean schemaGenerated) {
+        isSchemaGenerated = schemaGenerated;
+    }
+
+    public Class getJavaClass() {
+        return javaClass;
+    }
+
+    public void setJavaClass(Class javaClass) {
+        this.javaClass = javaClass;
+    }
+
+    public List getElementFields() {
+        return elementFields;
+    }
+
+    public void setElementFields(List elementFields) {
+        this.elementFields = elementFields;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getNamespace() {
+        return namespace;
+    }
+
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
+    }
+
+    public XmlType getXmlType() {
+        return xmlType;
+    }
+
+    public void setXmlType(XmlType xmlType) {
+        this.xmlType = xmlType;
+    }
+
+    public Type getParentType() {
+        return parentType;
+    }
+
+    public void setParentType(Type parentType) {
+        this.parentType = parentType;
+    }
+
+    public List getAttributeFields() {
+        return attributeFields;
+    }
+
+    public void setAttributeFields(List attributeFields) {
+        this.attributeFields = attributeFields;
+    }
+}

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/AbstractXmlType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/AbstractXmlType.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/AbstractXmlType.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/AbstractXmlType.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.metadata.xml;
+
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+import java.util.List;
+import java.util.Map;
+
+
+public abstract class AbstractXmlType implements XmlType{
+
+    /**
+     * Qualified name of the xmlType
+     */
+    protected QName qname;
+
+    /**
+     * is this an anAnonymous type this case qname can be null
+     */
+    protected boolean isAnonymous;
+
+    /**
+     * is this is a basic type
+     */
+    protected boolean isSimpleType;
+
+    /**
+     * list of child elements
+     */
+    protected List elements;
+
+    /**
+     * list of child attributes
+     */
+    protected List attributes;
+
+    /**
+     * complex type element for this XmlType
+     */
+    protected Element typeElement;
+
+    /**
+     * parent type for this xml type if it is an extension
+     */
+    protected XmlType parentType;
+
+    public void addElement(XmlElement xmlElement) {
+        this.elements.add(xmlElement);
+    }
+
+    public void addAttribute(XmlAttribute xmlAttribute) {
+        this.attributes.add(xmlAttribute);
+    }
+
+    /**
+     * this generates the complex type only if it is annonymous and
+     * is not a simple type
+     *
+     * @param document
+     * @param namespacesToPrefixMap
+     * @throws org.apache.axis2.rmi.exception.SchemaGenerationException
+     *
+     */
+    public abstract void generateWSDLSchema(Document document,
+                                   Map namespacesToPrefixMap)
+            throws SchemaGenerationException;
+
+    public QName getQname() {
+        return qname;
+    }
+
+    public void setQname(QName qname) {
+        this.qname = qname;
+    }
+
+    public boolean isAnonymous() {
+        return isAnonymous;
+    }
+
+    public void setAnonymous(boolean anonymous) {
+        isAnonymous = anonymous;
+    }
+
+    public boolean isSimpleType() {
+        return isSimpleType;
+    }
+
+    public void setSimpleType(boolean simpleType) {
+        isSimpleType = simpleType;
+    }
+
+    public List getElements() {
+        return elements;
+    }
+
+    public void setElements(List elements) {
+        this.elements = elements;
+    }
+
+    public Element getTypeElement() {
+        return typeElement;
+    }
+
+    public void setTypeElement(Element typeElement) {
+        this.typeElement = typeElement;
+    }
+
+    public XmlType getParentType() {
+        return parentType;
+    }
+
+    public void setParentType(XmlType parentType) {
+        this.parentType = parentType;
+    }
+
+    public List getAttributes() {
+        return attributes;
+    }
+
+    public void setAttributes(List attributes) {
+        this.attributes = attributes;
+    }
+}

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlAttribute.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlAttribute.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlAttribute.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.metadata.xml;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+
+import java.util.Map;
+
+/**
+ * this class represents and xml attribute
+ */
+public interface XmlAttribute {
+
+    public void generateWSDLSchema(Document document, Map namespacesToPrefixMap) throws SchemaGenerationException;
+
+    public String getNamespace();
+
+    public void setNamespace(String namespace);
+
+    public boolean isRequired();
+
+    public void setRequired(boolean required);
+
+    public XmlType getType();
+
+    public void setType(XmlType type);
+
+    public String getName();
+
+    public void setName(String name);
+
+    public Element getAttribute();
+
+    public void setAttribute(Element attribute);
+
+}

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlElement.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlElement.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlElement.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlElement.java Mon Aug 20 20:06:10 2007
@@ -22,169 +22,40 @@
 
 import java.util.Map;
 
-public class XmlElement {
+public interface XmlElement {
 
-    /**
-     * namespace for this element if it is an top level element
-     */
-    private String namespace;
-
-    /**
-     * name of this element
-     */
-    private String name;
-
-    /**
-     * is this element nillable
-     */
-    private boolean isNillable;
-
-    /**
-     * is minOccures zero for this element
-     */
-    private boolean isMinOccurs0;
-
-    /**
-     * is Array
-     */
-    private boolean isArray;
-
-    /**
-     * if this is an schema top level element
-     */
-    private boolean isTopElement;
-
-    /**
-     * xmlType of this element
-     */
-    private XmlType type;
-
-    /**
-     * schema element for this element
-     */
-    private Element element;
-
-    public XmlElement(boolean isPrimitiveType) {
-        // set the nillable value to true
-        this.isNillable = !isPrimitiveType;
-        this.isMinOccurs0 = !isPrimitiveType;
-    }
-
-    public void generateWSDLSchema(Document document,
-                                   Map namespacesToPrefixMap)
-            throws SchemaGenerationException {
-        String xsdPrefix = (String) namespacesToPrefixMap.get(Constants.URI_2001_SCHEMA_XSD);
-        this.element = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "element");
-        this.element.setPrefix(xsdPrefix);
-        this.element.setAttribute("name", this.name);
-
-
-        if (this.isArray && !this.isTopElement) {
-            this.element.setAttribute("maxOccurs", "unbounded");
-        }
-
-        if (this.namespace == null){
-            this.element.setAttribute("form", "unqualified");
-        }
-
-        // setting the type
-        if (type == null) {
-            // i.e this is corresponds to an void type so generate a empty annony mous complex type
-            Element complexElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "complexType");
-            complexElement.setPrefix(xsdPrefix);
-
-            Element sequenceElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "sequence");
-            sequenceElement.setPrefix(xsdPrefix);
-            complexElement.appendChild(sequenceElement);
-            this.element.appendChild(complexElement);
-        } else if (type.isSimpleType()) {
-            // this is an simple type element
-            this.element.setAttribute("type", xsdPrefix + ":" + type.getQname().getLocalPart());
-            if (this.isNillable) {
-                this.element.setAttribute("nillable", "true");
-            }
-            if (this.isMinOccurs0 && !this.isTopElement){
-                this.element.setAttribute("minOccurs","0");
-            }
-        } else if (!type.isAnonymous()) {
-            String prefix = (String) namespacesToPrefixMap.get(type.getQname().getNamespaceURI());
-            this.element.setAttribute("type", prefix + ":" + type.getQname().getLocalPart());
-            if (this.isNillable) {
-                this.element.setAttribute("nillable", "true");
-            }
-            if (this.isMinOccurs0 && !this.isTopElement){
-                this.element.setAttribute("minOccurs","0");
-            }
-        } else {
-            // i.e this is and annonymous complex type
-            type.generateWSDLSchema(document, namespacesToPrefixMap);
-            this.element.appendChild(type.getComplexElement());
-        }
-
-    }
-
-    public String getNamespace() {
-        return namespace;
-    }
-
-    public void setNamespace(String namespace) {
-        this.namespace = namespace;
-    }
-
-    public boolean isNillable() {
-        return isNillable;
-    }
-
-    public void setNillable(boolean nillable) {
-        isNillable = nillable;
-    }
-
-    public boolean isArray() {
-        return isArray;
-    }
-
-    public void setArray(boolean array) {
-        isArray = array;
-    }
-
-    public boolean isTopElement() {
-        return isTopElement;
-    }
-
-    public void setTopElement(boolean topElement) {
-        isTopElement = topElement;
-    }
-
-    public XmlType getType() {
-        return type;
-    }
-
-    public void setType(XmlType type) {
-        this.type = type;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public Element getElement() {
-        return element;
-    }
-
-    public void setElement(Element element) {
-        this.element = element;
-    }
-
-    public boolean isMinOccurs0() {
-        return isMinOccurs0;
-    }
-
-    public void setMinOccurs0(boolean minOccurs0) {
-        isMinOccurs0 = minOccurs0;
-    }
+    public void generateWSDLSchema(Document document, Map namespacesToPrefixMap) throws SchemaGenerationException;
+
+    public String getNamespace();
+
+    public void setNamespace(String namespace);
+
+    public boolean isNillable();
+
+    public void setNillable(boolean nillable);
+
+    public boolean isArray();
+
+    public void setArray(boolean array);
+
+    public boolean isTopElement();
+
+    public void setTopElement(boolean topElement);
+
+    public XmlType getType();
+
+    public void setType(XmlType type);
+
+    public String getName();
+
+    public void setName(String name);
+
+    public Element getElement();
+
+    public void setElement(Element element);
+
+    public boolean isMinOccurs0();
+
+    public void setMinOccurs0(boolean minOccurs0);
 
 }

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlSchema.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlSchema.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlSchema.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlSchema.java Mon Aug 20 20:06:10 2007
@@ -131,7 +131,7 @@
                  xmlType = (XmlType) iter.next();
                  if (!xmlType.isAnonymous() && !xmlType.isSimpleType()){
                      xmlType.generateWSDLSchema(document, namespacesToPrefixMap);
-                     schemaElement.appendChild(xmlType.getComplexElement());
+                     schemaElement.appendChild(xmlType.getTypeElement());
                  }
             }
 

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlType.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlType.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlType.java Mon Aug 20 20:06:10 2007
@@ -27,156 +27,47 @@
 import java.util.Iterator;
 
 
-public class XmlType {
+public interface XmlType {
 
-    /**
-     * Qualified name of the xmlType
-     */
-    private QName qname;
+    public void addElement(XmlElement xmlElement);
 
-    /**
-     * is this an anAnonymous type this case qname can be null
-     */
-    private boolean isAnonymous;
+    public void addAttribute(XmlAttribute xmlAttribute);
 
     /**
-     *  is this is a basic type
+     * this generates the complex type only if it is annonymous and
+     * is not a simple type
+     * @param document
+     * @param namespacesToPrefixMap
+     * @throws SchemaGenerationException
      */
-    private boolean isSimpleType;
+    public void generateWSDLSchema(Document document, Map namespacesToPrefixMap) throws SchemaGenerationException;
 
-    /**
-     * list of child elements
-     */
-    private List elements;
+    public QName getQname();
 
-    /**
-     * complex type element for this XmlType
-     */
-    private Element complexElement;
+    public void setQname(QName qname);
 
-    /**
-     * parent type for this xml type if it is an extension
-     *
-     */
-    private XmlType parentType;
+    public boolean isAnonymous();
 
+    public void setAnonymous(boolean anonymous);
 
-    public void addElement(XmlElement xmlElement){
-        this.elements.add(xmlElement);
-    }
+    public boolean isSimpleType();
 
-    /**
-     * this generates the complex type only if it is annonymous and
-     * is not a simple type
-     * @param document
-     * @param namespacesToPrefixMap
-     * @throws SchemaGenerationException
-     */
-    public void generateWSDLSchema(Document document,
-                                   Map namespacesToPrefixMap)
-                                   throws SchemaGenerationException {
-        // here we have to generate the complex type element for this xmlType
-        if (!this.isSimpleType){
-            String xsdPrefix = (String) namespacesToPrefixMap.get(Constants.URI_2001_SCHEMA_XSD);
-            this.complexElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD,"complexType");
-            this.complexElement.setPrefix(xsdPrefix);
-            if (!this.isAnonymous){
-               this.complexElement.setAttribute("name", this.qname.getLocalPart());
-            }
-
-            Element sequenceElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD,"sequence");
-            sequenceElement.setPrefix(xsdPrefix);
-
-            // set the extension details if there are
-            if (this.parentType != null){
-
-                // i.e this is an extension type
-                Element complexContent = document.createElementNS(Constants.URI_2001_SCHEMA_XSD,"complexContent");
-                complexContent.setPrefix(xsdPrefix);
-                this.complexElement.appendChild(complexContent);
-
-                Element extension = document.createElementNS(Constants.URI_2001_SCHEMA_XSD,"extension");
-                extension.setPrefix(xsdPrefix);
-                complexContent.appendChild(extension);
-
-                String extensionPrefix =
-                        (String) namespacesToPrefixMap.get(this.parentType.getQname().getNamespaceURI());
-                String localPart = this.parentType.getQname().getLocalPart();
-                if ((extensionPrefix == null) || extensionPrefix.equals("")){
-                    extension.setAttribute("base",localPart);
-                } else {
-                    extension.setAttribute("base",extensionPrefix + ":" + localPart);
-                }
-               extension.appendChild(sequenceElement);
-            } else {
-               this.complexElement.appendChild(sequenceElement);
-            }
-
-            // add the other element children
-            XmlElement xmlElement;
-            for (Iterator iter = this.elements.iterator();iter.hasNext();){
-                xmlElement = (XmlElement) iter.next();
-                xmlElement.generateWSDLSchema(document,namespacesToPrefixMap);
-                sequenceElement.appendChild(xmlElement.getElement());
-            }
-        }
-    }
-
-    public XmlType() {
-        this.elements = new ArrayList();
-    }
-
-    public XmlType(QName qname) {
-        this();
-        this.qname = qname;
-    }
-
-    public QName getQname() {
-        return qname;
-    }
-
-    public void setQname(QName qname) {
-        this.qname = qname;
-    }
-
-    public boolean isAnonymous() {
-        return isAnonymous;
-    }
-
-    public void setAnonymous(boolean anonymous) {
-        isAnonymous = anonymous;
-    }
-
-    public boolean isSimpleType() {
-        return isSimpleType;
-    }
-
-    public void setSimpleType(boolean simpleType) {
-        isSimpleType = simpleType;
-    }
-
-    public List getElements() {
-        return elements;
-    }
-
-    public void setElements(List elements) {
-        this.elements = elements;
-    }
-
-    public Element getComplexElement() {
-        return complexElement;
-    }
-
-    public void setComplexElement(Element complexElement) {
-        this.complexElement = complexElement;
-    }
-
-    public XmlType getParentType() {
-        return parentType;
-    }
-
-    public void setParentType(XmlType parentType) {
-        this.parentType = parentType;
-    }
+    public void setSimpleType(boolean simpleType);
+
+    public List getElements();
+
+    public void setElements(List elements);
+
+    public Element getTypeElement();
+
+    public void setTypeElement(Element typeElement);
+
+    public XmlType getParentType();
+
+    public void setParentType(XmlType parentType);
+
+    public List getAttributes();
 
+    public void setAttributes(List attributes);
+    
 }

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlAttributeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlAttributeImpl.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlAttributeImpl.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlAttributeImpl.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.metadata.xml.impl;
+
+import org.apache.axis2.rmi.metadata.xml.XmlType;
+import org.apache.axis2.rmi.metadata.xml.XmlAttribute;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+import org.apache.axis2.rmi.util.Constants;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+
+import java.util.Map;
+
+public class XmlAttributeImpl implements XmlAttribute {
+    /**
+     * namespace for this attribute if it is an top level attribute
+     */
+    private String namespace;
+
+    /**
+     * name of this attribute
+     */
+    private String name;
+
+    /**
+     * is this attribute nillable
+     */
+    private boolean isRequired;
+
+    /**
+     * xmlType of this attribute
+     */
+    private XmlType type;
+
+    /**
+     * schema attribute for this attribute
+     */
+    private Element attribute;
+
+    public XmlAttributeImpl(boolean isPrimitive) {
+        // set the nillable value to true
+        this.isRequired = isPrimitive;
+    }
+
+    public void generateWSDLSchema(Document document,
+                                   Map namespacesToPrefixMap)
+            throws SchemaGenerationException {
+        String xsdPrefix = (String) namespacesToPrefixMap.get(Constants.URI_2001_SCHEMA_XSD);
+        this.attribute = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "attribute");
+        this.attribute.setPrefix(xsdPrefix);
+        this.attribute.setAttribute("name", this.name);
+
+
+        if (this.isRequired) {
+            this.attribute.setAttribute("use", "required");
+        }
+
+        if (this.type != null){
+            if (type.isSimpleType()){
+                this.attribute.setAttribute("type", xsdPrefix + ":" + type.getQname().getLocalPart());
+            } else {
+                throw new SchemaGenerationException("Attribute type must be a simple type");
+            }
+        } else {
+            throw new SchemaGenerationException("Type can not be null for an attribute");
+        }
+
+    }
+
+    public String getNamespace() {
+        return namespace;
+    }
+
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
+    }
+
+    public boolean isRequired() {
+        return isRequired;
+    }
+
+    public void setRequired(boolean required) {
+        isRequired = required;
+    }
+
+    public XmlType getType() {
+        return type;
+    }
+
+    public void setType(XmlType type) {
+        this.type = type;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Element getAttribute() {
+        return attribute;
+    }
+
+    public void setAttribute(Element attribute) {
+        this.attribute = attribute;
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlElementImpl.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlElementImpl.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlElementImpl.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.metadata.xml.impl;
+
+import org.apache.axis2.rmi.metadata.xml.XmlType;
+import org.apache.axis2.rmi.metadata.xml.XmlElement;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+import org.apache.axis2.rmi.util.Constants;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+
+import java.util.Map;
+
+
+public class XmlElementImpl implements XmlElement {
+    /**
+     * namespace for this element if it is an top level element
+     */
+    private String namespace;
+
+    /**
+     * name of this element
+     */
+    private String name;
+
+    /**
+     * is this element nillable
+     */
+    private boolean isNillable;
+
+    /**
+     * is minOccures zero for this element
+     */
+    private boolean isMinOccurs0;
+
+    /**
+     * is Array
+     */
+    private boolean isArray;
+
+    /**
+     * if this is an schema top level element
+     */
+    private boolean isTopElement;
+
+    /**
+     * xmlType of this element
+     */
+    private XmlType type;
+
+    /**
+     * schema element for this element
+     */
+    private Element element;
+
+    public XmlElementImpl(boolean isPrimitiveType) {
+        // set the nillable value to true
+        this.isNillable = !isPrimitiveType;
+        this.isMinOccurs0 = !isPrimitiveType;
+    }
+
+    public void generateWSDLSchema(Document document,
+                                   Map namespacesToPrefixMap)
+            throws SchemaGenerationException {
+        String xsdPrefix = (String) namespacesToPrefixMap.get(Constants.URI_2001_SCHEMA_XSD);
+        this.element = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "element");
+        this.element.setPrefix(xsdPrefix);
+        this.element.setAttribute("name", this.name);
+
+
+        if (this.isArray && !this.isTopElement) {
+            this.element.setAttribute("maxOccurs", "unbounded");
+        }
+
+        if (this.namespace == null){
+            this.element.setAttribute("form", "unqualified");
+        }
+
+        // setting the type
+        if (type == null) {
+            // i.e this is corresponds to an void type so generate a empty annony mous complex type
+            Element complexElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "complexType");
+            complexElement.setPrefix(xsdPrefix);
+
+            Element sequenceElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "sequence");
+            sequenceElement.setPrefix(xsdPrefix);
+            complexElement.appendChild(sequenceElement);
+            this.element.appendChild(complexElement);
+        } else if (type.isSimpleType()) {
+            // this is an simple type element
+            this.element.setAttribute("type", xsdPrefix + ":" + type.getQname().getLocalPart());
+            if (this.isNillable) {
+                this.element.setAttribute("nillable", "true");
+            }
+            if (this.isMinOccurs0 && !this.isTopElement){
+                this.element.setAttribute("minOccurs","0");
+            }
+        } else if (!type.isAnonymous()) {
+            String prefix = (String) namespacesToPrefixMap.get(type.getQname().getNamespaceURI());
+            this.element.setAttribute("type", prefix + ":" + type.getQname().getLocalPart());
+            if (this.isNillable) {
+                this.element.setAttribute("nillable", "true");
+            }
+            if (this.isMinOccurs0 && !this.isTopElement){
+                this.element.setAttribute("minOccurs","0");
+            }
+        } else {
+            // i.e this is and annonymous complex type
+            type.generateWSDLSchema(document, namespacesToPrefixMap);
+            this.element.appendChild(type.getTypeElement());
+        }
+
+    }
+
+    public String getNamespace() {
+        return namespace;
+    }
+
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
+    }
+
+    public boolean isNillable() {
+        return isNillable;
+    }
+
+    public void setNillable(boolean nillable) {
+        isNillable = nillable;
+    }
+
+    public boolean isArray() {
+        return isArray;
+    }
+
+    public void setArray(boolean array) {
+        isArray = array;
+    }
+
+    public boolean isTopElement() {
+        return isTopElement;
+    }
+
+    public void setTopElement(boolean topElement) {
+        isTopElement = topElement;
+    }
+
+    public XmlType getType() {
+        return type;
+    }
+
+    public void setType(XmlType type) {
+        this.type = type;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Element getElement() {
+        return element;
+    }
+
+    public void setElement(Element element) {
+        this.element = element;
+    }
+
+    public boolean isMinOccurs0() {
+        return isMinOccurs0;
+    }
+
+    public void setMinOccurs0(boolean minOccurs0) {
+        isMinOccurs0 = minOccurs0;
+    }
+}

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlTypeImpl.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlTypeImpl.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlTypeImpl.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,209 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.metadata.xml.impl;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.apache.axis2.rmi.metadata.xml.XmlElement;
+import org.apache.axis2.rmi.metadata.xml.XmlType;
+import org.apache.axis2.rmi.metadata.xml.XmlAttribute;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+import org.apache.axis2.rmi.util.Constants;
+
+import javax.xml.namespace.QName;
+import java.util.List;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+
+public class XmlTypeImpl implements XmlType {
+    /**
+     * Qualified name of the xmlType
+     */
+    private QName qname;
+
+    /**
+     * is this an anAnonymous type this case qname can be null
+     */
+    private boolean isAnonymous;
+
+    /**
+     * is this is a basic type
+     */
+    private boolean isSimpleType;
+
+    /**
+     * list of child elements
+     */
+    private List elements;
+
+    /**
+     * list of child attributes
+     */
+    private List attributes;
+
+    /**
+     * complex type element for this XmlType
+     */
+    private Element typeElement;
+
+    /**
+     * parent type for this xml type if it is an extension
+     */
+    private XmlType parentType;
+
+    public XmlTypeImpl() {
+        this.elements = new ArrayList();
+        this.attributes = new ArrayList();
+    }
+
+    public void addElement(XmlElement xmlElement) {
+        this.elements.add(xmlElement);
+    }
+
+    public void addAttribute(XmlAttribute xmlAttribute) {
+        this.attributes.add(xmlAttribute);
+    }
+
+    /**
+     * this generates the complex type only if it is annonymous and
+     * is not a simple type
+     *
+     * @param document
+     * @param namespacesToPrefixMap
+     * @throws org.apache.axis2.rmi.exception.SchemaGenerationException
+     *
+     */
+    public void generateWSDLSchema(Document document,
+                                   Map namespacesToPrefixMap)
+            throws SchemaGenerationException {
+        // here we have to generate the complex type element for this xmlType
+        if (!this.isSimpleType) {
+            String xsdPrefix = (String) namespacesToPrefixMap.get(Constants.URI_2001_SCHEMA_XSD);
+            this.typeElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "complexType");
+            this.typeElement.setPrefix(xsdPrefix);
+            if (!this.isAnonymous) {
+                this.typeElement.setAttribute("name", this.qname.getLocalPart());
+            }
+
+            Element sequenceElement = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "sequence");
+            sequenceElement.setPrefix(xsdPrefix);
+
+            // set the extension details if there are
+            if (this.parentType != null) {
+
+                // i.e this is an extension type
+                Element complexContent = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "complexContent");
+                complexContent.setPrefix(xsdPrefix);
+                this.typeElement.appendChild(complexContent);
+
+                Element extension = document.createElementNS(Constants.URI_2001_SCHEMA_XSD, "extension");
+                extension.setPrefix(xsdPrefix);
+                complexContent.appendChild(extension);
+
+                String extensionPrefix =
+                        (String) namespacesToPrefixMap.get(this.parentType.getQname().getNamespaceURI());
+                String localPart = this.parentType.getQname().getLocalPart();
+                if ((extensionPrefix == null) || extensionPrefix.equals("")) {
+                    extension.setAttribute("base", localPart);
+                } else {
+                    extension.setAttribute("base", extensionPrefix + ":" + localPart);
+                }
+                extension.appendChild(sequenceElement);
+            } else {
+                this.typeElement.appendChild(sequenceElement);
+            }
+
+            // add the other element children
+            XmlElement xmlElement;
+            for (Iterator iter = this.elements.iterator(); iter.hasNext();) {
+                xmlElement = (XmlElement) iter.next();
+                xmlElement.generateWSDLSchema(document, namespacesToPrefixMap);
+                sequenceElement.appendChild(xmlElement.getElement());
+            }
+
+            // add the attributes
+            XmlAttribute xmlAttribute;
+            for (Iterator iter = this.attributes.iterator(); iter.hasNext();) {
+                xmlAttribute = (XmlAttribute) iter.next();
+                xmlAttribute.generateWSDLSchema(document, namespacesToPrefixMap);
+                this.typeElement.appendChild(xmlAttribute.getAttribute());
+            }
+        }
+    }
+
+    public XmlTypeImpl(QName qname) {
+        this();
+        this.qname = qname;
+    }
+
+    public QName getQname() {
+        return qname;
+    }
+
+    public void setQname(QName qname) {
+        this.qname = qname;
+    }
+
+    public boolean isAnonymous() {
+        return isAnonymous;
+    }
+
+    public void setAnonymous(boolean anonymous) {
+        isAnonymous = anonymous;
+    }
+
+    public boolean isSimpleType() {
+        return isSimpleType;
+    }
+
+    public void setSimpleType(boolean simpleType) {
+        isSimpleType = simpleType;
+    }
+
+    public List getElements() {
+        return elements;
+    }
+
+    public void setElements(List elements) {
+        this.elements = elements;
+    }
+
+    public Element getTypeElement() {
+        return typeElement;
+    }
+
+    public void setTypeElement(Element typeElement) {
+        this.typeElement = typeElement;
+    }
+
+    public XmlType getParentType() {
+        return parentType;
+    }
+
+    public void setParentType(XmlType parentType) {
+        this.parentType = parentType;
+    }
+
+    public List getAttributes() {
+        return attributes;
+    }
+
+    public void setAttributes(List attributes) {
+        this.attributes = attributes;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ConfigObjectTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ConfigObjectTest.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ConfigObjectTest.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ConfigObjectTest.java Mon Aug 20 20:06:10 2007
@@ -16,12 +16,16 @@
 package org.apache.axis2.rmi.databind;
 
 import org.apache.axis2.rmi.deploy.config.*;
+import org.apache.axis2.rmi.deploy.config.ClassInfo;
+import org.apache.axis2.rmi.deploy.config.FieldInfo;
 import org.apache.axis2.rmi.metadata.Parameter;
 import org.apache.axis2.rmi.exception.MetaDataPopulateException;
 import org.apache.axis2.rmi.exception.SchemaGenerationException;
 import org.apache.axis2.rmi.exception.XmlSerializingException;
 import org.apache.axis2.rmi.exception.XmlParsingException;
 import org.apache.axis2.rmi.util.NamespacePrefix;
+import org.apache.axis2.rmi.config.*;
+import org.apache.axis2.rmi.databind.dto.TestClass2;
 import org.apache.axiom.om.util.StAXUtils;
 
 import javax.xml.stream.XMLStreamWriter;
@@ -36,6 +40,19 @@
 
         Config config = new Config();
 
+        // adding ustom mappings
+        org.apache.axis2.rmi.config.ClassInfo classInfo = new org.apache.axis2.rmi.config.ClassInfo(FieldInfo.class);
+        classInfo.addFieldInfo(new org.apache.axis2.rmi.config.FieldInfo("javaName",null,false));
+        classInfo.addFieldInfo(new org.apache.axis2.rmi.config.FieldInfo("xmlName",null,false));
+        classInfo.addFieldInfo(new org.apache.axis2.rmi.config.FieldInfo("element","isElement",false));
+        configurator.addClassInfo(classInfo);
+
+        classInfo = new org.apache.axis2.rmi.config.ClassInfo(ClassInfo.class);
+        classInfo.addFieldInfo(new org.apache.axis2.rmi.config.FieldInfo("className",null,false));
+        configurator.addClassInfo(classInfo);
+
+
+
         Service[] services = new Service[2];
         services[0] = new Service();
         services[0].setServiceClass("Service1");
@@ -64,6 +81,26 @@
         packageToNamespaceMapings.setPackageToNamespaceMap(packageToNamespaceMaps);
         config.setPackageToNamespaceMapings(packageToNamespaceMapings);
         config.setSimpleDataHandlerClass("test");
+
+        //adding customclass info
+        CustomClassInfo customClassInfo = new CustomClassInfo();
+        ClassInfo[] classInfos = new ClassInfo[1];
+        classInfos[0] = new ClassInfo();
+
+        FieldInfo[] filedInfos = new FieldInfo[1];
+        filedInfos[0] = new FieldInfo();
+        filedInfos[0].setElement(false);
+        filedInfos[0].setJavaName("param1");
+        filedInfos[0].setXmlName("xmlParam1");
+
+        classInfos[0].setFieldInfo(filedInfos);
+        classInfos[0].setClassName("test");
+
+        customClassInfo.setClassInfo(classInfos);
+
+        config.setCustomClassInfo(customClassInfo);
+
+
 
 
         Parameter parameter = new Parameter(Config.class, "config");

Added: webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CustomMappingsTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CustomMappingsTest.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CustomMappingsTest.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CustomMappingsTest.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.databind;
+
+import org.apache.axis2.rmi.Configurator;
+import org.apache.axis2.rmi.config.ClassInfo;
+import org.apache.axis2.rmi.config.FieldInfo;
+import org.apache.axis2.rmi.databind.dto.TestClass2;
+import org.apache.axis2.rmi.databind.dto.TestClass9;
+import org.apache.axis2.rmi.metadata.Parameter;
+
+
+public class CustomMappingsTest extends DataBindTest {
+
+    public void testTestClass2(){
+
+        ClassInfo classInfo = new ClassInfo(TestClass2.class);
+        classInfo.addFieldInfo(new FieldInfo("param1","xmlparam1",false));
+        classInfo.addFieldInfo(new FieldInfo("param2","xmlparam2",false));
+        configurator.addClassInfo(classInfo);
+
+        TestClass2 testObject = new TestClass2();
+        testObject.setParam1(5);
+        testObject.setParam2(34.5f);
+        testObject.setParam3(34.5);
+
+        Parameter parameter = new Parameter(TestClass2.class,"Param1");
+        TestClass2 result = (TestClass2) getReturnObject(parameter,testObject);
+        assertEquals(result.getParam1(),5);
+        assertTrue(result.getParam2() == 34.5f);
+        assertTrue(result.getParam3() == 34.5);
+
+    }
+
+    public void testTestClass9(){
+        
+        ClassInfo classInfo = new ClassInfo(TestClass2.class);
+        classInfo.addFieldInfo(new FieldInfo("param1","xmlparam1",false));
+        classInfo.addFieldInfo(new FieldInfo("param2","xmlparam2",false));
+        classInfo.addFieldInfo(new FieldInfo("param3","xmlparam3",true));
+        configurator.addClassInfo(classInfo);
+
+        classInfo = new ClassInfo(TestClass9.class);
+        classInfo.addFieldInfo(new FieldInfo("param1","xmlparam1",true));
+
+        configurator.addClassInfo(classInfo);
+
+        TestClass9 testClass9 = new TestClass9();
+
+        TestClass2[] testClass2 = new TestClass2[3];
+        testClass2[0] = new TestClass2();
+        testClass2[0].setParam1(6);
+        testClass2[0].setParam2(4.5f);
+        testClass2[0].setParam3(56.5);
+
+        testClass2[1] = new TestClass2();
+        testClass2[1].setParam1(6);
+        testClass2[1].setParam2(4.5f);
+        testClass2[1].setParam3(56.5);
+
+        testClass2[2] = new TestClass2();
+        testClass2[2].setParam1(6);
+        testClass2[2].setParam2(4.5f);
+        testClass2[2].setParam3(56.5);
+
+        testClass9.setParam1(testClass2);
+
+        Parameter parameter = new Parameter(TestClass9.class,"Param1");
+        TestClass9 result = (TestClass9) getReturnObject(parameter,testClass9);
+
+        assertEquals(result.getParam1()[0].getParam1(),6);
+        assertTrue(result.getParam1()[0].getParam2() == 4.5f);
+        assertTrue(result.getParam1()[0].getParam3() == 56.5);
+
+        assertEquals(result.getParam1()[1].getParam1(),6);
+        assertTrue(result.getParam1()[1].getParam2() == 4.5f);
+        assertTrue(result.getParam1()[1].getParam3() == 56.5);
+
+        assertEquals(result.getParam1()[2].getParam1(),6);
+        assertTrue(result.getParam1()[2].getParam2() == 4.5f);
+        assertTrue(result.getParam1()[2].getParam3() == 56.5);
+
+
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CustomTypeTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CustomTypeTest.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CustomTypeTest.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CustomTypeTest.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.databind;
+
+import org.apache.axis2.rmi.databind.dto.TestClass13;
+import org.apache.axis2.rmi.databind.dto.TestRestrictionBean;
+import org.apache.axis2.rmi.metadata.Parameter;
+
+
+public class CustomTypeTest extends DataBindTest {
+
+    public void testTestClass131() {
+
+        TestClass13 testClass13 = new TestClass13();
+        TestRestrictionBean testRestrictionBean = new TestRestrictionBean("test string");
+        testClass13.setParam1(testRestrictionBean);
+
+        Parameter parameter = new Parameter(TestClass13.class, "Param1");
+
+        TestClass13 result = (TestClass13) getReturnObject(parameter, testClass13);
+        assertEquals(result.getParam1().getParam1(), "test string");
+
+    }
+
+    public void testTestClass132() {
+
+        TestClass13 testClass13 = new TestClass13();
+        TestRestrictionBean[] testRestrictionBeans = new TestRestrictionBean[3];
+        testRestrictionBeans[0] = new TestRestrictionBean("test string 1");
+        testRestrictionBeans[1] = new TestRestrictionBean("test string 2");
+        testRestrictionBeans[2] = new TestRestrictionBean("test string 3");
+        testClass13.setParam2(testRestrictionBeans);
+
+        Parameter parameter = new Parameter(TestClass13.class, "Param1");
+
+        TestClass13 result = (TestClass13) getReturnObject(parameter, testClass13);
+        assertEquals(result.getParam2()[0].getParam1(), "test string 1");
+        assertEquals(result.getParam2()[1].getParam1(), "test string 2");
+        assertEquals(result.getParam2()[2].getParam1(), "test string 3");
+
+    }
+}

Added: webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/dto/TestClass13.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/dto/TestClass13.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/dto/TestClass13.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/dto/TestClass13.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.rmi.databind.dto;
+
+
+public class TestClass13 {
+
+    private TestRestrictionBean param1;
+    private TestRestrictionBean[] param2;
+
+    public TestRestrictionBean getParam1() {
+        return param1;
+    }
+
+    public void setParam1(TestRestrictionBean param1) {
+        this.param1 = param1;
+    }
+
+    public TestRestrictionBean[] getParam2() {
+        return param2;
+    }
+
+    public void setParam2(TestRestrictionBean[] param2) {
+        this.param2 = param2;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org