Author: mmerz
Date: Mon Feb 28 17:30:56 2005
New Revision: 155726

URL: http://svn.apache.org/viewcvs?view=rev&rev=155726
Log:
Fix for BEEHIVE-380.

Minor fixes for compile time error reporting: error source position (method, 
parameters) were off in several cases.


Modified:
    
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181MethodMetadataImpl.java
    
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181ParameterMetadataImpl.java
    
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181TypeMetadataImpl.java

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181MethodMetadataImpl.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181MethodMetadataImpl.java?view=diff&r1=155725&r2=155726
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181MethodMetadataImpl.java
 (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181MethodMetadataImpl.java
 Mon Feb 28 17:30:56 2005
@@ -76,13 +76,14 @@
         javaReturnType = returnType;
     }
 
-    public Jsr181MethodMetadataImpl(JavaMethodInfo jm) throws Exception {
+    public Jsr181MethodMetadataImpl(JavaMethodInfo jm) {
 
         super();
 
         // check input param
         if (null == jm) {
-            throw new IllegalArgumentException("illegal java method info: 
<null>");
+            jm.logError("illegal java method info: <null>");
+            return;
         }
         
         javaMethodName = jm.getMethodName();
@@ -94,7 +95,7 @@
         for (JavaParameterInfo param : jm.getParameters()) {
             BeehiveWsParameterMetadata wspm = new 
Jsr181ParameterMetadataImpl(param);
             if (null == wspm) {
-                throw new ValidationException("cannot create web param: " + 
param.getName());
+                jm.logError("cannot create metadata for web param: " + 
param.getName());
             }
             webParams.add(wspm);
         }
@@ -104,27 +105,27 @@
         
         // enforce JSR-181 rules
         if (! jm.isPublic()) {
-            throw new ValidationException("@WebMethod must be public: " + 
javaMethodName);
+            jm.logError("@WebMethod must be public: " + javaMethodName);
         }
         if (null != jm.getAnnotation(Oneway.class)) {
             // prohibit @Oneway with @WebResult
             if (null != jm.getAnnotation(WebResult.class)) {
-                throw new ValidationException("@Oneway method " + 
javaMethodName + " has incompatible annotation: @WebResult");
+                jm.logError("@Oneway method " + javaMethodName + " has 
incompatible annotation: @WebResult");
             }
             // prohibit @Oneway with return types other than <code>void</code>
             if (void.class != javaReturnType) {
-                throw new ValidationException("@Oneway method " + 
javaMethodName + " has illegal non-void return type: " + javaReturnType);
+                jm.logError("@Oneway method " + javaMethodName + " has illegal 
non-void return type: " + javaReturnType);
             }
             // prohibit @Oneway methods that throw Exceptions
             if (jm.throwsExceptions()) {
-                throw new ValidationException("@Oneway method " + 
javaMethodName + " must not throw exceptions");
+                jm.logError("@Oneway method " + javaMethodName + " must not 
throw checked exceptions");
             }
             // todo??? prohibit @Oneway with "OUT" and "INOUT" parameters
                     
             if (null != webParams) {
                 for (BeehiveWsParameterMetadata param : webParams) {
                     if ((WebParam.Mode.OUT == param.getWpMode()) || 
(WebParam.Mode.INOUT == param.getWpMode())) {
-                        throw new ValidationException("@Oneway method " + 
javaMethodName + " has illegal INOUT or OUT parameter: " + param.getWpName());
+                        jm.logError("@Oneway method " + javaMethodName + " has 
illegal INOUT or OUT parameter: " + param.getWpName());
                     }
                 }
             }

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181ParameterMetadataImpl.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181ParameterMetadataImpl.java?view=diff&r1=155725&r2=155726
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181ParameterMetadataImpl.java
 (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181ParameterMetadataImpl.java
 Mon Feb 28 17:30:56 2005
@@ -54,7 +54,8 @@
 
         // check input params
         if (null == jp) {
-            throw new IllegalArgumentException("illegal parameter info: 
<null>");
+            jp.logError("illegal java parameter info: <null>");
+            return;
         }
         
         javaType = jp.getType();

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181TypeMetadataImpl.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181TypeMetadataImpl.java?view=diff&r1=155725&r2=155726
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181TypeMetadataImpl.java
 (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181TypeMetadataImpl.java
 Mon Feb 28 17:30:56 2005
@@ -95,35 +95,32 @@
     }
 
     /**
-     * @param jws
-     * @throws
+     * This method creates an object that encapsulates all type-level
+     * annotations and their fields. Moreover, it enforces all rules specified 
+     * in JSR-181.
+     * @param jt An object that provides Java-specific context services for
+     *   type-level annotations.
      */
-    public Jsr181TypeMetadataImpl(JavaTypeInfo jt) throws Exception {
+    public Jsr181TypeMetadataImpl(JavaTypeInfo jt) {
 
         super();
 
         if (null == jt) {
             jt.logError("illegal java type info: <null>");
+            return;
         }
 
-        // check required parameter: wsAnnotation
-        WebService wsAnnotation = jt.getAnnotation(WebService.class);
-        if (null == wsAnnotation) {
+        // check required @WebService annotation
+        WebService webService = jt.getAnnotation(WebService.class);
+        if (null == webService) {
             jt.logError("no @WebService annotation found");
         }
 
         // get webMethods
         Collection<BeehiveWsMethodMetadata> webMethods =
             new ArrayList<BeehiveWsMethodMetadata>();
-        // SEI: add all methods from service endpoint interface
-        if (jt.isInterface()) {
-            for (JavaMethodInfo jm : jt.getMethods()) {
-                BeehiveWsMethodMetadata wsmm = new 
Jsr181MethodMetadataImpl(jm);
-                webMethods.add(wsmm);
-            }
-        }        
-        // SIB: add only annotated methods
-        else {
+        // SIB: try adding only annotated methods
+        if (! jt.isInterface()) {
             for (JavaMethodInfo jm : jt.getMethods()) {
                 if (null != jm.getAnnotation(WebMethod.class)) {
                     BeehiveWsMethodMetadata wsmm = new 
Jsr181MethodMetadataImpl(jm);
@@ -134,6 +131,13 @@
                 }
             }
         }
+        // SEI or SIB with no @WebMethod annotations: add all methods
+        if (webMethods.isEmpty()) {
+            for (JavaMethodInfo jm : jt.getMethods()) {
+                BeehiveWsMethodMetadata wsmm = new 
Jsr181MethodMetadataImpl(jm);
+                webMethods.add(wsmm);
+            }
+        }        
         
         // check required parameters: annotations, webMethods
         Collection<Annotation> annotations = jt.getAnnotations();
@@ -156,10 +160,10 @@
             jt.logError("web service class must not declare method: 
finalize()");
         }
         if (jt.isInterface()) {
-            if (null != wsAnnotation.endpointInterface() && 0 < 
wsAnnotation.endpointInterface().trim().length()) {
+            if (null != webService.endpointInterface() && 0 < 
webService.endpointInterface().trim().length()) {
                 jt.logError("@WebService.endpointInterface not allowed on 
interfaces");
             }
-            if (null != wsAnnotation.serviceName() && 0 < 
wsAnnotation.serviceName().trim().length()) {
+            if (null != webService.serviceName() && 0 < 
webService.serviceName().trim().length()) {
                 jt.logError("@WebService.serviceName not allowed on 
interfaces");
             }
         }
@@ -174,7 +178,7 @@
         if (null != jt.getAnnotation(SOAPMessageHandlers.class) && null != 
jt.getAnnotation(HandlerChain.class)) {
             jt.logError("Illegal combination of @SOAPMessageHandlers and 
@HandlerChain");
         }
-        String wsdlLocation = wsAnnotation.wsdlLocation();
+        String wsdlLocation = webService.wsdlLocation();
         if (null != wsdlLocation && 0 < wsdlLocation.trim().length()) {
             try {
                 findResource(wsdlLocation.trim(), baseLocation).openStream();
@@ -185,7 +189,7 @@
         }
         
         // initilize instance
-        initFromAnnotation(wsAnnotation);
+        initFromAnnotation(webService);
 
         // set optional annotations
         for (Annotation a : annotations) {
@@ -244,7 +248,12 @@
             }
 
             // add WebMethod to TYPE metadata
-            addMethod(wsmm);
+            try {
+                addMethod(wsmm);
+            }
+            catch (ValidationException e) {
+                jt.logError("cannot add web method to metadata: " + 
wsmm.getJavaMethodName());
+            }
         }
     }
 


Reply via email to