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 [1/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...

Author: amilas
Date: Mon Aug 20 20:06:10 2007
New Revision: 567923

URL: http://svn.apache.org/viewvc?rev=567923&view=rev
Log:
Added custom schema support. i.e give controll to the users about the generated schema.

Added:
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/config/
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/config/ClassInfo.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/config/FieldInfo.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/AbstractRMIBean.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/RMIBean.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/ClassInfo.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/CustomClassInfo.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/FieldInfo.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/RMIBeanInfo.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/AbstractType.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/AttributeField.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/ElementField.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Field.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/impl/
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/impl/TypeImpl.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/AbstractXmlType.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlAttribute.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlAttributeImpl.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlElementImpl.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/impl/XmlTypeImpl.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CustomMappingsTest.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/CustomTypeTest.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/dto/TestClass13.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/dto/TestRestrictionBean.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/type/
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/type/TestRestrictionType.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/type/TestRestrictionXmlType.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/CustomBeanTest.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/CustomMappingServiceTest.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/service/CustomBeanService.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/service/CustomMappingService.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/service/dto/ComplexType3.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/service/dto/CustomBeanClass.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/service/dto/SimpleRestriction.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/type/
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/type/SimpleRestrictionType.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/type/xml/
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/type/xml/SimpleRestrictionXmlType.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/server/services/Service2.java
Modified:
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/Configurator.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/JavaObjectSerializer.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/XmlStreamParser.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/RMIServiceDeployer.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/Config.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Attribute.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Operation.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Parameter.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Service.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Type.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlElement.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlSchema.java
    webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/xml/XmlType.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/databind/ConfigObjectTest.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/ExtensionServiceTest.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/metadata/TypeTest.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/server/ServerTest.java
    webservices/axis2/trunk/java/modules/rmi/test/org/apache/axis2/rmi/server/services/Service1.java

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/Configurator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/Configurator.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/Configurator.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/Configurator.java Mon Aug 20 20:06:10 2007
@@ -17,6 +17,7 @@
 
 import org.apache.axis2.rmi.util.Constants;
 import org.apache.axis2.rmi.databind.SimpleTypeHandler;
+import org.apache.axis2.rmi.config.ClassInfo;
 import org.apache.axis2.databinding.typemapping.SimpleTypeMapper;
 
 import java.util.List;
@@ -34,10 +35,15 @@
     private List extensionClasses;
     private Map packageToNamespaceMap;
     private SimpleTypeHandler simpleTypeHandler;
+    /**
+     * this map contains custom details of the classes
+     */
+    private Map classInfoMap;
 
     public Configurator() {
         this.extensionClasses = new ArrayList();
         this.packageToNamespaceMap = new HashMap();
+        this.classInfoMap = new HashMap();
 
         populateDefualtValues();
     }
@@ -63,6 +69,14 @@
     public void addPackageToNamespaceMaping(String packageName,
                                             String namespace){
         this.packageToNamespaceMap.put(packageName,namespace);
+    }
+
+    public void addClassInfo(ClassInfo classInfo){
+        this.classInfoMap.put(classInfo.getJavaClass(),classInfo);
+    }
+
+    public ClassInfo getClassInfo(Class javaClass){
+        return (ClassInfo) this.classInfoMap.get(javaClass);
     }
 
     public boolean isBare() {

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/config/ClassInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/config/ClassInfo.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/config/ClassInfo.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/config/ClassInfo.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.config;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * this is used to keep the custome information
+ * about the class
+ */
+public class ClassInfo {
+
+    private Map fieldInfoMap;
+    private Class javaClass;
+
+    public ClassInfo(Class javaClass) {
+        this();
+        this.javaClass = javaClass;
+    }
+
+    public ClassInfo() {
+        fieldInfoMap = new HashMap();
+    }
+
+    public void addFieldInfo(FieldInfo fieldInfo){
+        fieldInfoMap.put(fieldInfo.getJavaName(),fieldInfo);
+    }
+
+    public FieldInfo getFieldInfo(String javaName){
+        return (FieldInfo) fieldInfoMap.get(javaName);
+    }
+
+    public Class getJavaClass() {
+        return javaClass;
+    }
+
+    public void setJavaClass(Class javaClass) {
+        this.javaClass = javaClass;
+    }
+}

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/config/FieldInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/config/FieldInfo.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/config/FieldInfo.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/config/FieldInfo.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,65 @@
+/*
+ * 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.config;
+
+/**
+ * this class is used to keep the information about
+ * the class filed
+ */
+public class FieldInfo {
+
+    private String javaName;
+    private String xmlName;
+    // set the default element value to true
+    private boolean isElement = true;
+
+    public FieldInfo() {
+    }
+
+    public FieldInfo(String javaName) {
+        this.javaName = javaName;
+    }
+
+    public FieldInfo(String javaName, String xmlName, boolean element) {
+        this.javaName = javaName;
+        this.xmlName = xmlName;
+        isElement = element;
+    }
+
+    public String getJavaName() {
+        return javaName;
+    }
+
+    public void setJavaName(String javaName) {
+        this.javaName = javaName;
+    }
+
+    public String getXmlName() {
+        return xmlName;
+    }
+
+    public void setXmlName(String xmlName) {
+        this.xmlName = xmlName;
+    }
+
+    public boolean isElement() {
+        return isElement;
+    }
+
+    public void setElement(boolean element) {
+        isElement = element;
+    }
+}

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/AbstractRMIBean.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/AbstractRMIBean.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/AbstractRMIBean.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/AbstractRMIBean.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,115 @@
+/*
+ * 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.exception.XmlSerializingException;
+import org.apache.axis2.rmi.util.Constants;
+import org.apache.axis2.rmi.util.NamespacePrefix;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+
+public abstract class AbstractRMIBean implements RMIBean {
+
+    public abstract void serialize(XMLStreamWriter writer,
+                                   JavaObjectSerializer serializer,
+                                   QName parentQName,
+                                   NamespacePrefix namespacePrefix)
+            throws XMLStreamException, XmlSerializingException;
+
+    protected void writeStartElement(XMLStreamWriter writer,
+                                     String namespace,
+                                     String localPart,
+                                     NamespacePrefix namespacePrefix)
+            throws XMLStreamException {
+        if (!namespace.equals("")) {
+            String prefix = writer.getPrefix(namespace);
+            if (prefix == null) {
+                prefix = "ns" + namespacePrefix.getNamesapcePrefix();
+                writer.writeStartElement(prefix, localPart, namespace);
+                writer.writeNamespace(prefix, namespace);
+                writer.setPrefix(prefix, namespace);
+            } else {
+                writer.writeStartElement(namespace, localPart);
+            }
+        } else {
+            writer.writeStartElement(localPart);
+        }
+    }
+
+    protected void writeTypeAttribute(XMLStreamWriter writer,
+                                      QName typeQname,
+                                      NamespacePrefix namespacePrefix)
+            throws XMLStreamException {
+        String xsiPrefix = writer.getPrefix(Constants.URI_DEFAULT_SCHEMA_XSI);
+        if (xsiPrefix == null) {
+            xsiPrefix = "ns" + namespacePrefix.getNamesapcePrefix();
+            writer.writeNamespace(xsiPrefix, Constants.URI_DEFAULT_SCHEMA_XSI);
+            writer.setPrefix(xsiPrefix, Constants.URI_DEFAULT_SCHEMA_XSI);
+        }
+
+        String typePrefix = writer.getPrefix(typeQname.getNamespaceURI());
+        if (typePrefix == null) {
+            typePrefix = "ns" + namespacePrefix.getNamesapcePrefix();
+            writer.writeNamespace(typePrefix, typeQname.getNamespaceURI());
+            writer.setPrefix(typePrefix, typeQname.getNamespaceURI());
+        }
+
+        String attributeValue = typeQname.getLocalPart();
+        if (!typePrefix.equals("")) {
+            attributeValue = typePrefix + ":" + attributeValue;
+        }
+        writer.writeAttribute(Constants.URI_DEFAULT_SCHEMA_XSI, "type", attributeValue);
+    }
+
+    protected void writeNullAttribute(XMLStreamWriter writer,
+                                      NamespacePrefix namespacePrefix)
+            throws XMLStreamException {
+        QName attributeQName = new QName(Constants.URI_DEFAULT_SCHEMA_XSI, "nil");
+        writeAttribute(writer, "1", attributeQName, namespacePrefix);
+    }
+
+    /**
+     * this method wrtes the simple attribute to the writer.
+     *
+     * @param writer
+     * @param attributeValue
+     * @param attributeQName
+     * @param namespacePrefix
+     * @throws XMLStreamException
+     */
+    protected void writeAttribute(XMLStreamWriter writer,
+                                  String attributeValue,
+                                  QName attributeQName,
+                                  NamespacePrefix namespacePrefix) throws XMLStreamException {
+        if ((attributeQName.getNamespaceURI() != null) && !attributeQName.getNamespaceURI().trim().equals("")) {
+            String prefix = writer.getPrefix(attributeQName.getNamespaceURI());
+            if (prefix == null) {
+                prefix = "ns" + namespacePrefix.getNamesapcePrefix();
+                writer.writeNamespace(prefix, attributeQName.getNamespaceURI());
+                writer.setPrefix(prefix, attributeQName.getNamespaceURI());
+            }
+            writer.writeAttribute(attributeQName.getNamespaceURI(),
+                    attributeQName.getLocalPart(),
+                    attributeValue);
+
+        } else {
+            writer.writeAttribute(attributeQName.getLocalPart(), attributeValue);
+        }
+    }
+}

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/JavaObjectSerializer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/JavaObjectSerializer.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/JavaObjectSerializer.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/JavaObjectSerializer.java Mon Aug 20 20:06:10 2007
@@ -16,18 +16,18 @@
 package org.apache.axis2.rmi.databind;
 
 import org.apache.axis2.rmi.metadata.Type;
-import org.apache.axis2.rmi.metadata.Attribute;
 import org.apache.axis2.rmi.metadata.Parameter;
+import org.apache.axis2.rmi.metadata.ElementField;
+import org.apache.axis2.rmi.metadata.AttributeField;
+import org.apache.axis2.rmi.metadata.impl.TypeImpl;
 import org.apache.axis2.rmi.metadata.xml.XmlElement;
 import org.apache.axis2.rmi.util.Constants;
 import org.apache.axis2.rmi.util.NamespacePrefix;
-import org.apache.axis2.rmi.util.JavaTypeToQNameMap;
 import org.apache.axis2.rmi.exception.XmlSerializingException;
 import org.apache.axis2.rmi.exception.MetaDataPopulateException;
 import org.apache.axis2.rmi.exception.SchemaGenerationException;
 import org.apache.axis2.rmi.Configurator;
 import org.apache.axis2.rmi.types.MapType;
-import org.apache.axis2.databinding.utils.ConverterUtil;
 
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.stream.XMLStreamException;
@@ -233,107 +233,136 @@
             throws XMLStreamException,
             XmlSerializingException {
 
-        // first write the start element
-        writeStartElement(writer,
-                parentQName.getNamespaceURI(),
-                parentQName.getLocalPart(),
-                namespacePrefix);
-        if (object == null) {
-            writeNullAttribute(writer, namespacePrefix);
+        if (object instanceof RMIBean) {
+            RMIBean rmiBean = (RMIBean) object;
+            rmiBean.serialize(writer, this, parentQName, namespacePrefix);
         } else {
-            // handle extensions here.
-            // primitive can not have excented types
-            if (!object.getClass().equals(type.getJavaClass()) && !type.getJavaClass().isPrimitive()) {
-                // i.e this is an extension
-                if (!processedTypeMap.containsKey(object.getClass())) {
-                    Type newType = new Type(object.getClass());
-                    processedTypeMap.put(object.getClass(), newType);
-                    try {
-                        newType.populateMetaData(this.configurator, this.processedTypeMap);
-                        newType.generateSchema(this.configurator, this.schemaMap);
-                    } catch (MetaDataPopulateException e) {
-                        new XmlSerializingException("Problem in processing new type", e);
-                    } catch (SchemaGenerationException e) {
-                        new XmlSerializingException("Problem in processing new type", e);
+            // first write the start element
+            writeStartElement(writer,
+                    parentQName.getNamespaceURI(),
+                    parentQName.getLocalPart(),
+                    namespacePrefix);
+            if (object == null) {
+                writeNullAttribute(writer, namespacePrefix);
+            } else {
+                // handle extensions here.
+                // primitive can not have excented types
+                if (!object.getClass().equals(type.getJavaClass()) && !type.getJavaClass().isPrimitive()) {
+                    // i.e this is an extension
+                    if (!processedTypeMap.containsKey(object.getClass())) {
+                        Type newType = new TypeImpl(object.getClass());
+                        processedTypeMap.put(object.getClass(), newType);
+                        try {
+                            newType.populateMetaData(this.configurator, this.processedTypeMap);
+                            newType.generateSchema(this.configurator, this.schemaMap);
+                        } catch (MetaDataPopulateException e) {
+                            new XmlSerializingException("Problem in processing new type", e);
+                        } catch (SchemaGenerationException e) {
+                            new XmlSerializingException("Problem in processing new type", e);
+                        }
                     }
+                    type = (Type) processedTypeMap.get(object.getClass());
+                    writeTypeAttribute(writer, type.getXmlType().getQname(), namespacePrefix);
                 }
-                type = (Type) processedTypeMap.get(object.getClass());
-                writeTypeAttribute(writer, type.getXmlType().getQname(), namespacePrefix);
-            }
 
-            if (type.getXmlType().isSimpleType()) {
-                // this is a know type for us
-                // get the string represenation of this object using converter util class.
-                try {
-                    Method methodToInvoke = this.simpleTypeHandlerClass.getMethod("convertToString", new Class[]{type.getJavaClass()});
-                    // these methods are static so use null as the object argument
-                    String stringValue = (String) methodToInvoke.invoke(this.simpleTypeHandler, new Object[]{object});
+                if (type.getXmlType().isSimpleType()) {
+                    // this is a know type for us
+                    // get the string represenation of this object using converter util class.
                     if (!type.getJavaClass().equals(Object.class)) {
-                        writer.writeCharacters(stringValue);
+                        writer.writeCharacters(getSimpleTypeStringValue(type, object));
                     }
-                } catch (NoSuchMethodException e) {
-                    new XmlSerializingException("Can not invoke converter util method convertToString for class "
-                            + type.getJavaClass().getName(), e);
-                } catch (IllegalAccessException e) {
-                    new XmlSerializingException("Can not invoke converter util method convertToString for class "
-                            + type.getJavaClass().getName(), e);
-                } catch (InvocationTargetException e) {
-                    new XmlSerializingException("Can not invoke converter util method convertToString for class "
-                            + type.getJavaClass().getName(), e);
-                }
 
-            } else {
-                // this is a complex type
-                try {
-                    // write the attributes
-                    Attribute attribute;
-                    Method getterMethod;
-                    Object attributeValue;
-                    QName attributeQName;
-                    for (Iterator iter = type.getAllAttributes().iterator(); iter.hasNext();) {
-                        attribute = (Attribute) iter.next();
-                        getterMethod = attribute.getGetterMethod();
-                        attributeValue = getterMethod.invoke(object, new Object[]{});
-                        serializeAttribute(attributeValue,
-                                attribute,
-                                writer,
-                                namespacePrefix);
+                } else {
+                    // this is a complex type
+                    try {
 
+                        AttributeField attributeField;
+                        Method getterMethod;
+                        Object attributeFieldValue;
+                        QName attributeQName;
+                        for (Iterator iter = type.getAllAttributeFields().iterator(); iter.hasNext();) {
+                            attributeField = (AttributeField) iter.next();
+                            getterMethod = attributeField.getGetterMethod();
+                            attributeFieldValue = getterMethod.invoke(object, new Object[]{});
+                            attributeQName = new QName(attributeField.getNamespace(), attributeField.getName());
+                            // calls to write attribute. for attributes we can have only simple types
+                            if (attributeFieldValue != null) {
+                                writeAttribute(writer,
+                                        getSimpleTypeStringValue(attributeField.getType(), attributeFieldValue),
+                                        attributeQName,
+                                        namespacePrefix);
+                            } else if (attributeField.isRequried()) {
+                                throw new XmlSerializingException("Attribute value for attribute "
+                                        + attributeField.getName() + " is required");
+                            }
+
+                        }
+
+                        // write the element fields
+                        ElementField elementField;
+                        Object elementFieldValue;
+                        for (Iterator iter = type.getAllElementFields().iterator(); iter.hasNext();) {
+                            elementField = (ElementField) iter.next();
+                            getterMethod = elementField.getGetterMethod();
+                            elementFieldValue = getterMethod.invoke(object, new Object[]{});
+                            serializeElementField(elementFieldValue,
+                                    elementField,
+                                    writer,
+                                    namespacePrefix);
+
+                        }
+                    } catch (IllegalAccessException e) {
+                        throw new XmlSerializingException("problem with method inovocation " + type.getName());
+                    } catch (InvocationTargetException e) {
+                        throw new XmlSerializingException("problem with method inovocation " + type.getName());
                     }
-                } catch (IllegalAccessException e) {
-                    throw new XmlSerializingException("problem with method inovocation " + type.getName());
-                } catch (InvocationTargetException e) {
-                    throw new XmlSerializingException("problem with method inovocation " + type.getName());
-                }
 
+                }
             }
+            writer.writeEndElement();
+        }
+    }
+
+    private String getSimpleTypeStringValue(Type type, Object object) throws XmlSerializingException {
+        try {
+            Method methodToInvoke = this.simpleTypeHandlerClass.getMethod("convertToString", new Class[]{type.getJavaClass()});
+            // these methods are static so use null as the object argument
+            return (String) methodToInvoke.invoke(this.simpleTypeHandler, new Object[]{object});
+        } catch (NoSuchMethodException e) {
+            throw new XmlSerializingException("Can not invoke converter util method convertToString for class "
+                    + type.getJavaClass().getName(), e);
+        } catch (IllegalAccessException e) {
+            throw new XmlSerializingException("Can not invoke converter util method convertToString for class "
+                    + type.getJavaClass().getName(), e);
+        } catch (InvocationTargetException e) {
+            throw new XmlSerializingException("Can not invoke converter util method convertToString for class "
+                    + type.getJavaClass().getName(), e);
         }
-        writer.writeEndElement();
     }
 
     /**
      * this method serializes the attributes by calling to serialize element method.
      *
-     * @param attributeValue
-     * @param attribute
+     * @param elementFieldValue
+     * @param elementField
      * @param writer
      * @param namespacePrefix
      */
-    private void serializeAttribute(Object attributeValue,
-                                    Attribute attribute,
-                                    XMLStreamWriter writer,
-                                    NamespacePrefix namespacePrefix)
+    private void serializeElementField(Object elementFieldValue,
+                                       ElementField elementField,
+                                       XMLStreamWriter writer,
+                                       NamespacePrefix namespacePrefix)
             throws XmlSerializingException, XMLStreamException {
 
-        QName attribueQName = new QName(attribute.getElement().getNamespace(),
-                attribute.getElement().getName());
-        serializeElement(attributeValue,
-                attribueQName,
-                attribute.getType(),
+        QName elementFieldQName = new QName(elementField.getElement().getNamespace(),
+                elementField.getElement().getName());
+                serializeElement(elementFieldValue,
+                elementFieldQName,
+                elementField.getType(),
                 writer,
                 namespacePrefix,
-                attribute.isArray(),
-                attribute.getClassType());
+                elementField.isArray(),
+                elementField.getClassType());
 
     }
 
@@ -386,12 +415,36 @@
     private void writeNullAttribute(XMLStreamWriter writer,
                                     NamespacePrefix namespacePrefix)
             throws XMLStreamException {
-        String prefix = writer.getPrefix(Constants.URI_DEFAULT_SCHEMA_XSI);
-        if (prefix == null) {
-            prefix = "ns" + namespacePrefix.getNamesapcePrefix();
-            writer.writeNamespace(prefix, Constants.URI_DEFAULT_SCHEMA_XSI);
-            writer.setPrefix(prefix, Constants.URI_DEFAULT_SCHEMA_XSI);
+        QName attributeQName = new QName(Constants.URI_DEFAULT_SCHEMA_XSI,"nil");
+        writeAttribute(writer,"1",attributeQName,namespacePrefix);
+    }
+
+    /**
+     * this method wrtes the simple attribute to the writer.
+     * @param writer
+     * @param attributeValue
+     * @param attributeQName
+     * @param namespacePrefix
+     * @throws XMLStreamException
+     */
+    private void writeAttribute(XMLStreamWriter writer,
+                                String attributeValue,
+                                QName attributeQName,
+                                NamespacePrefix namespacePrefix) throws XMLStreamException {
+        if ((attributeQName.getNamespaceURI() != null) && !attributeQName.getNamespaceURI().trim().equals("")){
+            String prefix = writer.getPrefix(attributeQName.getNamespaceURI());
+            if (prefix == null){
+                prefix = "ns" + namespacePrefix.getNamesapcePrefix();
+                writer.writeNamespace(prefix, attributeQName.getNamespaceURI());
+                writer.setPrefix(prefix, attributeQName.getNamespaceURI());
+            }
+            writer.writeAttribute(attributeQName.getNamespaceURI(),
+                    attributeQName.getLocalPart(),
+                    attributeValue);
+
+        } else {
+            writer.writeAttribute(attributeQName.getLocalPart(),attributeValue);
         }
-        writer.writeAttribute(Constants.URI_DEFAULT_SCHEMA_XSI, "nil", "1");
+
     }
 }

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/RMIBean.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/RMIBean.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/RMIBean.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/RMIBean.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,33 @@
+package org.apache.axis2.rmi.databind;
+
+import org.apache.axis2.rmi.metadata.Type;
+import org.apache.axis2.rmi.util.NamespacePrefix;
+import org.apache.axis2.rmi.exception.XmlSerializingException;
+import org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter;
+
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.namespace.QName;
+
+/**
+ * this interface is used to customize the
+ * the default way axis2 rmi works
+ */
+public interface RMIBean {
+
+    /**
+     * serialize the class accordingly.
+     * this method supposed to serialize this object to the
+     * writer. ParentQname is passed so that this method should wirte
+     * the start and end elements for the bean as well.
+     * @param writer
+     * @param parentQName
+     */
+    public void serialize(XMLStreamWriter writer,
+                         JavaObjectSerializer serializer,
+                         QName parentQName,
+                         NamespacePrefix namespacePrefix)
+            throws XMLStreamException, XmlSerializingException;
+
+}

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/XmlStreamParser.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/XmlStreamParser.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/XmlStreamParser.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/databind/XmlStreamParser.java Mon Aug 20 20:06:10 2007
@@ -15,10 +15,8 @@
  */
 package org.apache.axis2.rmi.databind;
 
-import org.apache.axis2.rmi.metadata.Attribute;
-import org.apache.axis2.rmi.metadata.Type;
-import org.apache.axis2.rmi.metadata.Parameter;
-import org.apache.axis2.rmi.metadata.Operation;
+import org.apache.axis2.rmi.metadata.*;
+import org.apache.axis2.rmi.metadata.impl.TypeImpl;
 import org.apache.axis2.rmi.exception.XmlParsingException;
 import org.apache.axis2.rmi.exception.MetaDataPopulateException;
 import org.apache.axis2.rmi.exception.SchemaGenerationException;
@@ -26,7 +24,6 @@
 import org.apache.axis2.rmi.util.JavaTypeToQNameMap;
 import org.apache.axis2.rmi.Configurator;
 import org.apache.axis2.rmi.types.MapType;
-import org.apache.axis2.databinding.utils.ConverterUtil;
 
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamException;
@@ -36,6 +33,8 @@
 import java.lang.reflect.Method;
 import java.util.*;
 
+import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
+
 
 public class XmlStreamParser {
 
@@ -68,7 +67,7 @@
         for (Iterator iter = defaultTypeMapKeys.iterator(); iter.hasNext();) {
             typeClass = (Class) iter.next();
             if (!processedTypeMap.containsKey(typeClass)) {
-                Type newType = new Type(typeClass);
+                Type newType = new TypeImpl(typeClass);
                 processedTypeMap.put(typeClass, newType);
                 newType.populateMetaData(this.configurator, processedTypeMap);
                 newType.generateSchema(this.configurator, schemaMap);
@@ -197,14 +196,7 @@
                     returnObject = new Object();
                 } else {
                     // find the object for this string using converter util classs
-                    String methodName = null;
-                    try {
-                        methodName = getMethodName(type.getJavaClass().getName());
-                        Method  methodToInvoke = this.simpleTypeHandlerClass.getMethod(methodName,new Class[]{String.class});
-                        returnObject = methodToInvoke.invoke(this.simpleTypeHandler,new Object[]{reader.getText()});
-                    } catch (NoSuchMethodException e) {
-                        throw new XmlParsingException("Can not invoke the converter util class method " + methodName, e);
-                    }
+                    returnObject = getSimpleTypeObject(type, reader, reader.getText());
                 }
             } else {
                 // first we have to point to the reader to the begining for the element
@@ -213,22 +205,22 @@
                 }
                 // this is a complex type
                 returnObject = type.getJavaClass().newInstance();
-                // we have to get all the attribute and populate them
-                List attributes = type.getAllAttributes();
-                Attribute attribute;
-                Object attributeObject;
-                QName attributeQName = null;
-
-                for (Iterator iter = attributes.iterator(); iter.hasNext();) {
-                    attribute = (Attribute) iter.next();
-                    attributeObject = getObjectForAttribute(reader, attribute);
-                    attributeQName = new QName(attribute.getNamespace(), attribute.getName());
-                    if (attributeObject != null) {
-                        attribute.getSetterMethod().invoke(returnObject, new Object[]{attributeObject});
+                // we have to get all the elementField and populate them
+                List elementFields = type.getAllElementFields();
+                ElementField elementField;
+                Object elementFieldObject;
+                QName elementFieldQName = null;
+
+                for (Iterator iter = elementFields.iterator(); iter.hasNext();) {
+                    elementField = (ElementField) iter.next();
+                    elementFieldObject = getObjectForElementField(reader, elementField);
+                    elementFieldQName = new QName(elementField.getNamespace(), elementField.getName());
+                    if (elementFieldObject != null) {
+                        elementField.getSetterMethod().invoke(returnObject, new Object[]{elementFieldObject});
                     }
-                    // if the reader is at the end of this attribute
+                    // if the reader is at the end of this elementField
                     // then we move it to next element.
-                    if (reader.isEndElement() && reader.getName().equals(attributeQName)){
+                    if (reader.isEndElement() && reader.getName().equals(elementFieldQName)){
                         reader.next();
                     }
 
@@ -247,6 +239,24 @@
 
     }
 
+    private Object getSimpleTypeObject(Type type, XMLStreamReader reader, String value)
+            throws  XmlParsingException {
+        Object returnObject;
+        String methodName = null;
+        try {
+            methodName = getMethodName(type.getJavaClass().getName());
+            Method  methodToInvoke = this.simpleTypeHandlerClass.getMethod(methodName,new Class[]{String.class});
+            returnObject = methodToInvoke.invoke(this.simpleTypeHandler,new Object[]{value});
+        } catch (NoSuchMethodException e) {
+            throw new XmlParsingException("Can not invoke the converter util class method " + methodName, e);
+        } catch (IllegalAccessException e) {
+            throw new XmlParsingException("Can not invoke the converter util class method " + methodName, e);
+        } catch (InvocationTargetException e) {
+            throw new XmlParsingException("Can not invoke the converter util class method " + methodName, e);
+        }
+        return returnObject;
+    }
+
     private String getMethodName(String className) {
         // first handle some exceptional casses
         if (className.equals(Integer.class.getName())) {
@@ -265,28 +275,28 @@
     }
 
     /**
-     * give the relavent object for attribute.
+     * give the relavent object for elementField.
      *
      * @param reader
-     * @param attribute
+     * @param elementField
      * @return
      * @throws XMLStreamException
      * @throws XmlParsingException
      */
 
-    private Object getObjectForAttribute(XMLStreamReader reader,
-                                         Attribute attribute)
+    private Object getObjectForElementField(XMLStreamReader reader,
+                                            ElementField elementField)
             throws XMLStreamException,
             XmlParsingException {
-        QName attributeQName = new QName(attribute.getNamespace(), attribute.getName());
+        QName elementFieldQName = new QName(elementField.getNamespace(), elementField.getName());
         return getObjectForElement(reader,
-                attributeQName,
-                attribute.getType(),
-                attribute.isArray(),
-                attribute.getElement().isNillable(),
-                attribute.getElement().isMinOccurs0(),
-                attribute.getClassType(),
-                attribute.getPropertyDescriptor().getPropertyType());
+                elementFieldQName,
+                elementField.getType(),
+                elementField.isArray(),
+                elementField.getElement().isNillable(),
+                elementField.getElement().isMinOccurs0(),
+                elementField.getClassType(),
+                elementField.getPropertyDescriptor().getPropertyType());
 
     }
 
@@ -355,8 +365,9 @@
                     }
 
                 } else {
-                    reader.next();
-                    objectsCollection.add(getObjectForType(reader, actualElementType));
+
+                    Object returnObject = getElementObjectFromReader(actualElementType, reader);
+                    objectsCollection.add(returnObject);
 
                     // we have to move the cursor until the end element of this attribute
                     while (!reader.isEndElement() || !reader.getName().equals(elementQName)) {
@@ -405,8 +416,9 @@
                                     throw new XmlParsingException("Element " + elementQName + " can not be null");
                                 }
                             } else {
-                                reader.next();
-                                objectsCollection.add(getObjectForType(reader, actualElementType));
+                                Object returnObject = getElementObjectFromReader(actualElementType, reader);
+                                objectsCollection.add(returnObject);
+
                                 // we have to move the cursor until the end element of this attribute
                                 while (!reader.isEndElement() || !reader.getName().equals(elementQName)) {
                                     reader.next();
@@ -493,9 +505,8 @@
                     }
 
                 } else {
-                    reader.next();
-                    Object returnObject = getObjectForType(reader, actualElementType);
 
+                    Object returnObject = getElementObjectFromReader(actualElementType, reader);
                     // we have to move the cursor until the end element of this attribute
                     while (!reader.isEndElement() || !reader.getName().equals(elementQName)) {
                         reader.next();
@@ -511,6 +522,72 @@
                         "expected " + elementQName.getLocalPart());
             }
         }
+    }
+
+    private Object getElementObjectFromReader(Type elementType,
+                                              XMLStreamReader reader)
+            throws XmlParsingException, XMLStreamException {
+        Object returnObject = null;
+        if (RMIBean.class.isAssignableFrom(elementType.getJavaClass())) {
+            // this is an rmi bean
+            // so invoke the static parse method
+            try {
+                Method parseMethod = elementType.getJavaClass().getMethod("parse", new Class[]{XMLStreamReader.class, XmlStreamParser.class});
+                returnObject = parseMethod.invoke(null, new Object[]{reader, this});
+            } catch (NoSuchMethodException e) {
+                throw new XmlParsingException("parse method has not been implemented correctly for the rmi bean "
+                        + elementType.getJavaClass().getName(), e);
+            } catch (IllegalAccessException e) {
+                throw new XmlParsingException("can not access parse method of the rmi bean "
+                        + elementType.getJavaClass().getName(), e);
+            } catch (InvocationTargetException e) {
+                throw new XmlParsingException("can not invoke parse method of the rmi bean "
+                        + elementType.getJavaClass().getName(), e);
+            }
+        } else {
+            // read the attributes.
+            Map javaMethodToValueMap = getJavaMethodValueHashMap(elementType, reader);
+            reader.next();
+            returnObject = getObjectForType(reader, elementType);
+            populateObjectAttributes(javaMethodToValueMap, returnObject);
+        }
+
+        return returnObject;
+    }
+
+    private void populateObjectAttributes(Map javaMethodToValueMap, Object returnObject) throws XmlParsingException {
+        Method javaMehtod;
+        try {
+            for (Iterator iter = javaMethodToValueMap.keySet().iterator();iter.hasNext();){
+                javaMehtod = (Method) iter.next();
+                javaMehtod.invoke(returnObject,new Object[]{javaMethodToValueMap.get(javaMehtod)});
+            }
+        } catch (IllegalAccessException e) {
+            throw new XmlParsingException("Can not set the attribute value");
+        } catch (InvocationTargetException e) {
+            throw new XmlParsingException("Can not set the attribute value");
+        }
+    }
+
+    private Map getJavaMethodValueHashMap(Type actualElementType, XMLStreamReader reader)
+            throws XmlParsingException {
+        AttributeField attributeField;
+        String attributeVlaue;
+        Object attributeObject;
+        Map javaMethodToValueMap = new HashMap();
+        for (Iterator iter = actualElementType.getAllAttributeFields().iterator();iter.hasNext();){
+            attributeField = (AttributeField) iter.next();
+            attributeVlaue = reader.getAttributeValue(attributeField.getNamespace(),
+                                                    attributeField.getName());
+            if (attributeVlaue != null) {
+                attributeObject = getSimpleTypeObject(attributeField.getType(), reader, attributeVlaue);
+                javaMethodToValueMap.put(attributeField.getSetterMethod(), attributeObject);
+            } else if (attributeField.isRequried()){
+                throw new XmlParsingException("Required attribute " + attributeField.getName() + " is missing");
+            }
+
+        }
+        return javaMethodToValueMap;
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/RMIServiceDeployer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/RMIServiceDeployer.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/RMIServiceDeployer.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/RMIServiceDeployer.java Mon Aug 20 20:06:10 2007
@@ -22,10 +22,11 @@
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.rmi.metadata.Parameter;
-import org.apache.axis2.rmi.deploy.config.Config;
-import org.apache.axis2.rmi.deploy.config.Service;
-import org.apache.axis2.rmi.deploy.config.PackageToNamespaceMap;
+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.Configurator;
+import org.apache.axis2.rmi.config.*;
 import org.apache.axis2.rmi.databind.XmlStreamParser;
 import org.apache.axis2.rmi.databind.SimpleTypeHandler;
 import org.apache.axis2.rmi.exception.MetaDataPopulateException;
@@ -71,44 +72,7 @@
             // gettting the file reader for zipinput stream
             Config configObject = getConfig(absolutePath);
 
-            Configurator configurator = new Configurator();
-
-            if (configObject.getExtensionClasses() != null) {
-                String[] extensionClasses = configObject.getExtensionClasses().getExtensionClass();
-                if (extensionClasses != null) {
-                    Class extensionClass;
-                    for (int i = 0; i < extensionClasses.length; i++) {
-                        extensionClass = Loader.loadClass(deploymentClassLoader, extensionClasses[i]);
-                        configurator.addExtension(extensionClass);
-                    }
-                }
-            }
-
-            if (configObject.getPackageToNamespaceMapings() != null) {
-                PackageToNamespaceMap[] packageToNamespaceMapings =
-                        configObject.getPackageToNamespaceMapings().getPackageToNamespaceMap();
-                if (packageToNamespaceMapings != null) {
-                    for (int i = 0; i < packageToNamespaceMapings.length; i++) {
-                        configurator.addPackageToNamespaceMaping(packageToNamespaceMapings[i].getPackageName(),
-                                packageToNamespaceMapings[i].getNamespace());
-                    }
-                }
-            }
-
-            // set the simple type data handler if it is set
-            if ((configObject.getSimpleDataHandlerClass() != null)
-                    && (configObject.getSimpleDataHandlerClass().trim().length() > 0)){
-                Class simpleTypeHandlerClass =
-                        Loader.loadClass(deploymentClassLoader,configObject.getSimpleDataHandlerClass());
-                try {
-                    SimpleTypeHandler simpleTypeHandler = (SimpleTypeHandler) simpleTypeHandlerClass.newInstance();
-                    configurator.setSimpleTypeHandler(simpleTypeHandler);
-                } catch (InstantiationException e) {
-                    throw new DeploymentException("Can not instantiate simple type handler",e);
-                } catch (IllegalAccessException e) {
-                    throw new DeploymentException("Can not instantiate simple type handler",e);
-                }
-            }
+            Configurator configurator = getConfigurator(configObject, deploymentClassLoader);
 
             Service[] services = configObject.getServices().getService();
             ClassDeployer classDeployer =
@@ -133,6 +97,78 @@
         }
     }
 
+    private Configurator getConfigurator(Config configObject, DeploymentClassLoader deploymentClassLoader)
+            throws ClassNotFoundException, DeploymentException {
+        Configurator configurator = new Configurator();
+
+        if (configObject.getExtensionClasses() != null) {
+            String[] extensionClasses = configObject.getExtensionClasses().getExtensionClass();
+            if (extensionClasses != null) {
+                Class extensionClass;
+                for (int i = 0; i < extensionClasses.length; i++) {
+                    extensionClass = Loader.loadClass(deploymentClassLoader, extensionClasses[i]);
+                    configurator.addExtension(extensionClass);
+                }
+            }
+        }
+
+        if (configObject.getPackageToNamespaceMapings() != null) {
+            PackageToNamespaceMap[] packageToNamespaceMapings =
+                    configObject.getPackageToNamespaceMapings().getPackageToNamespaceMap();
+            if (packageToNamespaceMapings != null) {
+                for (int i = 0; i < packageToNamespaceMapings.length; i++) {
+                    configurator.addPackageToNamespaceMaping(packageToNamespaceMapings[i].getPackageName(),
+                            packageToNamespaceMapings[i].getNamespace());
+                }
+            }
+        }
+
+        // set the simple type data handler if it is set
+        if ((configObject.getSimpleDataHandlerClass() != null)
+                && (configObject.getSimpleDataHandlerClass().trim().length() > 0)){
+            Class simpleTypeHandlerClass =
+                    Loader.loadClass(deploymentClassLoader,configObject.getSimpleDataHandlerClass());
+            try {
+                SimpleTypeHandler simpleTypeHandler = (SimpleTypeHandler) simpleTypeHandlerClass.newInstance();
+                configurator.setSimpleTypeHandler(simpleTypeHandler);
+            } catch (InstantiationException e) {
+                throw new DeploymentException("Can not instantiate simple type handler",e);
+            } catch (IllegalAccessException e) {
+                throw new DeploymentException("Can not instantiate simple type handler",e);
+            }
+        }
+
+        // setting the custom class info
+        ClassInfo[] classInfos = null;
+        FieldInfo[] filsInfos = null;
+        org.apache.axis2.rmi.config.ClassInfo classInfo;
+        Class customClass = null;
+        if (configObject.getCustomClassInfo() != null) {
+            CustomClassInfo customClassInfo = configObject.getCustomClassInfo();
+            if ((customClassInfo.getClassInfo() != null) && (customClassInfo.getClassInfo().length > 0)) {
+                classInfos = customClassInfo.getClassInfo();
+                for (int i = 0; i < classInfos.length; i++) {
+
+                    if ((classInfos[i].getFieldInfo() != null) &&
+                            (classInfos[i].getFieldInfo().length > 0)){
+                        customClass = Loader.loadClass(deploymentClassLoader,classInfos[i].getClassName());
+                        classInfo = new org.apache.axis2.rmi.config.ClassInfo(customClass);
+                        filsInfos = classInfos[i].getFieldInfo();
+                        for (int j = 0; j < filsInfos.length; j++) {
+                           classInfo.addFieldInfo(
+                                   new org.apache.axis2.rmi.config.FieldInfo(
+                                           filsInfos[j].getJavaName(),
+                                           filsInfos[j].getXmlName(),
+                                           filsInfos[j].isElement()));
+                        }
+                        configurator.addClassInfo(classInfo);
+                    }
+                }
+            }
+        }
+        return configurator;
+    }
+
     private Config getConfig(String zipFilePath) throws ConfigFileReadingException {
         try {
             InputStream configFileInputStream = getConfigFileInputStream(zipFilePath);
@@ -141,6 +177,19 @@
             Configurator configurator = new Configurator();
             configurator.addPackageToNamespaceMaping("org.apache.axis2.rmi.deploy.config",
                     "http://ws.apache.org/axis2/rmi");
+
+            // add configurator details to handle custom class info
+            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);
+
+
             Map processedTypeMap = new HashMap();
             Map processedSchemaMap = new HashMap();
             Parameter parameter = new Parameter(Config.class, "config");

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/ClassInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/ClassInfo.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/ClassInfo.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/ClassInfo.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.deploy.config;
+
+
+public class ClassInfo {
+
+    private String className;
+    private FieldInfo[] fieldInfo;
+
+    public FieldInfo[] getFieldInfo() {
+        return fieldInfo;
+    }
+
+    public void setFieldInfo(FieldInfo[] fieldInfo) {
+        this.fieldInfo = fieldInfo;
+    }
+
+    public String getClassName() {
+        return className;
+    }
+
+    public void setClassName(String className) {
+        this.className = className;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/Config.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/Config.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/Config.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/Config.java Mon Aug 20 20:06:10 2007
@@ -21,6 +21,7 @@
    private ExtensionClasses extensionClasses;
    private PackageToNamespaceMapings packageToNamespaceMapings;
    private String simpleDataHandlerClass;
+   private CustomClassInfo customClassInfo;
 
     public Services getServices() {
         return services;
@@ -52,6 +53,14 @@
 
     public void setSimpleDataHandlerClass(String simpleDataHandlerClass) {
         this.simpleDataHandlerClass = simpleDataHandlerClass;
+    }
+
+    public CustomClassInfo getCustomClassInfo() {
+        return customClassInfo;
+    }
+
+    public void setCustomClassInfo(CustomClassInfo customClassInfo) {
+        this.customClassInfo = customClassInfo;
     }
 
 }

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/CustomClassInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/CustomClassInfo.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/CustomClassInfo.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/CustomClassInfo.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,31 @@
+/*
+ * 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.deploy.config;
+
+
+public class CustomClassInfo {
+
+    private ClassInfo[] classInfo;
+
+    public ClassInfo[] getClassInfo() {
+        return classInfo;
+    }
+
+    public void setClassInfo(ClassInfo[] classInfo) {
+        this.classInfo = classInfo;
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/FieldInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/FieldInfo.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/FieldInfo.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/FieldInfo.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,48 @@
+/*
+ * 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.deploy.config;
+
+
+public class FieldInfo {
+
+    private String javaName;
+    private String xmlName;
+    private boolean isElement = true;
+
+    public String getJavaName() {
+        return javaName;
+    }
+
+    public void setJavaName(String javaName) {
+        this.javaName = javaName;
+    }
+
+    public String getXmlName() {
+        return xmlName;
+    }
+
+    public void setXmlName(String xmlName) {
+        this.xmlName = xmlName;
+    }
+
+    public boolean isElement() {
+        return isElement;
+    }
+
+    public void setElement(boolean element) {
+        isElement = element;
+    }
+}

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/RMIBeanInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/RMIBeanInfo.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/RMIBeanInfo.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/deploy/config/RMIBeanInfo.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.deploy.config;
+
+
+public class RMIBeanInfo {
+
+    private String beanClass;
+    private String beanTypeClass;
+
+    public String getBeanClass() {
+        return beanClass;
+    }
+
+    public void setBeanClass(String beanClass) {
+        this.beanClass = beanClass;
+    }
+
+    public String getBeanTypeClass() {
+        return beanTypeClass;
+    }
+
+    public void setBeanTypeClass(String beanTypeClass) {
+        this.beanTypeClass = beanTypeClass;
+    }
+}

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/AbstractType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/AbstractType.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/AbstractType.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/AbstractType.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,187 @@
+/*
+ * 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.Configurator;
+import org.apache.axis2.rmi.exception.MetaDataPopulateException;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+import org.apache.axis2.rmi.metadata.xml.XmlType;
+import org.apache.axis2.rmi.metadata.xml.XmlSchema;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public abstract class AbstractType implements Type {
+
+    /**
+     * java class corresponds to this XmlType object
+     */
+    protected Class javaClass;
+
+    /**
+     * list of element Field objects for this java class
+     */
+    protected List elementFields;
+
+    /**
+     * list of attribute Field objects for this java class
+     */
+    protected List attributeFields;
+
+    /**
+     * name of the Type : class name
+     */
+    protected String name;
+
+    /**
+     * namespace of the type : depends on the package
+     */
+    protected String namespace;
+
+    /**
+     * parent type for this type
+     */
+    protected Type parentType;
+
+    /**
+     * xml metadata type correponding to this type object
+     */
+    protected XmlType xmlType;
+
+    protected boolean isSchemaGenerated;
+
+
+    /**
+     * popualate the meta data corresponding to this type
+     * @param configurator
+     */
+    public abstract void populateMetaData(Configurator configurator,
+                                 Map processedTypeMap)
+            throws MetaDataPopulateException;
+
+    /**
+     * this method sets the xmlType correctly. this method should only be invoked
+     * if it has not already processed
+     * @param configurator
+     * @param schemaMap
+     */
+
+    public abstract void generateSchema(Configurator configurator,
+                               Map schemaMap)
+            throws SchemaGenerationException;
+
+    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;
+    }
+
+    protected void registerXmlType(Map schemaMap) {
+        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);
+        xmlSchema.addComplexType(this.xmlType);
+    }
+
+    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;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Attribute.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Attribute.java?rev=567923&r1=567922&r2=567923&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Attribute.java (original)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/Attribute.java Mon Aug 20 20:06:10 2007
@@ -20,6 +20,8 @@
 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;
 
@@ -137,7 +139,7 @@
             if (processedTypeMap.containsKey(baseClass)){
                 this.type = (Type) processedTypeMap.get(baseClass);
             } else {
-                this.type = new Type(baseClass);
+                this.type = new TypeImpl(baseClass);
                 processedTypeMap.put(baseClass, this.type);
                 this.type.populateMetaData(configurator, processedTypeMap);
             }
@@ -164,7 +166,7 @@
             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 = new XmlElementImpl(!this.isArray && this.type.getJavaClass().isPrimitive());
        this.element.setName(this.name);
        this.element.setNamespace(this.namespace);
        this.element.setTopElement(false);

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/AttributeField.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/AttributeField.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/AttributeField.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/AttributeField.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,128 @@
+/*
+ * 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.XmlAttribute;
+import org.apache.axis2.rmi.metadata.xml.impl.XmlElementImpl;
+import org.apache.axis2.rmi.metadata.xml.impl.XmlAttributeImpl;
+import org.apache.axis2.rmi.metadata.impl.TypeImpl;
+import org.apache.axis2.rmi.Configurator;
+import org.apache.axis2.rmi.databind.RMIBean;
+import org.apache.axis2.rmi.util.JavaTypeToQNameMap;
+import org.apache.axis2.rmi.exception.MetaDataPopulateException;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+
+import java.beans.PropertyDescriptor;
+import java.util.Map;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+
+public class AttributeField extends Field {
+
+    /**
+     * xml attribute representing this attribute
+     */
+    protected XmlAttribute attribute;
+
+    private boolean isRequried;
+
+    public AttributeField() {
+    }
+
+    public AttributeField(PropertyDescriptor propertyDescriptor, String namespace) {
+        super(propertyDescriptor, namespace);
+    }
+
+    public void populateMetaData(Configurator configurator, Map processedTypeMap)
+            throws MetaDataPopulateException {
+        super.populateMetaData(configurator, processedTypeMap);
+        if (!this.propertyDescriptor.getPropertyType().isArray()) {
+            Class baseClass = this.propertyDescriptor.getPropertyType();
+            if (JavaTypeToQNameMap.containsKey(baseClass) ||
+                    RMIBean.class.isAssignableFrom(baseClass)) {
+
+                if (processedTypeMap.containsKey(baseClass)) {
+                    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());
+                    } catch (IllegalAccessException e) {
+                        throw new MetaDataPopulateException("Can not invoke rmi bean class " +
+                                baseClass.getName());
+                    } catch (InstantiationException e) {
+                        throw new MetaDataPopulateException("Can not instantiate RMI bean class " +
+                                baseClass.getName());
+                    }
+                } else {
+                    this.type = new TypeImpl(baseClass);
+                    processedTypeMap.put(baseClass, this.type);
+                    this.type.populateMetaData(configurator, processedTypeMap);
+                }
+            } else {
+                throw new MetaDataPopulateException("Attribute element must have a known simpe type");
+            }
+
+        } else {
+            throw new MetaDataPopulateException("Attribute element can not be an array type");
+        }
+
+    }
+
+    public void generateSchema(Configurator configurator, Map schemaMap)
+            throws SchemaGenerationException {
+        super.generateSchema(configurator, schemaMap);
+        this.attribute = new XmlAttributeImpl(this.getPropertyDescriptor().getPropertyType().isPrimitive());
+        this.attribute.setName(this.name);
+        this.attribute.setNamespace(this.namespace);
+        this.attribute.setType(this.type.getXmlType());
+        this.attribute.setRequired(this.isRequried);
+    }
+
+    public XmlAttribute getAttribute() {
+        return attribute;
+    }
+
+    public void setAttribute(XmlAttribute attribute) {
+        this.attribute = attribute;
+    }
+
+    public boolean isRequried() {
+        return isRequried;
+    }
+
+    public void setRequried(boolean requried) {
+        isRequried = requried;
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/ElementField.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/ElementField.java?rev=567923&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/ElementField.java (added)
+++ webservices/axis2/trunk/java/modules/rmi/src/org/apache/axis2/rmi/metadata/ElementField.java Mon Aug 20 20:06:10 2007
@@ -0,0 +1,159 @@
+/*
+ * 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.metadata.xml.impl.XmlElementImpl;
+import org.apache.axis2.rmi.metadata.impl.TypeImpl;
+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.exception.MetaDataPopulateException;
+import org.apache.axis2.rmi.exception.SchemaGenerationException;
+
+import java.beans.PropertyDescriptor;
+import java.util.Map;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+
+public class ElementField extends Field {
+
+    /**
+     * is this attribute an array
+     */
+    protected boolean isArray;
+
+    /**
+     * class type of the attribute class
+     */
+    protected int classType;
+
+    /**
+     * schmema element corresponding to this attribute
+     * always an attribute refer to and schema XmlElement
+     */
+    protected XmlElement element;
+
+
+    public ElementField() {
+    }
+
+    public ElementField(PropertyDescriptor propertyDescriptor, String namespace) {
+        super(propertyDescriptor, namespace);
+    }
+
+    public void populateMetaData(Configurator configurator,
+                                 Map processedTypeMap)
+            throws MetaDataPopulateException {
+        super.populateMetaData(configurator, processedTypeMap);
+        Class baseClass = null;
+        try {
+            this.classType = Util.getClassType(this.propertyDescriptor.getPropertyType());
+
+            if ((this.classType & Constants.COLLECTION_TYPE) == Constants.COLLECTION_TYPE) {
+                // i.e. if this is collection type
+                this.isArray = true;
+                baseClass = Object.class;
+            } else if ((this.classType & Constants.MAP_TYPE) == Constants.MAP_TYPE) {
+                // if the attribute is mep type we set a custom type for it.
+                this.isArray = true;
+                baseClass = MapType.class;
+            } else {
+                this.isArray = this.propertyDescriptor.getPropertyType().isArray();
+                if (this.isArray) {
+                    baseClass = this.propertyDescriptor.getPropertyType().getComponentType();
+                } else {
+                    baseClass = this.propertyDescriptor.getPropertyType();
+                }
+            }
+
+            if (processedTypeMap.containsKey(baseClass)) {
+                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 TypeImpl(baseClass);
+                processedTypeMap.put(baseClass, this.type);
+                this.type.populateMetaData(configurator, processedTypeMap);
+            }
+        } catch (IllegalAccessException e) {
+            throw new MetaDataPopulateException("Can not instataite class "
+                    + this.propertyDescriptor.getPropertyType().getName(), e);
+        } catch (InstantiationException e) {
+            throw new MetaDataPopulateException("Can not instataite class "
+                    + this.propertyDescriptor.getPropertyType().getName(), e);
+        }
+    }
+
+    public void generateSchema(Configurator configurator, Map schemaMap) throws SchemaGenerationException {
+        super.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.setTopElement(false);
+        this.element.setType(this.type.getXmlType());
+        this.element.setArray(this.isArray);
+
+    }
+
+    public boolean isArray() {
+        return isArray;
+    }
+
+    public void setArray(boolean array) {
+        isArray = array;
+    }
+
+    public XmlElement getElement() {
+        return element;
+    }
+
+    public void setElement(XmlElement element) {
+        this.element = element;
+    }
+
+    public int getClassType() {
+        return classType;
+    }
+
+    public void setClassType(int classType) {
+        this.classType = classType;
+    }
+
+}



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