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 de...@apache.org on 2008/07/04 11:37:45 UTC
svn commit: r673977 - in /webservices/axis2/trunk/java/modules:
adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java
Author: deepal
Date: Fri Jul 4 02:37:45 2008
New Revision: 673977
URL: http://svn.apache.org/viewvc?rev=673977&view=rev
Log:
Added a way to control the attribute sort , just add the following parameter into services.xml
<parameter name=”SortAttributes”>false</paramter>
Modified:
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java?rev=673977&r1=673976&r2=673977&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java Fri Jul 4 02:37:45 2008
@@ -31,6 +31,7 @@
import org.apache.axis2.deployment.util.BeanExcludeInfo;
import org.apache.axis2.deployment.util.ExcludeInfo;
import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
import org.apache.axis2.description.java2wsdl.FieldComparator;
import org.apache.axis2.description.java2wsdl.TypeTable;
import org.apache.axis2.engine.ObjectSupplier;
@@ -86,6 +87,13 @@
if (MessageContext.getCurrentMessageContext() != null) {
axisService = MessageContext.getCurrentMessageContext().getAxisService();
}
+ boolean sortAttributes = true;
+ if (axisService != null) {
+ Parameter sortAtt = axisService.getParameter("SortAttributes");
+ if (sortAtt !=null && "false".equals(sortAtt.getValue())){
+ sortAttributes = false;
+ }
+ }
BeanExcludeInfo beanExcludeInfo = null;
Class beanClass = beanObject.getClass();
if (axisService != null && axisService.getExcludeInfo() != null) {
@@ -124,7 +132,9 @@
Field jProperty = (Field)propertyList.get(i);
properties[i] = jProperty;
}
- Arrays.sort(properties , new FieldComparator());
+ if (sortAttributes) {
+ Arrays.sort(properties , new FieldComparator());
+ }
BeanInfo beanInfo = Introspector.getBeanInfo(beanObject.getClass());
PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
HashMap propertMap = new HashMap();
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java?rev=673977&r1=673976&r2=673977&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java Fri Jul 4 02:37:45 2008
@@ -22,10 +22,7 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.deployment.util.BeanExcludeInfo;
import org.apache.axis2.deployment.util.Utils;
-import org.apache.axis2.description.AxisMessage;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.*;
import org.apache.axis2.description.java2wsdl.bytecode.MethodTable;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
@@ -112,6 +109,8 @@
//To check whether we need to generate Schema element for Exception
protected boolean generateBaseException;
+ protected boolean sortAttributes = true;
+
public NamespaceGenerator getNsGen() throws Exception {
if (nsGen == null) {
nsGen = new DefaultNamespaceGenerator();
@@ -153,6 +152,12 @@
} else {
this.schema_namespace_prefix = SCHEMA_NAMESPACE_PRFIX;
}
+ if (service !=null ) {
+ Parameter sortAtt = service.getParameter("SortAttributes");
+ if (sortAtt !=null && "false".equals(sortAtt.getValue())){
+ sortAttributes = false;
+ }
+ }
}
//This will locad the custom schema file and add that into the schema map
@@ -546,7 +551,9 @@
}
}
Field[] properties = (Field[]) propertiesSet.toArray(new Field[0]);
- Arrays.sort(properties, new FieldComparator());
+ if (sortAttributes) {
+ Arrays.sort(properties, new FieldComparator());
+ }
for (int i = 0; i < properties.length; i++) {
Field property = properties[i];
boolean isArryType = property.getType().isArray();
@@ -593,7 +600,9 @@
// end patch for Annogen -21
Field[] froperties = (Field[]) FieldMap.values().toArray(new Field[0]);
- Arrays.sort(froperties);
+ if (sortAttributes) {
+ Arrays.sort(froperties);
+ }
for (int i = 0; i < froperties.length; i++) {
Field field = froperties[i];