Author: gawor
Date: Fri Mar 25 19:06:08 2011
New Revision: 1085521

URL: http://svn.apache.org/viewvc?rev=1085521&view=rev
Log:
AXIS2-4984: Use a property to force to use the post web method rules. Patch 
from Ivan. Also cleaned up the code a bit and removed unused private functions

Modified:
    axis/axis2/java/core/branches/1_6/   (props changed)
    
axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
    
axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java

Propchange: axis/axis2/java/core/branches/1_6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 25 19:06:08 2011
@@ -1 +1 @@
-/axis/axis2/java/core/trunk:1070439,1072077,1072271,1072499,1072510,1078242,1081563,1081587,1081590,1082316,1082322,1082702,1082726,1082738,1083180,1083192,1083379,1083381,1083425,1083433,1083446,1084753
+/axis/axis2/java/core/trunk:1070439,1072077,1072271,1072499,1072510,1078242,1081563,1081587,1081590,1082316,1082322,1082702,1082726,1082738,1083180,1083192,1083379,1083381,1083425,1083433,1083446,1084753,1085514

Modified: 
axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java?rev=1085521&r1=1085520&r2=1085521&view=diff
==============================================================================
--- 
axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
 (original)
+++ 
axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
 Fri Mar 25 19:06:08 2011
@@ -96,5 +96,6 @@ public class MDQConstants {
     public static final String USE_LEGACY_WEB_METHOD_RULES = 
"jaxws.runtime.legacyWebMethod";
     public static final String USE_MANIFEST_LEGACY_WEB_METHOD_RULES = 
"LegacyWebMethod";
     public static final String SUN_WEB_METHOD_BEHAVIOR_CHANGE_VERSION = 
"2.1.6";
+    public static final String USE_POST_WEB_METHOD_RULES = 
"jaxws.runtime.usePostWebMethodRules";
 
 }

Modified: 
axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java?rev=1085521&r1=1085520&r2=1085521&view=diff
==============================================================================
--- 
axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java
 (original)
+++ 
axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java
 Fri Mar 25 19:06:08 2011
@@ -21,10 +21,8 @@
 package org.apache.axis2.jaxws.description.impl;
 
 import java.io.IOException;
-import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
@@ -800,21 +798,7 @@ public class EndpointInterfaceDescriptio
         }
         return string.toString();
     }
-    /**
-     * Get an annotation.  This is wrappered to avoid a Java2Security 
violation.
-     * @param cls Class that contains annotation 
-     * @param annotation Class of requrested Annotation
-     * @return annotation or null
-     */
-    private static Annotation getAnnotation(final Class cls, final Class 
annotation) {
-        return (Annotation) AccessController.doPrivileged(new 
PrivilegedAction() {
-            public Object run() {
-                return cls.getAnnotation(annotation);
-            }
-        });
-    }
-    
-    
+      
     /*
      * This method returns a method retriever that properly implements the 
specified behavior, 
      * which is determined by a user-defined system property
@@ -823,29 +807,39 @@ public class EndpointInterfaceDescriptio
 
         MethodRetriever methodRetriever = null;
         //default behavior
-        boolean newSunBehavior = true;
-        //Lets make sure the default behavior is supported by packaged JDK.
-        //this check verifies JAX-WS2.2 tooling is supported.
-        newSunBehavior = isNewSunBehaviorSupported();
-        
-        //The system property always overrides the manifest
-        //property. So, if both are set than the manifest property will be 
ignored
+        boolean newSunBehavior = false;
         
-        String legacyWebmethod = readLegacyWebMethodFlag();
-        if (WSToolingUtils.hasValue(legacyWebmethod) && 
legacyWebmethod.equalsIgnoreCase("true")) {
-            if (log.isDebugEnabled()){
-                log.debug("EndpointInterfaceDescriptionImpl: System or 
Manifest property USE_LEGACY_WEB_METHOD_RULES set to true" );
+        String legacyWebmethod = null;
+        String postWebMethodRules = readUsePostWebMethodRulesFlag();
+        if (WSToolingUtils.hasValue(postWebMethodRules) && 
postWebMethodRules.equalsIgnoreCase("true")) {
+            if (log.isDebugEnabled()) {
+                log.debug("EndpointInterfaceDescriptionImpl: System property " 
+ MDQConstants.USE_POST_WEB_METHOD_RULES + "  set to true, all other 
configurations are ignored");
             }
-            //LegacyWebmethod property set to true, use old JAX-WS tooling 
behavior.  
-            newSunBehavior = false;
-        }else {
-            //If LegacyWebmehtod was not set check for sun property.
-            String newSunRulesFlag = getNewSunRulesFlag();
-            if (WSToolingUtils.hasValue(newSunRulesFlag) && 
newSunRulesFlag.equalsIgnoreCase("true")) {
-                if (log.isDebugEnabled()){
-                    log.debug("EndpointInterfaceDescriptionImpl: System 
property USE_LEGACY_WEB_METHOD_RULES_SUN set to true" );
+            newSunBehavior = true;
+        } else {
+            //Lets make sure the default behavior is supported by packaged JDK.
+            //this check verifies JAX-WS2.2 tooling is supported.
+            newSunBehavior = isNewSunBehaviorSupported();
+
+            //The system property always overrides the manifest
+            //property. So, if both are set than the manifest property will be 
ignored
+
+            legacyWebmethod = readLegacyWebMethodFlag();
+            if (WSToolingUtils.hasValue(legacyWebmethod) && 
legacyWebmethod.equalsIgnoreCase("true")) {
+                if (log.isDebugEnabled()) {
+                    log.debug("EndpointInterfaceDescriptionImpl: System or 
Manifest property " + MDQConstants.USE_LEGACY_WEB_METHOD_RULES + " set to 
true");
+                }
+                //LegacyWebmethod property set to true, use old JAX-WS tooling 
behavior.  
+                newSunBehavior = false;
+            } else {
+                //If LegacyWebmehtod was not set check for sun property.
+                String newSunRulesFlag = getNewSunRulesFlag();
+                if (WSToolingUtils.hasValue(newSunRulesFlag) && 
newSunRulesFlag.equalsIgnoreCase("true")) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("EndpointInterfaceDescriptionImpl: System 
property " + MDQConstants.USE_LEGACY_WEB_METHOD_RULES_SUN + " set to true");
+                    }
+                    newSunBehavior = false;
                 }
-                newSunBehavior = false;;
             }
         }
         //Now based on the outcome of LegacyWebmethod and sun property check, 
retrieve methods to expose.
@@ -871,68 +865,15 @@ public class EndpointInterfaceDescriptio
      * @param propertyToSet
      * @return
      */
-    private boolean isNewSunBehavior(String propertyToSet) {
-
-        if (log.isDebugEnabled()) {
-            log.debug("isNewSunBehavior: Validating that JDK version can be 
used with property: " +propertyToSet);
-
-        }
-        
-        boolean versionValid = false;
-
-        try {
-            
-            String wsGenVersion = WSToolingUtils.getWsGenVersion();
-            
-            versionValid = WSToolingUtils.isValidVersion(wsGenVersion);
-            
-            if (log.isDebugEnabled()) {
-                log.debug("isNewSunBehavior: versionValid is: " +versionValid);
-            }
-            
-            if (!versionValid) {
-
-                if (log.isWarnEnabled()) {
-                    log.warn("You are attempting set a property: "
-                        + propertyToSet
-                        + " This property is not supported with this version 
of the JDK");
-                }
-            }
-
-            // We don't want to affect existing systems, if anything goes
-            // wrong just display
-            // a warning and default to old behavior
-        } catch (ClassNotFoundException e) {
-            if (log.isWarnEnabled()) {
-                log.warn(" Unable to determine WsGen version being used");
-            }
-        } catch (IOException ioex) {
-            if (log.isWarnEnabled()) {
-                log.warn(" Unable to determine WsGen version being used");
-            }
-        }
-        
-        return versionValid;
-    }
-    /**
-     * The user has indicated that they want to use the new Sun behavior 
(regardless) of which flag 
-     * they were using.
-     * This method determines whether we have the proper JDK version for using 
the new SUN behavior for
-     * retrieving methods. We determine this by checking the version of WsGen.
-     * @param propertyToSet
-     * @return
-     */
     private boolean isNewSunBehaviorSupported() {
 
         if (log.isDebugEnabled()) {
             log.debug("isNewSunBehavior: Validating that JDK version can be 
used");
-
         }
         
         boolean versionValid = false;
 
-        try {
-            
+        try {            
             String wsGenVersion = WSToolingUtils.getWsGenVersion();
             
             versionValid = WSToolingUtils.isValidVersion(wsGenVersion);
@@ -942,7 +883,6 @@ public class EndpointInterfaceDescriptio
             }
             
             if (!versionValid) {
-
                 if (log.isDebugEnabled()) {
                     log.debug("New Sun tooling behavior is not supported with 
this version of the JDK");
                 }
@@ -963,19 +903,11 @@ public class EndpointInterfaceDescriptio
         
         return versionValid;
     }
+    
     private String readLegacyWebMethodFlag () {
-        
-       String legacyWebmethod= null;
-            
+        String legacyWebmethod = null;
         try {
-            legacyWebmethod = (String) AccessController.doPrivileged(
-                new PrivilegedExceptionAction() {
-                    public Object run() {
-                        //System property takes precedence over manifest 
property.
-                        //So first lets check for system property.
-                        return 
(System.getProperty(MDQConstants.USE_LEGACY_WEB_METHOD_RULES));
-                    }
-                });
+            legacyWebmethod = 
getSystemProperty(MDQConstants.USE_LEGACY_WEB_METHOD_RULES);
         } catch (PrivilegedActionException e) {
             // Swallow and continue
             if (log.isWarnEnabled()) {
@@ -1018,16 +950,9 @@ public class EndpointInterfaceDescriptio
     }
     
     private static String getNewSunRulesFlag () {
-        
         String newSunRulesFlag = null;
-            
         try {
-            newSunRulesFlag = (String) AccessController.doPrivileged(
-                new PrivilegedExceptionAction() {
-                    public Object run() {
-                        return 
(System.getProperty(MDQConstants.USE_LEGACY_WEB_METHOD_RULES_SUN));
-                    }
-                });
+            newSunRulesFlag = 
getSystemProperty(MDQConstants.USE_LEGACY_WEB_METHOD_RULES_SUN);
         } catch (PrivilegedActionException e) {
             // Swallow and continue
             if (log.isWarnEnabled()) {
@@ -1047,5 +972,33 @@ public class EndpointInterfaceDescriptio
         return newSunRulesFlag;
     }
     
+    private String readUsePostWebMethodRulesFlag() {
+        String usePostMethodRules = null;
+        try {
+            usePostMethodRules = 
getSystemProperty(MDQConstants.USE_POST_WEB_METHOD_RULES);
+        } catch (PrivilegedActionException e) {
+            // Swallow and continue
+            if (log.isWarnEnabled()) {
+                log.debug("Exception getting USE_POST_WEB_METHOD_RULES system 
property: " + e.getException());
+            }
+        }
+        if (WSToolingUtils.hasValue(usePostMethodRules)) {
+            if (log.isDebugEnabled()) {
+                log.debug("EndpointInterfaceDescriptionImpl: system property 
'" + MDQConstants.USE_POST_WEB_METHOD_RULES + "' is set with " + 
usePostMethodRules);                
+            }
+        } else {
+            if (log.isDebugEnabled()) {
+                log.debug("EndpointInterfaceDescriptionImpl: system property 
'" + MDQConstants.USE_POST_WEB_METHOD_RULES + "' is not set");
+            }
+        }
+        return usePostMethodRules;
+    }
 
+    private static String getSystemProperty(final String propertyName) throws 
PrivilegedActionException {
+        return AccessController.doPrivileged(new 
PrivilegedExceptionAction<String>() {
+            public String run() {
+                return System.getProperty(propertyName);
+            }
+        });
+    }
 }


Reply via email to