cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5934] Introdicng gew protected methods to make it simpler to override handleOperation
Date Mon, 11 Aug 2014 11:45:12 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 9344b093b -> 8e4a6b56a


[CXF-5934] Introdicng gew protected methods to make it simpler to override handleOperation


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

Branch: refs/heads/master
Commit: 8e4a6b56a0e35b2a0b55ade98df12ab24a53fa8f
Parents: 9344b09
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Aug 11 12:44:54 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Aug 11 12:44:54 2014 +0100

----------------------------------------------------------------------
 .../cxf/jaxrs/model/wadl/WadlGenerator.java     | 37 +++++++++++++++-----
 1 file changed, 29 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/8e4a6b56/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 352a7cf..8800f5b 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
@@ -450,13 +450,34 @@ public class WadlGenerator implements ContainerRequestFilter {
         return change ? builder.toString() : value;
     }
     
-    private void startMethodTag(StringBuilder sb, OperationResourceInfo ori) {
+    protected void startMethodTag(StringBuilder sb, OperationResourceInfo ori) {
         sb.append("<method name=\"").append(ori.getHttpMethod()).append("\"");
         if (addResourceAndMethodIds) {
             sb.append(" id=\"").append(getMethod(ori).getName()).append("\"");
         }
         sb.append(">");
     }
+    protected void endMethodTag(StringBuilder sb, OperationResourceInfo ori) {
+        sb.append("</method>");
+    }
+    protected void startMethodRequestTag(StringBuilder sb, OperationResourceInfo ori) {
+        sb.append("<request>");
+    }
+    protected void startMethodResponseTag(StringBuilder sb, OperationResourceInfo ori) {
+        sb.append("<response");
+    }
+    protected void endMethodRequestTag(StringBuilder sb, OperationResourceInfo ori) {
+        sb.append("</request>");
+    }
+    protected void endMethodResponseTag(StringBuilder sb, OperationResourceInfo ori) {
+        sb.append("</response>");
+    }
+    protected void startResourceTag(StringBuilder sb, OperationResourceInfo ori, String path)
{
+        sb.append("<resource path=\"").append(path).append("\">");
+    }
+    protected void endResourceTag(StringBuilder sb, OperationResourceInfo ori) {
+        sb.append("</resource>");
+    }
 
     // CHECKSTYLE:OFF
     protected boolean handleOperation(StringBuilder sb, Set<Class<?>> jaxbTypes,
@@ -478,7 +499,7 @@ public class WadlGenerator implements ContainerRequestFilter {
                     path = path.substring(1);
                 }
             }
-            sb.append("<resource path=\"").append(getPath(path)).append("\">");
+            startResourceTag(sb, ori, getPath(path));
             handleDocs(anns, sb, DocTarget.RESOURCE, false, isJson);
             handlePathAndMatrixClassParams(ori, sb, classParams, isJson);
             handlePathAndMatrixParams(sb, ori, isJson);
@@ -492,7 +513,7 @@ public class WadlGenerator implements ContainerRequestFilter {
             handleOperJavaDocs(ori, sb);
         }
         if (getMethod(ori).getParameterTypes().length != 0 || classParams.size() != 0) {
-            sb.append("<request>");
+            startMethodRequestTag(sb, ori);
             handleDocs(anns, sb, DocTarget.REQUEST, false, isJson);
 
             boolean isForm = isFormRequest(ori);
@@ -507,9 +528,9 @@ public class WadlGenerator implements ContainerRequestFilter {
             if (isForm) {
                 handleFormRepresentation(sb, jaxbTypes, qnameResolver, clsMap, ori, getFormClass(ori),
isJson);
             }
-            sb.append("</request>");
+            endMethodRequestTag(sb, ori);
         }
-        sb.append("<response");
+        startMethodResponseTag(sb, ori);
         Class<?> returnType = getMethod(ori).getReturnType();
         boolean isVoid = void.class == returnType;
         if (isVoid) {
@@ -521,12 +542,12 @@ public class WadlGenerator implements ContainerRequestFilter {
         if (!isVoid) {
             handleRepresentation(sb, jaxbTypes, qnameResolver, clsMap, ori, returnType, isJson,
false);
         }
-        sb.append("</response>");
+        endMethodResponseTag(sb, ori);
 
-        sb.append("</method>");
+        endMethodTag(sb, ori);
 
         if (resourceTagOpened && !samePathOperationFollows) {
-            sb.append("</resource>");
+            endResourceTag(sb, ori);
             resourceTagOpened = false;
         }
         return resourceTagOpened;


Mime
View raw message