You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2011/09/01 12:34:46 UTC

svn commit: r1163991 - in /axis/axis2/java/core/trunk/modules: adb/src/org/apache/axis2/databinding/typemapping/ adb/src/org/apache/axis2/databinding/utils/ adb/src/org/apache/axis2/rpc/receivers/ integration/test/org/apache/axis2/engine/ kernel/src/or...

Author: sagara
Date: Thu Sep  1 10:34:45 2011
New Revision: 1163991

URL: http://svn.apache.org/viewvc?rev=1163991&view=rev
Log:
Applied patch for AXIS2-3967. 

Added:
    axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/EnumService.java   (with props)
    axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/EnumTest.java   (with props)
    axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/Event.java   (with props)
Modified:
    axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java
    axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
    axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java
    axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/Constants.java
    axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java
    axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/TypeTable.java

Modified: axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java?rev=1163991&r1=1163990&r2=1163991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java (original)
+++ axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java Thu Sep  1 10:34:45 2011
@@ -418,4 +418,13 @@ public class SimpleTypeMapper {
 		}
 	}
 
+    /*check weather passed parameter class is a java.lang.Enum
+    *
+    * @param classType the class type
+    * @return true , if it is an Enum
+    * */
+
+    public static boolean isEnum(Class classType) {
+        return java.lang.Enum.class.isAssignableFrom(classType);
+    }
 }

Modified: axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java?rev=1163991&r1=1163990&r2=1163991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java (original)
+++ axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java Thu Sep  1 10:34:45 2011
@@ -79,6 +79,7 @@ import org.w3c.dom.traversal.TreeWalker;
 
 
 public class BeanUtil {
+   
     private static int nsCount = 1;
 
     /**
@@ -367,7 +368,12 @@ public class BeanUtil {
 					addTypeQname(elemntNameSpace, propertyQnameValueList,
 							property, beanName, processingDocLitBare);
 					propertyQnameValueList.add(map);
-				} else {
+				} else if (SimpleTypeMapper.isEnum(ptype)){
+                    addTypeQname(elemntNameSpace, propertyQnameValueList, property,
+                                 beanName, processingDocLitBare);
+                    propertyQnameValueList.add(
+                            value == null ? null : SimpleTypeMapper.getStringValue(value.toString()));
+                }else {
                     addTypeQname(elemntNameSpace, propertyQnameValueList, property,
                                  beanName, processingDocLitBare);
 					if (Object.class.equals(ptype)) {
@@ -376,16 +382,16 @@ public class BeanUtil {
 						QName qNamefortheType = (QName) typeTable
 								.getComplexSchemaMap().get(
 										getClassName(beanClass));
-						OMFactory fac = OMAbstractFactory.getOMFactory();						
+						OMFactory fac = OMAbstractFactory.getOMFactory();
 						QName elementName = new QName(elemntNameSpace
 								.getNamespaceURI(), property.getName(),
 								qNamefortheType.getPrefix());
 						OMElement element;
 						if(SimpleTypeMapper.isSimpleType(value)){
-							element = fac.createOMElement(elementName);					
+							element = fac.createOMElement(elementName);
 							element.addChild(fac.createOMText(SimpleTypeMapper
-									.getStringValue(value)));	            		
-		            	}else{		            		 
+									.getStringValue(value)));            
+		            	}else{    
 		            		 XMLStreamReader xr = BeanUtil.getPullParser(value,
 		            				 elementName, typeTable, true, false);
 		                     OMXMLParserWrapper stAXOMBuilder =
@@ -625,6 +631,8 @@ public class BeanUtil {
                                 	 partObj = processGenericsMapElement(parameterArgTypes
                                      		 , (OMElement) parts.getParent(), null, parts.getChildren(), objectSupplier, beanClass);                                	
                                 }
+                            }else if (SimpleTypeMapper.isEnum(parameters)) {
+                                partObj =processEnumObject(parameters , parts);
                             } else {
                                 partObj = deserialize(parameters, parts, objectSupplier, null);
                             }
@@ -944,7 +952,10 @@ public class BeanUtil {
                      return toReturn[0];
                  }        		
         	}        	
-        } else {
+        } else if (SimpleTypeMapper.isEnum(classType)) {
+            /* handling enum types */
+            retObjs[count] = processEnumObject(classType, omElement);
+        } else{
             //handling refs
             retObjs[count] = processObject(omElement, classType, helper, false, objectSupplier, genericType);
             
@@ -1065,13 +1076,32 @@ public class BeanUtil {
                   }
                  
                 	
-                } else {
+                }else if(SimpleTypeMapper.isEnum(classType)){
+                    return processEnumObject(classType, omElement);
+                }else {
                     return BeanUtil.deserialize(classType, omElement, objectSupplier, null);
                 }
             }
         }
     }
 
+    /*This method check is service method required enum type instance as method parameter
+    * if so return required enum object
+    *
+    * @param classType method required instance type
+    * @param omElement OMElement
+    * @return an Enum object
+    * */
+    public static Object processEnumObject(Class classType , OMElement omElement)throws AxisFault{
+          /*
+            *reason to add this block is check is soap sending a string but service require Enum
+            * then this convert string to relevant enum object and add to retObjs[] as object
+            * */
+        Object enumIbj = Enum.valueOf(classType , omElement.getText());
+        return enumIbj;
+
+    }
+
 
     public static OMElement getOMElement(QName opName,
                                          Object[] args,
@@ -1188,6 +1218,9 @@ public class BeanUtil {
                         OMText text = fac.createOMText(arg, true);
                         wrappingElement.addChild(text);
                         objects.add(wrappingElement);
+                    }else if (SimpleTypeMapper.isEnum(arg.getClass())) {
+                        // in here i can return enum instances but for now i return it as a simple string
+                        objects.add(arg.toString());
                     } else {
                         objects.add(arg);
                     }
@@ -1260,8 +1293,8 @@ public class BeanUtil {
 	 *
 	 *
 	 * @param fac the SOAPFactory instance.
-	 * @param child the child OMElement to add attributes.
-	 * @param method the java reflection method
+	 * @param element the child OMElement to add attributes.
+	 * @param resObject the java reflection method
 	 * @param resObject the res object
 	 * @param typeTable the type table of particular Axis2 service
 	 */

Modified: axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java?rev=1163991&r1=1163990&r2=1163991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java (original)
+++ axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java Thu Sep  1 10:34:45 2011
@@ -46,8 +46,6 @@ import javax.xml.stream.XMLStreamReader;
 import java.lang.reflect.Array;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
@@ -511,7 +509,11 @@ public class RPCUtil {
                         returnElement.addChild(text);
                         resElemt.addChild(returnElement);
                         envelope.getBody().addChild(resElemt);
-                    } else {
+                    }
+                    else {
+                        if(SimpleTypeMapper.isEnum(resObject.getClass())){
+                           resObject = resObject.toString();
+                        }
                         if (service.isElementFormDefault()) {
                             RPCUtil.processResponse(fac, resObject, bodyContent, ns,
                                     envelope, method,

Added: axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/EnumService.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/EnumService.java?rev=1163991&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/EnumService.java (added)
+++ axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/EnumService.java Thu Sep  1 10:34:45 2011
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.engine;
+
+public class EnumService {
+
+    public EnumService() {
+    }
+
+    public Day testDay(Day day){
+        System.out.println(day.getClass().getName());
+        return day;
+    }
+
+    public Event enumPojo(Event newEvent){
+        return newEvent;
+    }
+
+    public Status testMultiEnumParameters(Status status1 , Day day1 , Status status2 , Day day){
+        return status1;
+    }
+
+    public enum Day{
+        MONDAY , TUESDAY , WEDNESDAY, THURSDAY , FRIDAY , SATURDAY , SUNDAY;
+    }
+
+
+
+    public enum Status{
+        START(0,"start"), ACTIVE(1,"active") , STOP(2, "stop");
+
+        private final int val;
+        private final String desc;
+        Status(int val , String desc){
+            this.val = val;
+            this.desc =  desc;
+        }
+
+        public int value(){
+            return this.val;
+        }
+
+        public String description(){
+            return this.desc;
+        }
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/EnumService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/EnumTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/EnumTest.java?rev=1163991&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/EnumTest.java (added)
+++ axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/EnumTest.java Thu Sep  1 10:34:45 2011
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.engine;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.integration.LocalTestCase;
+import org.apache.axis2.rpc.client.RPCServiceClient;
+import org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver;
+import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+
+public class EnumTest extends LocalTestCase{
+    private static final Log log = LogFactory.getLog(EnumTest.class);
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        serverConfig.addMessageReceiver(WSDL2Constants.MEP_URI_IN_ONLY,
+                new RPCInOnlyMessageReceiver());
+        serverConfig.addMessageReceiver(WSDL2Constants.MEP_URI_IN_OUT,
+                new RPCMessageReceiver());
+        deployClassAsService("EnumService", EnumService.class);
+    }
+
+
+    public void testTestDay()throws Exception {
+
+        QName opTestDay = new QName("http://engine.axis2.apache.org", "testDay" , "asix");
+//        QName paraDay = new QName("http://engine.axis2.apache.org", "day" , "asix");
+
+        EnumService.Day aDay = EnumService.Day.MONDAY;
+
+        Object[] opDayArg = new Object[]{aDay};
+        RPCServiceClient serviceClient = getRPCClient();
+        Options options = serviceClient.getOptions();
+        EndpointReference targetEPR = new EndpointReference(
+                "local://services/EnumService");
+        options.setTo(targetEPR);
+        options.setAction("testDay");
+
+//        Object[] ret = serviceClient.invokeBlocking(
+//                opTestDay, opDayArg, paraDay ,  new Class[]{String.class});
+        Object[]  ret = serviceClient.invokeBlocking(opTestDay ,opDayArg , new Class[]{String.class});
+        log.debug(ret[0].toString());
+        assertEquals(ret[0], "MONDAY");
+
+    }
+
+
+    public void testEnumPojo()throws Exception{
+        QName opEnumPojo = new QName("http://engine.axis2.apache.org", "enumPojo" , "asix");
+
+        Event event = new Event();
+
+        event.setEventDesc("Event Description");
+        event.setEventName("Event Name");
+        event.setStartingDay(EnumService.Day.FRIDAY);
+
+        // Constructing the arguments array for the method invocation
+        Object[] opAddEventArgs = new Object[] { event};
+
+        // Invoking the method
+        RPCServiceClient serviceClient = getRPCClient();
+        Options options = serviceClient.getOptions();
+        EndpointReference targetEPR = new EndpointReference(
+                "local://services/EnumService");
+        options.setTo(targetEPR);
+        options.setAction("enumPojo");
+        Class[] returnTypes = new Class[] { Event.class };
+
+        Object[] ret = serviceClient.invokeBlocking(opEnumPojo, opAddEventArgs, returnTypes);
+//                assertEquals(event, ret[0]);
+        Event res = (Event)ret[0];
+        assertEquals(event.getEventDesc() , res.getEventDesc());
+        assertEquals(event.getEventName(), res.getEventName());
+        assertEquals(event.getStartingDay() , res.getStartingDay());
+
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/EnumTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/Event.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/Event.java?rev=1163991&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/Event.java (added)
+++ axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/Event.java Thu Sep  1 10:34:45 2011
@@ -0,0 +1,53 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.engine;
+
+public class Event {
+
+    private EnumService.Day startingDay;
+    //    private SampleService.Status eventDesc;
+    private String eventDesc ;
+    private String eventName;
+
+    public EnumService.Day getStartingDay() {
+        return startingDay;
+    }
+
+    public void setStartingDay(EnumService.Day startingDay) {
+        this.startingDay = startingDay;
+    }
+
+    public String getEventDesc() {
+        return eventDesc;
+    }
+
+    public void setEventDesc(String eventDesc) {
+        this.eventDesc = eventDesc;
+    }
+
+    public String getEventName() {
+        return eventName;
+    }
+
+    public void setEventName(String eventName) {
+        this.eventName = eventName;
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/Event.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/Constants.java?rev=1163991&r1=1163990&r2=1163991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/Constants.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/Constants.java Thu Sep  1 10:34:45 2011
@@ -330,6 +330,10 @@ public class Constants extends org.apach
         "http://ws.apache.org/namespaces/axis2/map"; 
     public static final String AXIS2_MAP_NAMESPACE_PREFIX = "map";
 
+    public static final String AXIS2_ENUM_NAMESPACE_PREFIX = "enum";
+    public static final String AXIS2_ENUM_NAMESPACE_URI = "http://ws.apache.org/namespaces/axis2/enum";
+    public static final String ENUM_ELEMENT_NAME = "enum";
+
     public static interface Configuration {
         public static final String ENABLE_REST = "enableREST";
         public static final String ENABLE_HTTP_CONTENT_NEGOTIATION = "httpContentNegotiation";

Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java?rev=1163991&r1=1163990&r2=1163991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java Thu Sep  1 10:34:45 2011
@@ -21,18 +21,17 @@ package org.apache.axis2.description.jav
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
-import org.apache.axis2.jaxrs.JAXRSUtils;
-import org.apache.axis2.jaxrs.JAXRSModel;
-import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.deployment.util.BeanExcludeInfo;
 import org.apache.axis2.deployment.util.Utils;
-import org.apache.axis2.description.*;
+import org.apache.axis2.description.AxisMessage;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.java2wsdl.bytecode.MethodTable;
-import org.apache.axis2.jsr181.JSR181Helper;
-import org.apache.axis2.jsr181.WebMethodAnnotation;
-import org.apache.axis2.jsr181.WebParamAnnotation;
-import org.apache.axis2.jsr181.WebResultAnnotation;
-import org.apache.axis2.jsr181.WebServiceAnnotation;
+import org.apache.axis2.jaxrs.JAXRSModel;
+import org.apache.axis2.jaxrs.JAXRSUtils;
+import org.apache.axis2.jsr181.*;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -44,13 +43,13 @@ import org.w3c.dom.Document;
 import javax.activation.DataHandler;
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilderFactory;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
 import java.io.*;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.*;
 import java.util.*;
-import java.beans.PropertyDescriptor;
-import java.beans.BeanInfo;
-import java.beans.Introspector;
 
 public class DefaultSchemaGenerator implements Java2WSDLConstants, SchemaGenerator {
 
@@ -408,7 +407,9 @@ public class DefaultSchemaGenerator impl
                 } else if(methodParameter != null && Collection.class.isAssignableFrom(methodParameter)){
                 	generateWrappedSchemaTypeForCollection(sequence, genericParameterTypes[j], parameterName); 
                 	
-                } else {
+                }else if(methodParameter != null && Enum.class.isAssignableFrom(methodParameter)){
+                    generateWrappedSchemaTypeForEnum(sequence , parameterName , methodParameter , false);
+                }else {
                     Type genericParameterType = genericParameterTypes[j];
                     Type genericType = null;
                     if(genericParameterType instanceof ParameterizedType){
@@ -417,7 +418,17 @@ public class DefaultSchemaGenerator impl
                         genericType = parameterArgTypes[0];
                         generateSchemaForType(sequence, genericType, parameterName, true);
                     }else{
-                        generateSchemaForType(sequence, methodParameter, parameterName);
+                        if(methodParameter.isArray()){
+                            Class<?> componentType = methodParameter.getComponentType();
+                            if (Enum.class.isAssignableFrom(componentType)) {
+                                generateWrappedSchemaTypeForEnum(sequence,  parameterName, componentType, true);
+                            } else {
+                                 generateSchemaForType(sequence, methodParameter, parameterName);
+                            }
+
+                        }else{
+                            generateSchemaForType(sequence, methodParameter, parameterName);
+                        }
                     }
                 }
             }
@@ -455,13 +466,24 @@ public class DefaultSchemaGenerator impl
 						generateWrappedSchemaTypeForCollection(sequence, genericParameterType, returnName);
 					} else {						
 						generateWrappedSchemaTypeForCollection(sequence, genericParameterType, returnName);
-					}                  	
+					}
+                }else if(Enum.class .isAssignableFrom(returnType)){
+                      generateWrappedSchemaTypeForEnum(sequence ,  returnName , returnType , false);
                 } else if(genericParameterType instanceof ParameterizedType){
                     ParameterizedType aType = (ParameterizedType) genericParameterType;
                     Type[] parameterArgTypes = aType.getActualTypeArguments();
                     generateSchemaForType(sequence, parameterArgTypes[0], returnName, true);
                 } else {
-                generateSchemaForType(sequence, returnType, returnName);
+                    if (returnType.isArray()) {
+                        Class<?> returnComponentType = returnType.getComponentType();
+                        if (Enum.class.isAssignableFrom(returnComponentType)) {
+                            generateWrappedSchemaTypeForEnum(sequence,  returnName, returnComponentType, true);
+                        } else {
+                            generateSchemaForType(sequence, returnType, returnName);
+                        }
+                    } else {
+                        generateSchemaForType(sequence, returnType, returnName);
+                    }
                 }
 
                 AxisMessage outMessage = axisOperation.getMessage(
@@ -702,25 +724,27 @@ public class DefaultSchemaGenerator impl
                                 .isAssignableFrom((Class) genericFieldType)) {
                             generateSchemaTypeForDocument(sequence,
                                     propertyName);
-                            
+
                         } else {
-                        	if(genericFieldType != null && Map.class.isAssignableFrom((Class)genericFieldType)){
-                        		generateWrappedSchemaTypeForMap(sequence, genericFieldType, propertyName);
-                        		
-			    }
-			    if (genericFieldType != null
-				    && Collection.class
-					    .isAssignableFrom((Class) genericFieldType)) {
-				generateWrappedSchemaTypeForCollection(
-					sequence, genericFieldType,
-					propertyName);
-			    } else {
-                            	generateSchemaforFieldsandProperties(xmlSchema,
+                            if(genericFieldType != null && Map.class.isAssignableFrom((Class) genericFieldType)){
+                                generateWrappedSchemaTypeForMap(sequence, genericFieldType, propertyName);
+
+                            }
+                            if (genericFieldType != null
+                                    && Collection.class
+                                    .isAssignableFrom((Class) genericFieldType)) {
+                                generateWrappedSchemaTypeForCollection(
+                                        sequence, genericFieldType,
+                                        propertyName);
+                            }else if (genericFieldType!=null && Enum.class.isAssignableFrom((Class)genericFieldType)) {
+                                generateWrappedSchemaTypeForEnum(sequence ,  propertyName ,(Class)genericFieldType , false );
+                            }else {
+                                generateSchemaforFieldsandProperties(xmlSchema,
                                         sequence,
                                         property.getPropertyType(),
                                         propertyName,
-                                        property.getPropertyType().isArray());                            	
-                            }                            
+                                        property.getPropertyType().isArray());
+                            }
                         }
                     }
                 }
@@ -2041,4 +2065,96 @@ public class DefaultSchemaGenerator impl
         sequence.getItems().add(entryElement);
 
     }
+
+
+    /**
+	 * Generate wrapped schema type for Enum.
+	 *
+	 * @param sequence the sequence
+	 * @param methodParameterType the generic parameter type
+	 * @param parameterName the parameter name
+	 * @throws Exception the exception
+	 */
+	private void generateWrappedSchemaTypeForEnum(XmlSchemaSequence sequence,
+			 String parameterName , Class<?> methodParameterType , boolean isArray) throws Exception {
+		//generateSchemaTypeForMap(sequence, genericParameterType, parameterName, false);
+        generateSchemaTypeForEnum(sequence , parameterName, isArray , methodParameterType);
+	}
+
+
+    /**
+	 * Generate schema type for Enum.
+	 *
+	 * @param sequence the sequence
+	 * @param classType the generic parameter type
+	 * @param parameterName the parameter name
+	 * @param isArrayType parameter is an array or not
+	 * @return the q name
+	 * @throws Exception the exception
+	 */
+    private QName generateSchemaTypeForEnum(XmlSchemaSequence sequence,
+                                            String parameterName, boolean isArrayType , Class<?> classType) {
+        if(Enum.class .isAssignableFrom(classType)){
+            XmlSchema xmlSchema = getXmlSchema(Constants.AXIS2_ENUM_NAMESPACE_URI);
+            String targetNamespacePrefix = targetNamespacePrefixMap
+                  .get(Constants.AXIS2_ENUM_NAMESPACE_URI);
+//          String enumName = generateUniqueNameForEnum();
+            String enumClass = classType.getName().substring(
+                    classType.getName().lastIndexOf("$")+1 , classType.getName().length());
+            //String enumInstanceName = generateUniqueNameForEnumInstance(enumClass);
+            QName enumQname = new QName(Constants.AXIS2_ENUM_NAMESPACE_URI,
+                  enumClass, targetNamespacePrefix);
+                 // check weather this enum class have already added to schema
+            if(typeTable.getSimpleTypeEnum(classType.getName())==null){
+                XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(xmlSchema);
+                simpleType.setName(enumClass);
+                XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
+                restriction.setBaseTypeName(Constants.XSD_STRING);
+                List enumList = Arrays.asList(classType.getEnumConstants());
+                for(Object enumObj : enumList){        // add all enum constants to restriction facet
+                    restriction.getFacets().add(new XmlSchemaEnumerationFacet(enumObj.toString(), false));
+                }
+                simpleType.setContent(restriction);
+                xmlSchema.getItems().add(simpleType);       // add enum to wsdl
+                typeTable.addSimpleTypeEnum( classType.getName() ,enumQname ); //add to typetable
+            }
+
+
+          XmlSchemaElement entryElement = new XmlSchemaElement();
+          entryElement.setName(Constants.ENUM_ELEMENT_NAME);
+          entryElement.setNillable(true);
+          entryElement.setSchemaTypeName(enumQname);
+          entryElement.setQName(enumQname);
+             QName schemaTypeName = new QName(Constants.AXIS2_ENUM_NAMESPACE_URI,
+                  enumClass);
+          addImport(getXmlSchema(schemaTargetNameSpace), schemaTypeName);
+          if (sequence != null) {
+              XmlSchemaComplexType parameterType = new XmlSchemaComplexType(
+                      xmlSchema);
+              QName parameterTypeName = new QName(
+                      Constants.AXIS2_ENUM_NAMESPACE_URI, enumClass,
+                      targetNamespacePrefix);
+              XmlSchemaSequence parameterSequence = new XmlSchemaSequence();
+              parameterSequence.getItems().add(entryElement);
+              parameterType.setParticle(parameterSequence);
+
+              XmlSchemaElement parameterElement = new XmlSchemaElement();
+              parameterElement.setName(parameterName);
+              if(isArrayType){
+                  parameterElement.setMaxOccurs(Long.MAX_VALUE);
+                  parameterElement.setMinOccurs(0);
+                  parameterElement.setNillable(true);
+              }
+              sequence.getItems().add(parameterElement);
+              parameterElement.setSchemaTypeName(parameterTypeName);
+              return parameterTypeName;
+          }
+//          return enumTypeName;
+          return enumQname;
+      }else{
+        // if classType is not enum
+          return null;
+      }
+    }
+
 }
\ No newline at end of file

Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/TypeTable.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/TypeTable.java?rev=1163991&r1=1163990&r2=1163991&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/TypeTable.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/TypeTable.java Thu Sep  1 10:34:45 2011
@@ -44,6 +44,8 @@ public class TypeTable {
 
     private HashMap<String,QName> complexTypeMap;
 
+    private HashMap<String , QName> simpleTypeEnum;
+
     /**
      * this map is used to keep the class names with the Qnames.
      */
@@ -59,6 +61,9 @@ public class TypeTable {
         //instantiated
         complexTypeMap = new HashMap<String,QName>();
         this.qNameToClassMap = new HashMap<QName, String>();
+
+        // keep qname of enum
+        simpleTypeEnum = new HashMap<String , QName>();
     }
 
     /* statically populate the simple type map  - this is not likely to
@@ -236,17 +241,34 @@ public class TypeTable {
      * Return the complex type map
      * @return  the map with complex types
      */
-    public Map<String,QName> getComplexSchemaMap() {
-        return complexTypeMap;
+    public Map<String,QName> getSimpleTypeEnumMap() {
+        return simpleTypeEnum;
+    }
+
+    public void addSimpleTypeEnum(String className, QName simpleSchemaType) {
+        simpleTypeEnum.put(className, simpleSchemaType);
     }
 
-    public void addComplexSchema(String name, QName schemaType) {
-        complexTypeMap.put(name, schemaType);
+    public QName getSimpleTypeEnum(String className) {
+        return (QName) simpleTypeEnum.get(className);
     }
 
-    public QName getComplexSchemaType(String name) {
-        return (QName) complexTypeMap.get(name);
-    }   
+    /**
+        * Return the complex type map
+        * @return  the map with complex types
+        */
+       public Map<String,QName> getComplexSchemaMap() {
+           return complexTypeMap;
+       }
+
+       public void addComplexSchema(String name, QName schemaType) {
+           complexTypeMap.put(name, schemaType);
+       }
+
+       public QName getComplexSchemaType(String name) {
+           return (QName) complexTypeMap.get(name);
+       }
+
  
     /**
      * Gets the class name for QName.