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/04/28 18:28:20 UTC
svn commit: r939003 - in /axis/axis2/java/core/trunk/modules/metadata:
src/org/apache/axis2/jaxws/description/impl/
src/org/apache/axis2/jaxws/util/ test/org/apache/axis2/jaxws/utils/
Author: nthaker
Date: Wed Apr 28 16:28:20 2010
New Revision: 939003
URL: http://svn.apache.org/viewvc?rev=939003&view=rev
Log:
Adding code to:
1)Modify logic of how JAX-WS tooling version is read by JAX-WS module.
2)Adding proper support for Legacy @Webmethod annotation behavior when JAX-WS 2.2 version is detected by runtime and user wants old behavior.
Added:
axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/utils/
axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/utils/WSToolingUtilsTests.java
Modified:
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/util/WSToolingUtils.java
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=939003&r1=939002&r2=939003&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 Wed Apr 28 16:28:20 2010
@@ -249,21 +249,47 @@ public class EndpointInterfaceDescriptio
AxisService axisService = getEndpointDescription().getAxisService();
AxisOperation axisOperation = axisService
.getOperation(OperationDescriptionImpl.determineOperationQName(this, mdc));
-
+
OperationDescription operation =
- new OperationDescriptionImpl(mdc, this, axisOperation);
-
- if (axisOperation == null) {
+ new OperationDescriptionImpl(mdc, this, axisOperation);
+ //In LegacyWebmethod case:
+ //1) if wsdl is defined then we should only expose operations that are in wsdl.
+ //NOTE:If wsdl is defined AxisService will have all operations found in wsdl,
+ //AxisServiceBuilder will do that part before metadata layer is invoked.
+ //2) if wsdl not defined we need to expose operations based on annotation, in
+ //which case we need add operations not found in AxisService.
+ if(getWSDLDefinition() != null){
+ if(log.isDebugEnabled()){
+ log.debug("wsdl definition found, we will not expose operation not found in AxisService.");
+ }
+ if (log.isDebugEnabled())
+ log.debug("EID: Just added operation= " + operation.getOperationName());
+ addOperation(operation);
+ }
+ //Since wsdl is not defined add all operations we found.
+ else if (axisOperation == null) {
+ if(log.isDebugEnabled()){
+ log.debug("wsdl defintion NOT found, we will expose operation using annotations.");
+ }
// This axisOperation did not already exist on the AxisService, and so was created
// with the OperationDescription, so we need to add the operation to the service
((OperationDescriptionImpl)operation).addToAxisService(axisService);
+ if (log.isDebugEnabled())
+ log.debug("EID: Just added operation= " + operation.getOperationName());
+ addOperation(operation);
+ }
+ //This check is to add operations in case an Async binding is used while generating
+ //jax-ws artifacts, So any async operation example invokeAsync is mapped to operation invoke.
+ //However, we will keep an operation Description that holds details of invokeAsync.
+ //this check will ensure Async operations get added to operation description list.
+ else if(axisOperation!=null && operation.getName().getLocalPart()!=mdc.getMethodName()){
+ if (log.isDebugEnabled())
+ log.debug("EID: Just added operation= " + operation.getOperationName());
+ addOperation(operation);
}
- if (log.isDebugEnabled())
- log.debug("EID: Just added operation= " + operation.getOperationName());
- addOperation(operation);
}
-
+
}
if (log.isDebugEnabled())
@@ -945,7 +971,7 @@ public class EndpointInterfaceDescriptio
}
}
- return newRulesFlag;
+ return newSunRulesFlag;
}
Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/util/WSToolingUtils.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/util/WSToolingUtils.java?rev=939003&r1=939002&r2=939003&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/util/WSToolingUtils.java (original)
+++ axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/util/WSToolingUtils.java Wed Apr 28 16:28:20 2010
@@ -23,10 +23,13 @@ import org.apache.axis2.java.security.Ac
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+
import java.io.IOException;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Properties;
+import java.util.StringTokenizer;
public class WSToolingUtils {
@@ -139,63 +142,86 @@ public class WSToolingUtils {
}
public static boolean isValidVersion(String wsGenVersion) {
+ if(log.isDebugEnabled()){
+ log.debug("Start isValidVersion(String)");
+ }
if (log.isDebugEnabled()) {
log.debug("isValidVersion: Determining if WsGen version: " +wsGenVersion
+" is appropriate version for using new SUN RI behavior");
}
-
+ if(wsGenVersion == null){
+ return false;
+ }
+ /*
+ * This algorithm is improvement over the old algorithm we had to validate the
+ * version. In this algorithm we don't assume that the format will be x.x.x.
+ * This algorithm looks for versionNumbers in a String token delimited by a
+ * ".", the idea is to look for the first digit in each token and compare that
+ * with the version validation requirements.
+ * we return false if version is less that 2.1.6.
+ * possible input version strings could be "JAX-WS RI 2.2-b05-", "2.1.6" "2.1.0" etc.
+ */
// Beginning of reuseable code
final int VERSION_FIELD_1 = 2;
final int VERSION_FIELD_2 = 1;
final int VERSION_FIELD_3 = 6;
String version = wsGenVersion.trim();
-
- //Algorithm assumption 1: We are assuming that the version string will always be
- // of the form "x.x.x" where x is a character (or series of characters) with each digit
- // having a converted integer value of 0 - 9.
- //Assumption 2: We are assuming thatWsgen version 2.1.6 is the starting version
- // for being able to use the new Sun behavior
-
- int dotIndex = version.indexOf(".");
- int subField = Integer.valueOf(version.substring(0, dotIndex));
-
- if (subField < VERSION_FIELD_1) {
- return false;
- } else if (subField > VERSION_FIELD_1) {
- //If we are greater than 2.x.x (i.e. 3.x.x) then version is valid
- return true;
- }
-
- String subString2 = version.substring(dotIndex + 1);
- dotIndex = subString2.indexOf(".");
- subField = Integer.valueOf(subString2.substring(0, dotIndex));
-
- if (subField < VERSION_FIELD_2) {
+
+ StringTokenizer st = new StringTokenizer(version, ".");
+ if(st.countTokens()<=0){
+ if(log.isDebugEnabled()){
+ log.debug("No Tokens to validate the tooling version, Input version String is invalid.");
+ }
return false;
- } else if (subField > VERSION_FIELD_2) {
- //If we are greater than 2.1.x (i.e. 2.2.x) then version is valid
- return true;
}
-
- //Final substring, will probably hit end of string. But, check to make sure there is not
- // another "." (i.e. We could have "2.1.6.1")yes.
- String subString3 = subString2.substring(dotIndex + 1);
-
- //Does string contain another dot? if so, just read up to that dot. Otherwise, assume that
- //this is the last sub-string
- dotIndex = subString3.indexOf(".");
- if (dotIndex == -1) {
- subField = Integer.valueOf(subString3);
- } else {
- subField = Integer.valueOf(subString3.substring(0, dotIndex));
+ for(int tokenCnt = 1;st.hasMoreTokens();tokenCnt++){
+ String token = st.nextToken();
+ if(token == null){
+ return false;
+ }
+ int versionNumber = getDigit(token);
+ if (tokenCnt==1 && versionNumber < VERSION_FIELD_1) {
+ if(log.isDebugEnabled()){
+ log.debug("Validation failed of tokenCnt="+tokenCnt);
+ log.debug("Input VersionNumber ="+versionNumber);
+ }
+ return false;
+ }
+ if(tokenCnt == 2 && versionNumber < VERSION_FIELD_2 ){
+ if(log.isDebugEnabled()){
+ log.debug("Validation failed of tokenCnt="+tokenCnt);
+ log.debug("Input VersionNumber ="+versionNumber);
+ }
+ return false;
+ }
+ if (tokenCnt==3 && versionNumber < VERSION_FIELD_3) {
+ if(log.isDebugEnabled()){
+ log.debug("Validation failed of tokenCnt="+tokenCnt);
+ log.debug("Input VersionNumber ="+versionNumber);
+ }
+ return false;
+ }
}
-
- if (subField < VERSION_FIELD_3) {
- return false;
+ if(log.isDebugEnabled()){
+ log.debug("Exit isValidVersion(String)");
}
return true;
}
+ /**
+ * look for first digit in the version token.
+ * @param s - version token.
+ * @return a digit or -1 if not digit found in the token.
+ */
+ private static int getDigit(String s){
+ for(int i=0;i<s.length();i++){
+ char ch = s.charAt(i);
+ if(Character.isDigit(ch)){
+ return Character.getNumericValue(ch);
+ }
+ }
+ return -1;
+ }
}
Added: axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/utils/WSToolingUtilsTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/utils/WSToolingUtilsTests.java?rev=939003&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/utils/WSToolingUtilsTests.java (added)
+++ axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/utils/WSToolingUtilsTests.java Wed Apr 28 16:28:20 2010
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.utils;
+
+import org.apache.axis2.jaxws.util.WSToolingUtils;
+
+import junit.framework.TestCase;
+
+
+public class WSToolingUtilsTests extends TestCase {
+ public void testisValidVersion(){
+ String wsGenVersion = "JAX-WS RI 2.2-b05-";
+ assertTrue(WSToolingUtils.isValidVersion(wsGenVersion));
+ wsGenVersion = "2.1.6";
+ assertTrue(WSToolingUtils.isValidVersion(wsGenVersion));
+ wsGenVersion = "2.1.0";
+ assertFalse(WSToolingUtils.isValidVersion(wsGenVersion));
+ wsGenVersion = "2.0.6";
+ assertFalse(WSToolingUtils.isValidVersion(wsGenVersion));
+ wsGenVersion = "1.1.6";
+ assertFalse(WSToolingUtils.isValidVersion(wsGenVersion));
+ }
+}