You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by mm...@apache.org on 2004/10/11 20:45:03 UTC

svn commit: rev 54607 - in incubator/beehive/trunk/wsm: drt/tests drt/tests/org/apache/beehive/wsm/jsr181/model src/runtime/org/apache/beehive/wsm/jsr181/model src/runtime/org/apache/beehive/wsm/jsr181/processor/apt src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection

Author: mmerz
Date: Mon Oct 11 11:45:02 2004
New Revision: 54607

Modified:
   incubator/beehive/trunk/wsm/drt/tests/Bar.java
   incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java
   incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
Log:
Made @WebMethod annotation optional for web methods -- Required by use case "endpointInterface". Also adapted test cases to reflect these changes.



Modified: incubator/beehive/trunk/wsm/drt/tests/Bar.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/Bar.java	(original)
+++ incubator/beehive/trunk/wsm/drt/tests/Bar.java	Mon Oct 11 11:45:02 2004
@@ -33,4 +33,9 @@
     {
         return;
     }
+
+    public int dropMoney(int amount)
+    {
+        return amount;
+    }
 }

Modified: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java	(original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java	Mon Oct 11 11:45:02 2004
@@ -18,6 +18,8 @@
  * $Header:$
  */
 
+import java.util.Collection;
+
 import junit.framework.TestCase;
 
 /**
@@ -145,9 +147,14 @@
 
     protected WebServiceMETHODMetadata getMethod(String methodName)
     {
+        if ((null == methodName) || (null == objectModel))
+        {
+            return null;
+        }
+
         for (WebServiceMETHODMetadata method : ((WebServiceTYPEMetadata) objectModel).getMethods())
         {
-            if (method.getWmOperationName().equals(methodName))
+            if (methodName.equals(method.getWmOperationName()))
             {
                 return method;
             }
@@ -157,9 +164,16 @@
 
     protected WebServicePARAMETERMetadata getParam(String methodName, int pos)
     {
-        for (WebServiceMETHODMetadata method : ((WebServiceTYPEMetadata) objectModel).getMethods())
+        if ((null == methodName) || (null == objectModel))
+        {
+            return null;
+        }
+        
+        Collection<WebServiceMETHODMetadata> webMethods =
+            ((WebServiceTYPEMetadata) objectModel).getMethods();
+        for (WebServiceMETHODMetadata method : webMethods)
         {
-            if (method.getWmOperationName().equals(methodName))
+            if (methodName.equals(method.getWmOperationName()))
             {
                 int i = 0;
                 for (WebServicePARAMETERMetadata param : method.getParams())

Modified: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java	(original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java	Mon Oct 11 11:45:02 2004
@@ -139,7 +139,7 @@
          * @WebMethod not required anymore -> endpointInterface/implementation bean
         try {
             WebServiceMETHODMetadata method =
-                new WebServiceMETHODMetadata(null, "methodname", void.class, false, null, null);
+                new WebServiceMETHODMetadata("methodname", void.class, false, null, null);
             fail("Error, the METHOD annotation should fail without @WebMethod");
         }
         catch (IllegalArgumentException e)
@@ -149,7 +149,7 @@
         
         try {
             WebServiceMETHODMetadata method =
-                new WebServiceMETHODMetadata(null, "methodname", void.class, false, methodAnnotations, null);
+                new WebServiceMETHODMetadata("methodname", void.class, false, methodAnnotations, null);
             fail("Error, the METHOD annotation should fail without @WebMethod");
         }
         catch (IllegalArgumentException e)
@@ -158,11 +158,10 @@
         }
          */
 
-        WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
-        methodAnnotations.add(mAnnotation);
+        methodAnnotations.add(new FakeWebMethodAnnotation("", ""));
         try {
             WebServiceMETHODMetadata method =
-                new WebServiceMETHODMetadata(mAnnotation, null, void.class, false, methodAnnotations, null);
+                new WebServiceMETHODMetadata(null, void.class, false, methodAnnotations, null);
             fail("Error, the METHOD annotation should fail without method name");
         }
         catch (IllegalArgumentException e)
@@ -171,7 +170,7 @@
         }
         try {
             WebServiceMETHODMetadata method =
-                new WebServiceMETHODMetadata(mAnnotation, "methodName", null,  false, methodAnnotations,null);
+                new WebServiceMETHODMetadata("methodName", null,  false, methodAnnotations,null);
             fail("Error, the METHOD annotation should fail without return type class");
         }
         catch (IllegalArgumentException e)
@@ -254,11 +253,10 @@
     public void testMETHODWebMethodDefaults() throws Exception
     {
         Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
-        WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
-        methodAnnotations.add(mAnnotation);
+        methodAnnotations.add(new FakeWebMethodAnnotation("", ""));
 
         WebServiceMETHODMetadata method =
-            new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+            new WebServiceMETHODMetadata("methodname", void.class, false, methodAnnotations, null);
         
         assertEquals("methodname", method.getWmOperationName());
         assertEquals("", method.getWmAction());
@@ -272,7 +270,7 @@
         methodAnnotations.add(mAnnotation);
         
         WebServiceMETHODMetadata method =
-            new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+            new WebServiceMETHODMetadata("methodname", void.class, false, methodAnnotations, null);
         
         assertEquals("operationname", method.getWmOperationName());
         assertEquals("action", method.getWmAction());
@@ -287,12 +285,10 @@
     public void testMETHODOneWayDefaults() throws Exception
     {
         Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
-        WebMethod mAnnotation =
-            new FakeWebMethodAnnotation("", "");
-        methodAnnotations.add(mAnnotation);
+        methodAnnotations.add(new FakeWebMethodAnnotation("", ""));
     
         WebServiceMETHODMetadata method =
-            new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+            new WebServiceMETHODMetadata("methodname", void.class, false, methodAnnotations, null);
         
         assertFalse(method.isOneWay());
     }
@@ -300,12 +296,11 @@
     public void testMETHODOneWay() throws Exception
     {
         Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
-        WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
-        methodAnnotations.add(mAnnotation);
+        methodAnnotations.add(new FakeWebMethodAnnotation("", ""));
         methodAnnotations.add(new FakeOneWayAnnotation());
     
         WebServiceMETHODMetadata method =
-            new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+            new WebServiceMETHODMetadata("methodname", void.class, false, methodAnnotations, null);
         
         assertTrue(method.isOneWay());       
     }
@@ -343,7 +338,7 @@
         methodAnnotations.add(methodAnnotation);
 
         WebServiceMETHODMetadata method =
-            new WebServiceMETHODMetadata(methodAnnotation, "methodname", void.class, false, methodAnnotations, params);
+            new WebServiceMETHODMetadata("methodname", void.class, false, methodAnnotations, params);
 
         methods.add(method);
         
@@ -395,7 +390,7 @@
         methodAnnotations.add(new FakeWebResultAnnotation("result", ""));
         
         WebServiceMETHODMetadata method =
-            new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+            new WebServiceMETHODMetadata("methodname", void.class, false, methodAnnotations, null);
         
 /*** *** ***/
 
@@ -429,7 +424,7 @@
         methodAnnotations.add(new FakeWebResultAnnotation("result", "targetNamespace"));
 
         WebServiceMETHODMetadata method =
-            new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+            new WebServiceMETHODMetadata("methodname", void.class, false, methodAnnotations, null);
        
         assertEquals("result", method.getWrName());
         assertEquals("targetNamespace", method.getWrTargetNamespace());
@@ -716,7 +711,7 @@
         methodAnnotations.add(new FakeSecurityRoleAnnotation(null, null));
 
         WebServiceMETHODMetadata method =
-            new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+            new WebServiceMETHODMetadata("methodname", void.class, false, methodAnnotations, null);
         
         assertNull(method.getSecurityRoles().getRolesAllowed());
         assertNull(method.getSecurityRoles().getRolesReferenced());
@@ -734,7 +729,7 @@
                 rolesReferenced));
  
         WebServiceMETHODMetadata method =
-            new WebServiceMETHODMetadata(mAnnotation, "methodname", void.class, false, methodAnnotations, null);
+            new WebServiceMETHODMetadata("methodname", void.class, false, methodAnnotations, null);
 
         assertEquals(1, method.getSecurityRoles().getRolesAllowed().size());
         assertEquals("rolesallowed", method.getSecurityRoles().getRolesAllowed().iterator().next());
@@ -753,7 +748,6 @@
             methodAnnotations.add(new FakeOneWayAnnotation());
             methodAnnotations.add(new FakeWebResultAnnotation("result", ""));
             WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
-                mAnnotation,
                 "methodname",
                 void.class,
                 false,
@@ -781,7 +775,6 @@
             methodAnnotations.add(mAnnotation);
             methodAnnotations.add(new FakeOneWayAnnotation());
             WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
-                mAnnotation,
                 "methodname",
                 int.class,
                 false,
@@ -810,7 +803,6 @@
             methodAnnotations.add(mAnnotation);
             methodAnnotations.add(new FakeOneWayAnnotation());
             WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
-                mAnnotation,
                 "methodname",
                 void.class,
                 true,
@@ -856,7 +848,6 @@
             params.add(param);
             
             WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
-                mAnnotation,
                 "methodname",
                 void.class,
                 false,

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java	(original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java	Mon Oct 11 11:45:02 2004
@@ -53,7 +53,6 @@
     }
 
     public WebServiceMETHODMetadata(
-        WebMethod methodAnnotation, 
         String javaMethodName,
         Class javaReturnType,
         boolean throwsExceptions,
@@ -122,16 +121,16 @@
             }
         }
         
-        // initialize from required annotation
-        initFromAnnotation(methodAnnotation);
-
         // set optional annotations
         if (null != annotations)
         {
             for (Annotation a : annotations)
             {
-                // add defaults
-                if (a.annotationType() == javax.jws.Oneway.class)
+                if (a.annotationType() == javax.jws.WebMethod.class)
+                {
+                    initFromAnnotation((javax.jws.WebMethod) a);
+                }
+                else if (a.annotationType() == javax.jws.Oneway.class)
                 {
                     initFromAnnotation((javax.jws.Oneway) a);
                 }
@@ -150,6 +149,16 @@
             }
         }
 
+        // set defaults for @WebMethod -- always, even when @WebMethod not present
+        if ((null == getWmOperationName()) || (0 == getWmOperationName().length()))
+        {
+            setWmOperationName(javaMethodName);
+        }
+        if ((null == getWmAction()) || (0 == getWmAction().length()))
+        {
+            setWmAction("");
+        }
+        
         // set WebServicePARAMETERMetadata
         addParams(webParams);
     }
@@ -182,14 +191,6 @@
         {
             setWmAction(annotation.action());
             setWmOperationName(annotation.operationName());
-        }
-        if((null == getWmOperationName()) || (0 == getWmOperationName().length()))
-        {
-            setWmOperationName(javaMethodName);
-        }
-        if((null == getWmAction()) || (0 == getWmAction().length()))
-        {
-            setWmAction("");
         }
     }
 

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java	(original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java	Mon Oct 11 11:45:02 2004
@@ -60,7 +60,6 @@
         {
             for (Annotation a : annotations)
             {
-                // add defaults
                 if (a.annotationType() == javax.jws.WebParam.class)
                 {
                     initFromAnnotation((javax.jws.WebParam) a);

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java	(original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java	Mon Oct 11 11:45:02 2004
@@ -360,10 +360,6 @@
         try {
             Collection<Annotation> annotations = getAnnotations(decl);
             wsmm = new WebServiceMETHODMetadata(
-                (javax.jws.WebMethod)AnnotationModel.getAnnotationOfType(
-                    annotations,
-                    javax.jws.WebMethod.class
-                ),
                 decl.getSimpleName(),
                 classForName(decl.getReturnType()),
                 (0 < decl.getThrownTypes().size()),

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java	(original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java	Mon Oct 11 11:45:02 2004
@@ -66,51 +66,9 @@
             new ArrayList<WebServiceMETHODMetadata>();
         for (Method method : methods)
         {
-            WebMethod webMethodAnnotation = method.getAnnotation(WebMethod.class);
-
             //method is a webmethod
-            if ( isImplementationBean && (webMethodAnnotation == null) )
+            if (isImplementationBean && (null == method.getAnnotation(WebMethod.class)))
             {
-                // get all parameters
-/*
-                List<WebServicePARAMETERMetadata> params =
-                    new ArrayList<WebServicePARAMETERMetadata>();
-                int offset = 0;
-                Class< ? >[] methodParamTypes = method.getParameterTypes();
-                Annotation[][] allAnnotations = method.getParameterAnnotations();
-                for (Class paramType : methodParamTypes)
-                {
-                    WebServicePARAMETERMetadata paramMetaData =
-                        new WebServicePARAMETERMetadata(
-                            paramType,
-                            "in" + offset,   // by default parameter should be IN
-                            Arrays.asList(allAnnotations[offset]) // class
-                        );
-                    // reflection
-                    // doesn't keep the
-                    // name of
-                    // the parameter
-                    params.add(paramMetaData);
-                    offset++;
-                }
-                try {
-                    WebServiceMETHODMetadata wsmm =
-                        new WebServiceMETHODMetadata(
-                            webMethodAnnotation,
-                            method.getName(),
-                            method.getReturnType(),
-                            (0 < method.getExceptionTypes().length),
-                            Arrays.asList(method.getAnnotations()),
-                            params
-                        );
-                    webMethods.add(wsmm);
-                }
-                catch (Throwable t)
-                {
-                    t.printStackTrace(); // todo proper error handling
-                    return null;
-                }
- */
                 // This method is declared in a service implementation bean, but not annotated with @WebMethod.
                 // Thus, this method will not be exposed.
                 continue;
@@ -145,7 +103,6 @@
             try {
                 WebServiceMETHODMetadata wsmm =
                     new WebServiceMETHODMetadata(
-                        webMethodAnnotation,
                         method.getName(),
                         method.getReturnType(),
                         (0 < method.getExceptionTypes().length),