cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Minor updates to WADLGenerator - optional exclusion of overloaded methods and referencing of (XSLT)stylesheets
Date Mon, 24 Nov 2014 11:19:33 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 24aa7e581 -> 75177fdcd


Minor updates to WADLGenerator - optional exclusion of overloaded methods and referencing
of (XSLT)stylesheets


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/75177fdc
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/75177fdc
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/75177fdc

Branch: refs/heads/3.0.x-fixes
Commit: 75177fdcd20402c8c5b577a223c7642812860681
Parents: 24aa7e5
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Nov 24 11:18:15 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Nov 24 11:19:15 2014 +0000

----------------------------------------------------------------------
 .../cxf/jaxrs/model/wadl/WadlGenerator.java     | 22 ++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/75177fdc/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
index fa9e295..1b1b591 100644
--- a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
+++ b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
@@ -153,6 +153,7 @@ public class WadlGenerator implements ContainerRequestFilter {
     private boolean supportCollections = true;
     private boolean supportJaxbXmlType = true;
     private boolean supportJaxbSubstitutions = true;
+    private boolean ignoreOverloadedMethods;
     private boolean checkAbsolutePathSlash;
     
     private List<String> externalSchemasCache;
@@ -167,6 +168,7 @@ public class WadlGenerator implements ContainerRequestFilter {
     private String nsPrefix = DEFAULT_NS_PREFIX;
     private MediaType defaultWadlResponseMediaType = MediaType.APPLICATION_XML_TYPE;
     private MediaType defaultRepMediaType = MediaType.WILDCARD_TYPE;
+    private String stylesheetReference;
     private Bus bus;
     private DocumentationProvider docProvider;
     private ResourceIdGenerator idGenerator;     
@@ -235,6 +237,9 @@ public class WadlGenerator implements ContainerRequestFilter {
                                        Message m,
                                        UriInfo ui) {
         StringBuilder sbMain = new StringBuilder();
+        if (!isJson && stylesheetReference != null) {
+            sbMain.append("<?xml-stylesheet type=\"text/xsl\" href=\"" + stylesheetReference
+ "\"?>");
+        }
         sbMain.append("<application");
         if (!isJson) {
             sbMain.append(" xmlns=\"").append(getNamespace()).append("\" xmlns:xs=\"")
@@ -345,7 +350,10 @@ public class WadlGenerator implements ContainerRequestFilter {
         boolean resourceTagOpened = false;
         for (int i = 0; i < sortedOps.size(); i++) {
             OperationResourceInfo ori = sortedOps.get(i);
-
+            if (i > 0 && ignoreOverloadedMethods 
+                && ori.getMethodToInvoke().getName().equals(sortedOps.get(i - 1).getMethodToInvoke().getName()))
{
+                continue;
+            }
             if (ori.getHttpMethod() == null) {
                 Class<?> cls = getMethod(ori).getReturnType();
                 ClassResourceInfo subcri = cri.findResource(cls, cls);
@@ -1034,6 +1042,12 @@ public class WadlGenerator implements ContainerRequestFilter {
                 if (result == 0 && !(sub1 && sub2)) {
                     result = op1.getHttpMethod().compareTo(op2.getHttpMethod());
                 }
+                if (result == 0 && ignoreOverloadedMethods
+                    && op1.getMethodToInvoke().getName().equals(op2.getMethodToInvoke().getName()))
{
+                    Integer paramLen1 = op1.getMethodToInvoke().getParameterTypes().length;
+                    Integer paramLen2 = op2.getMethodToInvoke().getParameterTypes().length;
+                    result = paramLen1.compareTo(paramLen2) * -1; 
+                }
                 return result;
             }
 
@@ -1979,7 +1993,7 @@ public class WadlGenerator implements ContainerRequestFilter {
     /**
      * Set the default WADL response media type.
      * For example, a browser may display WADL better if Content-Type 
-     * is set application/xml which is a default response content type. 
+     * is set to application/xml which is a default response content type. 
      * Users may set it to application/vnd.sun.wadl+xml or other type.
      * @param mt WADL response media type 
      */
@@ -2017,6 +2031,10 @@ public class WadlGenerator implements ContainerRequestFilter {
         docProvider = p;
     }
 
+    public void setStylesheetReference(String stylesheetReference) {
+        this.stylesheetReference = stylesheetReference;
+    }
+
     private static class SchemaConverter extends DelegatingXMLStreamWriter {
         private static final String SCHEMA_LOCATION = "schemaLocation";
         private Map<String, String> locsMap;


Mime
View raw message