cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1554274 - /cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/JavaDocProvider.java
Date Mon, 30 Dec 2013 16:39:41 GMT
Author: sergeyb
Date: Mon Dec 30 16:39:40 2013
New Revision: 1554274

URL: http://svn.apache.org/r1554274
Log:
[CXF-5353] Updating JavaDocsHandler to pick up the right HTML resource

Modified:
    cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/JavaDocProvider.java

Modified: cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/JavaDocProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/JavaDocProvider.java?rev=1554274&r1=1554273&r2=1554274&view=diff
==============================================================================
--- cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/JavaDocProvider.java
(original)
+++ cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/JavaDocProvider.java
Mon Dec 30 16:39:40 2013
@@ -20,12 +20,15 @@
 package org.apache.cxf.jaxrs.model.wadl;
 
 import java.io.InputStream;
+import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 
+import javax.ws.rs.Path;
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.util.StringUtils;
@@ -122,15 +125,31 @@ public class JavaDocProvider implements 
         return null;
     }
     
+    private Class<?> getPathAnnotatedClass(Class<?> cls) {
+        if (cls.getAnnotation(Path.class) != null) { 
+            return cls;
+        }
+        if (cls.getSuperclass().getAnnotation(Path.class) != null) {
+            return cls.getSuperclass();
+        }
+        for (Class<?> i : cls.getInterfaces()) {
+            if (i.getAnnotation(Path.class) != null) {
+                return i;    
+            }
+        }
+        return cls;
+    }
+    
     private ClassDocs getClassDocInternal(ClassResourceInfo cri) throws Exception {
-        String resource = cri.getServiceClass().getName().replace(".", "/") + ".html";
+        Class<?> annotatedClass = getPathAnnotatedClass(cri.getServiceClass());
+        String resource = annotatedClass.getName().replace(".", "/") + ".html";
         ClassDocs classDocs = docs.get(resource);
         if (classDocs == null) {
             InputStream resourceStream = javaDocLoader.getResourceAsStream(resource);
             if (resourceStream != null) {
                 String doc = IOUtils.readStringFromStream(resourceStream);
                 
-                String classMarker = "Class " + cri.getServiceClass().getSimpleName();
+                String classMarker = "Class " + annotatedClass.getSimpleName();
                 int index = doc.indexOf(classMarker);
                 if (index != -1) {
                     String classInfoTag = getClassInfoTag();
@@ -150,7 +169,9 @@ public class JavaDocProvider implements 
         if (classDoc == null) {
             return null;
         }
-        String methodName = ori.getMethodToInvoke().getName();
+        Method method = ori.getAnnotatedMethod() == null ? ori.getMethodToInvoke() 
+            : ori.getAnnotatedMethod(); 
+        String methodName = method.getName();
         MethodDocs mDocs = classDoc.getMethodDocs(methodName);
         if (mDocs == null) {
             String operLink = getOperLink();



Mime
View raw message