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 2007/12/03 06:26:05 UTC

svn commit: r600427 - in /webservices/axis2/trunk/java/modules: adb/src/org/apache/axis2/databinding/utils/ kernel/src/org/apache/axis2/deployment/ kernel/src/org/apache/axis2/deployment/util/ kernel/src/org/apache/axis2/description/ kernel/src/org/apa...

Author: deepal
Date: Sun Dec  2 21:25:49 2007
New Revision: 600427

URL: http://svn.apache.org/viewvc?rev=600427&view=rev
Log:
Implemented bean property exclude support , to exclude property or properties form a bean(s) need to add the following parameter to services.xml

<parameter name="excludeBeans">
    <bean class="sample.Address" excludeProperties="street" />
    <bean class="sample.AddressParent" excludeProperties="abc" />
</parameter>

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/deployment/DeploymentConstants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.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=600427&r1=600426&r2=600427&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 Sun Dec  2 21:25:49 2007
@@ -24,7 +24,9 @@
 import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
 import org.apache.axiom.om.util.Base64;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.java2wsdl.TypeTable;
+import org.apache.axis2.description.AxisService;
 import org.apache.axis2.databinding.typemapping.SimpleTypeMapper;
 import org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl;
 import org.apache.axis2.engine.ObjectSupplier;
@@ -103,18 +105,37 @@
                                             "elementName");
             }
 
+            AxisService axisService = MessageContext.getCurrentMessageContext().getAxisService();
+            ArrayList excludes = null;
+            if (axisService.getBeanExludeMap() !=null) {
+                excludes = (ArrayList) axisService.getBeanExludeMap().get(
+                        jClass.getQualifiedName());
+            }
             // properties from JAM
             ArrayList propertyList = new ArrayList();
             JProperty properties [] = jClass.getDeclaredProperties();
             for (int i = 0; i < properties.length; i++) {
                 JProperty property = properties[i];
+                //Excluding properties if it is suppose to be
+                if(excludes != null && excludes.contains(
+                        getCorrectName(getCorrectName(property.getSimpleName())))) {
+                    continue;
+                }
                 propertyList.add(property);
             }
             JClass supClass = jClass.getSuperclass();
             while (!"java.lang.Object".equals(supClass.getQualifiedName())) {
                 properties = supClass.getDeclaredProperties();
+                  excludes = (ArrayList) axisService.getBeanExludeMap().get(
+                        supClass.getQualifiedName());
+
                 for (int i = 0; i < properties.length; i++) {
                     JProperty property = properties[i];
+                    //Excluding properties if it is suppose to be
+                    if(excludes != null && excludes.contains(
+                            getCorrectName(getCorrectName(property.getSimpleName())))) {
+                        continue;
+                    }
                     propertyList.add(property);
                 }
                 supClass = supClass.getSuperclass();

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java?rev=600427&r1=600426&r2=600427&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java Sun Dec  2 21:25:49 2007
@@ -91,6 +91,7 @@
     String TAG_DISPATCHER = "dispatcher";
     String TAG_DESCRIPTION = "Description";
     String TAG_CLASS_NAME = "class";
+    String TAG_EXCLUDE_PROPERTIES= "excludeProperties";
     String TAG_AFTER = "after";
     String TAG_BEFORE = "before";
     String TAG_SUPPORTED_POLICY_NAMESPACES = "supported-policy-namespaces";

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java?rev=600427&r1=600426&r2=600427&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java Sun Dec  2 21:25:49 2007
@@ -27,15 +27,7 @@
 import org.apache.axis2.dataretrieval.DRConstants;
 import org.apache.axis2.deployment.util.PhasesInfo;
 import org.apache.axis2.deployment.util.Utils;
-import org.apache.axis2.description.AxisMessage;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisOperationFactory;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.InOutAxisOperation;
-import org.apache.axis2.description.ModuleConfiguration;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.description.PolicyInclude;
-import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.*;
 import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
 import org.apache.axis2.description.java2wsdl.TypeTable;
 import org.apache.axis2.engine.MessageReceiver;
@@ -43,6 +35,7 @@
 import org.apache.axis2.engine.ServiceLifeCycle;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.util.Loader;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -124,6 +117,13 @@
             Iterator itr = service_element.getChildrenWithName(new QName(TAG_PARAMETER));
             processParameters(itr, service, service.getParent());
 
+            //If multiple services in one service group have different values for the PARENT_FIRST
+            //  parameter then the final value become the value specified by the last service in the group
+//            Parameter parameter = service.getParameter(DeploymentClassLoader.PARENT_FIRST);
+//            if (parameter !=null && "false".equals(parameter.getValue())) {
+//                ClassLoader serviceClassLoader = service.getClassLoader();
+//                ((DeploymentClassLoader)serviceClassLoader).setParentFirst(false);
+//            }
             // process service description
             OMElement descriptionElement =
                     service_element.getFirstChildWithName(new QName(TAG_DESCRIPTION));
@@ -334,6 +334,7 @@
             // Set the default message receiver for the operations that were
             // not listed in the services.xml
             setDefaultMessageReceivers();
+            Utils.processBeanPropertyExclude(service);
             if (!service.isUseUserWSDL()) {
                 // Generating schema for the service if the impl class is Java
                 if (!service.isWsdlFound()) {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=600427&r1=600426&r2=600427&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java Sun Dec  2 21:25:49 2007
@@ -26,6 +26,7 @@
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.deployment.DeploymentClassLoader;
 import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.deployment.DeploymentConstants;
 import org.apache.axis2.deployment.repository.util.ArchiveReader;
 import org.apache.axis2.deployment.repository.util.DeploymentFileData;
 import org.apache.axis2.description.AxisModule;
@@ -68,14 +69,7 @@
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Stack;
-import java.util.StringTokenizer;
+import java.util.*;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
@@ -671,6 +665,48 @@
         File file =
                 new File(path.replace('/', File.separatorChar).replace('|', ':'));
         return file;
+    }
+
+    /**
+     * This method is to process bean exclude parameter and the XML format of that would be
+     * <parameter name="excludeBeans">
+     *     <bean class="full qualified class name" excludeProperties="name,age"/>+
+     * </parameter>
+     * @param service , AxisService object
+     */
+    public static void processBeanPropertyExclude(AxisService  service){
+        Parameter excludeBeanProperty = service.getParameter("excludeBeans");
+        if (excludeBeanProperty != null) {
+            OMElement parameterElement = excludeBeanProperty.getParameterElement();
+            Iterator bneasItr =parameterElement.getChildrenWithName(new QName("bean"));
+            HashMap beanMap = new HashMap();
+            while (bneasItr.hasNext()) {
+                OMElement bean = (OMElement) bneasItr.next();
+                String clazz = bean.getAttributeValue(
+                        new QName(DeploymentConstants.TAG_CLASS_NAME));
+                String value = bean.getAttributeValue(
+                        new QName(DeploymentConstants.TAG_EXCLUDE_PROPERTIES));
+                if (clazz != null && value != null) {
+                    beanMap.put(clazz,getArrayFromString(value));
+                }
+            }
+            service.setBeanExludeMap(beanMap);
+        }
+    }
+
+    /**
+     * This will split a bean exclude property values into ArrayList
+     * @param value : String to be splited
+     * @return : Arryalist of the splited string
+     */
+    private static List getArrayFromString(String value) {
+        String values [] = value.split(",");
+        ArrayList list = new ArrayList();
+        for (int i = 0; i < values.length; i++) {
+            String s = values[i];
+            list.add(s);
+        }
+       return list;
     }
 
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java?rev=600427&r1=600426&r2=600427&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java Sun Dec  2 21:25:49 2007
@@ -240,6 +240,9 @@
     // package to namespace mapping
     private Map p2nMap;
 
+    //To keep the bean property exclude map
+    private Map beanExludeMap;
+
     private TypeTable typeTable;
 
     // Data Locators for  WS-Mex Support
@@ -1876,6 +1879,7 @@
         map.put(Java2WSDLConstants.DEFAULT_SCHEMA_NAMESPACE_PREFIX,
                 Java2WSDLConstants.URI_2001_SCHEMA_XSD);
         axisService.setNameSpacesMap(map);
+        Utils.processBeanPropertyExclude(axisService);
         axisService.setElementFormDefault(false);
         try {
             axisService.addSchema(schemaGenerator.generateSchema());
@@ -2559,5 +2563,14 @@
 
     public String toString() {
         return getName();
+    }
+
+
+    public Map getBeanExludeMap() {
+        return beanExludeMap;
+    }
+
+    public void setBeanExludeMap(Map beanExludeMap) {
+        this.beanExludeMap = beanExludeMap;
     }
 }

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=600427&r1=600426&r2=600427&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 Sun Dec  2 21:25:49 2007
@@ -34,7 +34,6 @@
 import org.codehaus.jam.*;
 
 import javax.xml.namespace.QName;
-import javax.activation.DataHandler;
 import java.util.*;
 
 public class DefaultSchemaGenerator implements Java2WSDLConstants, SchemaGenerator {
@@ -409,8 +408,8 @@
 
     /**
      * Generate schema construct for given type
-     *
-     * @param javaType
+     * @param javaType : Class to whcih need to generate Schema
+     * @return : Generated QName
      */
     private QName generateSchema(JClass javaType) throws Exception {
         String name = getQualifiedName(javaType);
@@ -502,7 +501,16 @@
             Set propertiesNames = new HashSet();
 
             JProperty[] tempProperties = javaType.getDeclaredProperties();
+            ArrayList excludes = null;
+            if (service.getBeanExludeMap() !=null) {
+                excludes = (ArrayList) service.getBeanExludeMap().get(
+                        javaType.getQualifiedName());
+            }
             for (int i = 0; i < tempProperties.length; i++) {
+                if(excludes != null && excludes.contains(
+                        getCorrectName(tempProperties[i].getSimpleName()))) {
+                    continue;
+                }
                 propertiesSet.add(tempProperties[i]);
             }
 

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java?rev=600427&r1=600426&r2=600427&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java Sun Dec  2 21:25:49 2007
@@ -403,8 +403,17 @@
             Set propertiesSet = new HashSet();
             Set propertiesNames = new HashSet();
 
+            ArrayList excludes = null;
+            if (service.getBeanExludeMap() !=null) {
+                excludes = (ArrayList) service.getBeanExludeMap().get(
+                        javaType.getQualifiedName());
+            }
             JProperty[] tempProperties = javaType.getDeclaredProperties();
             for (int i = 0; i < tempProperties.length; i++) {
+                if(excludes != null && excludes.contains(
+                        getCorrectName(tempProperties[i].getSimpleName()))) {
+                    continue;
+                }
                 propertiesSet.add(tempProperties[i]);
             }
 



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