You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by di...@apache.org on 2004/10/31 16:27:12 UTC
svn commit: rev 56139 - incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model
Author: dims
Date: Sun Oct 31 07:27:11 2004
New Revision: 56139
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java
Log:
Patch from wolfgang127us@yahoo.co.jp <wo...@yahoo.co.jp>
===========================================================
I have a checkin request for wsm.
The attachment(proc_diff.txt) is a patch for WebServiceTYPEMetadata.java
A validateDuplicatedMethods() method is added in the class.
It checks if there're duplicated methods in the object model.
The duplicated methods are something like as follows.
@WebMethod(operationName = "Ope")
public boolean getNutty(int a);
@WebMethod(operationName = "Ope")
public boolean getHome(int a);
and
@WebMethod(operationName = "Ope")
public boolean getNutty(int a);
@WebMethod
public boolean Ope(int a);
When they are converted in an object model, they will
have same operationName and same parameters.
( Thus, Axis treats them as exactly same methods so that
it will throw an exception when generating WSDL. )
The validateDuplicatedMethods() method prevents it.
===========================================================
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java Sun Oct 31 07:27:11 2004
@@ -447,6 +447,109 @@
") not on classpath");
}
}
+
+ validateDuplicatedMethods();
+ }
+
+ /**
+ * Verifies duplicated methods in object model.
+ *
+ * When a object model is created from the class having the following combinations
+ * of methods, duplicated methods will appear in the object model.
+ * Thus, we gotta prevent it.
+ *
+ * --------------------------------
+ * @WebMethod(operationName = "Ope")
+ * @WebResult
+ * public boolean getNutty(int a);
+ *
+ * @WebMethod(operationName = "Ope")
+ * @WebResult
+ * public boolean getHome(int a);
+ * --------------------------------
+ * or
+ * --------------------------------
+ * @WebMethod(operationName = "Ope")
+ * @WebResult
+ * public boolean getNutty(int a);
+ *
+ * @WebMethod
+ * @WebResult
+ * public boolean Ope(int a);
+ * --------------------------------
+ *
+ *
+ * Need better name of this method ...
+ */
+ private void validateDuplicatedMethods () throws ValidationException
+ {
+ WebServiceMETHODMetadata[] methods = getMethods().toArray(new WebServiceMETHODMetadata[]{});
+ for ( int i = 0 ; i < methods.length ; i++ )
+ {
+ WebServiceMETHODMetadata method = methods[i];
+ String methodName = method.getWmOperationName();
+ for ( int k = 0 ; k < methods.length ; k++ )
+ {
+ if ( i == k ) continue; // skip the same method.
+
+ WebServiceMETHODMetadata method_ = methods[k];
+ if ( methodName.equals( method_.getWmOperationName() ) )
+ {
+ // Found the duplicated method's name !
+ // make sure just an overloading method or duplicated method signature.
+
+ if ( hasSameParameterTypes ( method, method_ ) )
+ {
+ if (0 < seiClassName.length())
+ {
+ throw new ValidationException("There're duplicated operationName ( "
+ + method.getWmOperationName() + " ) of methods, ( "
+ + method.getJavaMethodName() + " ) and ( "
+ + method_.getJavaMethodName() + " ) , in class ( "
+ + seiClassName + " )" );
+ }
+ else
+ {
+ throw new ValidationException("There're duplicated operationName ( "
+ + method.getWmOperationName() + " ) of methods, ( "
+ + method.getJavaMethodName() + " ) and ( "
+ + method_.getJavaMethodName() + " ) , in class ( "
+ + sibClassName + " )" );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks the specified two methods has same paramater types.
+ *
+ * @param m1
+ * @param m2
+ * @return boolean
+ */
+ private boolean hasSameParameterTypes ( WebServiceMETHODMetadata m1, WebServiceMETHODMetadata m2 )
+ {
+
+ WebServicePARAMETERMetadata[] params1 = m1.getParams().toArray( new WebServicePARAMETERMetadata[]{} );
+ WebServicePARAMETERMetadata[] params2 = m2.getParams().toArray( new WebServicePARAMETERMetadata[]{} );
+
+ // check number of parameters.
+ if ( params1.length != params2.length )
+ {
+ return false;
+ }
+
+ for ( int i = 0 ; i < params1.length ; i++ )
+ {
+ if ( params1[i].getJavaType() != params2[i].getJavaType() )
+ {
+ return false;
+ }
+ }
+
+ return true;
}
/**