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/09 02:31:08 UTC

svn commit: rev 54139 - in incubator/beehive/trunk/wsm: 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: Fri Oct  8 17:31:07 2004
New Revision: 54139

Modified:
   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/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:
Bug fix: @WebParam is optional for parameters of @WebMethod.



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	Fri Oct  8 17:31:07 2004
@@ -188,7 +188,7 @@
     {
         try {
             WebServicePARAMETERMetadata param =
-                new WebServicePARAMETERMetadata(null, null, "paramname", null);
+                new WebServicePARAMETERMetadata(null, "paramname", null);
             fail("Java type is required in for constructor");
         }
         catch (IllegalArgumentException e)
@@ -319,7 +319,7 @@
         paramAnnotations.add(wpAnnotation);
 
         WebServicePARAMETERMetadata param =
-            new WebServicePARAMETERMetadata (wpAnnotation, String.class, "paramname", paramAnnotations);
+            new WebServicePARAMETERMetadata (String.class, "paramname", paramAnnotations);
         
 /*** *** ***/
 
@@ -368,7 +368,7 @@
         paramAnnotations.add(wpAnnotation);
 
         WebServicePARAMETERMetadata param =
-            new WebServicePARAMETERMetadata(wpAnnotation, String.class, "paramname", paramAnnotations);
+            new WebServicePARAMETERMetadata(String.class, "paramname", paramAnnotations);
        
         assertEquals("paramname", param.getWpName());
         assertEquals("targetNamespace", param.getWpTargetNamespace());
@@ -845,7 +845,6 @@
             paramAnnotations.add(pAnnotation);
             WebServicePARAMETERMetadata param =
                 new WebServicePARAMETERMetadata(
-                    pAnnotation, // annotation
                     String.class, // javaType
                     "paramname", // name
                     paramAnnotations // annotations

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	Fri Oct  8 17:31:07 2004
@@ -41,7 +41,6 @@
     // defaultName is argument name in the source file. It can be null if the
     // name is not known.
     public WebServicePARAMETERMetadata(
-        javax.jws.WebParam webParamAnnotation,
         Class javaType,
         String defaultName,
         Collection<Annotation> annotations)
@@ -56,19 +55,19 @@
         setWpMode(WebParam.Mode.IN);  // by default if there were no anotations
         setWpName(defaultName);       // in case there are no annotations
         
-        // check required parameters
-        
-        // initialize from required annotation
-        if (null != webParamAnnotation)
+        // set optional annotations
+        for (Annotation a : annotations)
         {
-            initFromAnnotation(webParamAnnotation);
+            // add defaults
+            if (a.annotationType() == javax.jws.WebParam.class)
+            {
+                initFromAnnotation((javax.jws.WebParam) a);
+            }
+            else
+            {
+                // todo: warning -- unknown annotation
+            }
         }
-        
-        // set optional annotations  .. None in the case of parameters
-        //        for (Annotation a : annotations) {
-        //
-        //        }
-        
     }
     
     public boolean isWpHeader()

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	Fri Oct  8 17:31:07 2004
@@ -70,7 +70,6 @@
     public void check(Declaration decl)
     {
         // check type of declaration
-//        if ((null == decl) || (! (decl instanceof ClassDeclaration)))
         if ((null == decl) || (! ((decl instanceof ClassDeclaration) || (decl instanceof InterfaceDeclaration)) ))
         {
             return;
@@ -92,7 +91,15 @@
         objectModels.put(((TypeDeclaration) decl).getQualifiedName(), objectModel);
     }
 
-    public WebServiceTYPEMetadata handleEndpointInterface(WebServiceTYPEMetadata webServiceTYPEMetadata)
+    @Override
+    public void generate(Declaration decl)
+    {
+        // todo: on demand code generation
+
+        // todo: do something useful with the object model
+    }
+
+    private WebServiceTYPEMetadata handleEndpointInterface(WebServiceTYPEMetadata webServiceTYPEMetadata)
     {
         String endpointInterface = webServiceTYPEMetadata.getWsEndpointInterface();
         if (null == endpointInterface || 0 == endpointInterface.length())
@@ -162,15 +169,7 @@
         return endpointInterfaceMetadata;
     }
 
-     @Override
-     public void generate(Declaration decl)
-     {
-        // todo: on demand code generation
-
-        // todo: do something useful with the object model
-     }
-
-    public WebServiceTYPEMetadata createObjectModelWithReflection(String endpointInterface)
+    private WebServiceTYPEMetadata createObjectModelWithReflection(String endpointInterface)
     {
 
         WebServiceTYPEMetadata webServiceTYPEMetadata = null;
@@ -196,7 +195,7 @@
     }
 
     // find a source file of the specified className.
-    public String findSourceFile(String className)
+    private String findSourceFile(String className)
     {
         // todo: search the specified file. Need a precise algorithm.
 
@@ -236,7 +235,7 @@
         return null;
     }
 
-    public void readServiceEndpointInterface(String filePath)
+    private void readServiceEndpointInterface(String filePath)
     {
         try {
             // check these options are available and
@@ -331,10 +330,10 @@
             new ArrayList<WebServicePARAMETERMetadata>();
         for ( ParameterDeclaration paramDecl : decl.getParameters() )
         {
-            if (null != paramDecl.getAnnotation(javax.jws.WebParam.class))
-            {
+//            if (null != paramDecl.getAnnotation(javax.jws.WebParam.class))
+//            {
                 webParams.add(getWebServicePARAMETERMetadata(paramDecl));
-            }
+//            }
         }
 
         // create & return webMethod
@@ -368,7 +367,10 @@
         try {
             Collection<Annotation> annotations = getAnnotations(decl);
             wspm = new WebServicePARAMETERMetadata(
-               (javax.jws.WebParam)AnnotationModel.getAnnotationOfType(annotations, javax.jws.WebParam.class),
+//                (javax.jws.WebParam)AnnotationModel.getAnnotationOfType(
+//                    annotations,
+//                    javax.jws.WebParam.class
+//                ),
                 classForName(decl.getType()),
                 decl.getSimpleName(),
                 annotations

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	Fri Oct  8 17:31:07 2004
@@ -70,16 +70,11 @@
                 Annotation[][] allAnnotations = method.getParameterAnnotations();
                 for (Class paramType : methodParamTypes)
                 {
-                    List<Annotation> allParmAnnotation =
-                        Arrays.asList(allAnnotations[offset]);
-                    WebParam wpAnnotation =
-                        (WebParam)AnnotationModel.getAnnotationOfType(allParmAnnotation, WebParam.class);
                     WebServicePARAMETERMetadata paramMetaData =
                         new WebServicePARAMETERMetadata(
-                            wpAnnotation,
                             paramType,
                             "in" + offset,   // by default parameter should be IN
-                            allParmAnnotation // class
+                            Arrays.asList(allAnnotations[offset]) // class
                         );
                     // reflection
                     // doesn't keep the