Author: gawor
Date: Fri Mar 25 18:50:47 2011
New Revision: 1085514
URL: http://svn.apache.org/viewvc?rev=1085514&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/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java
Modified:
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java?rev=1085514&r1=1085513&r2=1085514&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
(original)
+++
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
Fri Mar 25 18:50:47 2011
@@ -96,6 +96,7 @@ 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";
/**
* Context Property:
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=1085514&r1=1085513&r2=1085514&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
Fri Mar 25 18:50:47 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);
+ }
+ });
+ }
}