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 nt...@apache.org on 2010/08/19 17:44:00 UTC

svn commit: r987195 - in /axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws: description/ description/impl/ i18n/

Author: nthaker
Date: Thu Aug 19 15:43:59 2010
New Revision: 987195

URL: http://svn.apache.org/viewvc?rev=987195&view=rev
Log:
AXIS2-4801
Adding warning message for new @Webmethod behavior on JAX-WS2.2 for migrating applications.

Modified:
    axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/MethodRetriever.java
    axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java
    axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java
    axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImpl.java
    axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties

Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/MethodRetriever.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/MethodRetriever.java?rev=987195&r1=987194&r2=987195&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/MethodRetriever.java (original)
+++ axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/MethodRetriever.java Thu Aug 19 15:43:59 2010
@@ -55,7 +55,15 @@ public abstract class MethodRetriever {
 
     //Logging setup
     private static final Log log = LogFactory.getLog(MethodRetriever.class);
-    
+    private String legacyWebMethod = null;
+    public String getLegacyWebMethod() {
+        return legacyWebMethod;
+    }
+
+    public void setLegacyWebMethod(String legacyWebMethod) {
+        this.legacyWebMethod = legacyWebMethod;
+    }
+
     protected MethodRetriever() {}
 
     /*

Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java?rev=987195&r1=987194&r2=987195&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java (original)
+++ axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java Thu Aug 19 15:43:59 2010
@@ -126,7 +126,21 @@ public class DescriptionUtils {
 
         return mdcList;
     }
-
+    
+    static boolean isWebmethodDefined(DescriptionBuilderComposite dbc){
+        if(dbc == null){
+            return false;
+        }
+        Iterator<MethodDescriptionComposite> iter = dbc.getMethodDescriptionsList().iterator();
+        while (iter.hasNext()) {
+            MethodDescriptionComposite mdc = iter.next();
+            if (mdc!=null && mdc.getWebMethodAnnot() != null) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
     /*
       * Check whether a MethodDescriptionComposite contains a WebMethod annotation with
       * exlude set to true

Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java?rev=987195&r1=987194&r2=987195&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java (original)
+++ axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java Thu Aug 19 15:43:59 2010
@@ -836,7 +836,8 @@ public class EndpointInterfaceDescriptio
         }
         //Now based on the outcome of LegacyWebmethod and sun property check, retrieve methods to expose.
         methodRetriever = newSunBehavior ? new PostRI216MethodRetrieverImpl(dbc, this) : new LegacyMethodRetrieverImpl(dbc, this);
-        
+        //set LegacyWebmethod Definition on MethodRetriever.
+        methodRetriever.setLegacyWebMethod(legacyWebmethod);
         if(log.isDebugEnabled()) {
             if (newSunBehavior) {
                 log.debug("getMethodRetriever: returning a PostRI216MethodRetrieverImpl");

Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImpl.java?rev=987195&r1=987194&r2=987195&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImpl.java (original)
+++ axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImpl.java Thu Aug 19 15:43:59 2010
@@ -34,6 +34,8 @@ import org.apache.axis2.jaxws.i18n.Messa
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import com.ibm.xylem.ISpecialForm;
+
 /**
  * PostRI216MethodRetrieverImpl subclass implements the new SUN RI interpretation for
  * annotation processing. See MethodRetriever superclass...
@@ -51,11 +53,10 @@ public class PostRI216MethodRetrieverImp
 
     //Logging setup
     private static final Log log = LogFactory.getLog(PostRI216MethodRetrieverImpl.class);
+    
+    private EndpointInterfaceDescriptionImpl eid = null;
 
-   private EndpointInterfaceDescriptionImpl eid = null;
-
-   private DescriptionBuilderComposite dbc = null;
-
+    private DescriptionBuilderComposite dbc = null;
     public PostRI216MethodRetrieverImpl (DescriptionBuilderComposite dbc, 
         EndpointInterfaceDescriptionImpl eid)  {
         super();
@@ -133,6 +134,25 @@ public class PostRI216MethodRetrieverImp
                 tempDBC = superDBC;
             } //Done with implied SEI's superclasses
             retrieveList = removeOverriddenMethods(retrieveList, dbc, eid);
+            //Let check to see if there where any operations with @Webmethod
+            //If LeagcyWebmethod is NOT defined i.e default and if there 
+            //are operations with @Webmethod annotation, then lets warn the
+            //user that we may be exposing public operation that they did not
+            //intend to expose, this can happen if user is migrating application
+            //from old JAX-WS tooling version.
+            //Let also inform user that if they can use LegacyWebmethod to expose 
+            //Only those operations that have @webmethod(exclude=false) annotation on them.
+            boolean isWebmethodDefined = DescriptionUtils.isWebmethodDefined(dbc);
+            Iterator<MethodDescriptionComposite> iter = retrieveList.iterator();
+            while(iter.hasNext()){
+                MethodDescriptionComposite mdc = iter.next();
+                //If user defined a legacyWemethod, has atleast one operation with @Wemethod annotation
+                //and this is a public operation with no @Webmethod operation that is being exposed then
+                //lets warn user of possible security exposure.
+                if(getLegacyWebMethod()==null && isWebmethodDefined && mdc.getWebMethodAnnot()==null && !isConstructor(mdc)){                      
+                  log.warn(Messages.getMessage("MethodRetrieverWarning1", mdc.getMethodName()));                     
+                }
+            }
         }//Done with implied SEI's
 
         return retrieveList.iterator();
@@ -152,7 +172,8 @@ public class PostRI216MethodRetrieverImp
         List<MethodDescriptionComposite> mdcList = dbc.getMethodDescriptionsList();
 
         if (mdcList != null) {
-            iter = dbc.getMethodDescriptionsList().iterator();
+            iter = dbc.getMethodDescriptionsList().iterator();           
+            boolean isWebmethodDefined = DescriptionUtils.isWebmethodDefined(dbc);
             while (iter.hasNext()) {
                 MethodDescriptionComposite mdc = iter.next();
                 //flag to check if the method can be exposed as webservice.
@@ -168,10 +189,14 @@ public class PostRI216MethodRetrieverImp
                     retrieveList.add(mdc);
                 }
             }
+            
         }
 
         return retrieveList;
     }
-
+    
+    private boolean isConstructor(MethodDescriptionComposite mdc){
+        return mdc.getMethodName().equals("<init>");
+    }
 
 }

Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties?rev=987195&r1=987194&r2=987195&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties (original)
+++ axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties Thu Aug 19 15:43:59 2010
@@ -353,3 +353,4 @@ axisEndpointReferenceFactoryErr=Cannot c
 axisEndpointReferenceFactoryErr2=Cannot create an endpoint reference because the address, service name, and/or port name are null.
 dispatchInvalidTypeWithMode=Unsupported Dispatch Type: Dispatch type javax.xml.soap.SOAPMessage cannot be used with messages in Payload mode.
 serviceDelegateConstruct2=An attempt was made to construct the ServiceDelegate object with the {0} service and with WebServicesFeatures, but there are no standard features defined for service creation in the current specification.
+MethodRetrieverWarning1=Public method {0} will be exposed as a Web Service operation per JAX-WS 2.2 tooling rules. If you intend to expose only operations that have @WebMethod annotation, set the manifest property 'LegacyWebmethod: true' or set a JVM property 'jaxws.runtime.legacyWebMethod=true'. 
\ No newline at end of file