cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r911772 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/model/wadl/ main/java/org/apache/cxf/jaxrs/utils/ test/java/org/apache/cxf/jaxrs/model/wadl/
Date Fri, 19 Feb 2010 10:21:59 GMT
Author: sergeyb
Date: Fri Feb 19 10:21:59 2010
New Revision: 911772

URL: http://svn.apache.org/viewvc?rev=911772&view=rev
Log:
JAXRS : minor update to WADLGenerator for it not to list ignorable query properties 

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=911772&r1=911771&r2=911772&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Fri Feb 19 10:21:59 2010
@@ -401,7 +401,7 @@
     }
     
     private void doWriteBeanParam(StringBuilder sb, Class<?> type, Parameter pm, String
parentName) {
-        Map<Parameter, Class<?>> pms = InjectionUtils.getParametersFromBeanClass(type,
pm.getType());
+        Map<Parameter, Class<?>> pms = InjectionUtils.getParametersFromBeanClass(type,
pm.getType(), true);
         for (Map.Entry<Parameter, Class<?>> entry : pms.entrySet()) {
             String name = entry.getKey().getName();
             if (parentName != null) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=911772&r1=911771&r2=911772&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Fri Feb 19 10:21:59 2010
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.jaxrs.utils;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
@@ -845,13 +846,15 @@
     }
     
     public static Map<Parameter, Class<?>> getParametersFromBeanClass(Class<?>
beanClass, 
-                                                                      ParameterType type)
{
+                                                                      ParameterType type,
+                                                                      boolean checkIgnorable)
{
         Map<Parameter, Class<?>> params = new LinkedHashMap<Parameter, Class<?>>();
         for (Method m : beanClass.getMethods()) {
             if (m.getName().startsWith("get") && m.getParameterTypes().length ==
0 
                 && m.getName().length() > 3) {
                 String propertyName = m.getName().substring(3).toLowerCase();
-                if ("class".equals(propertyName)) {
+                if ("class".equals(propertyName) 
+                    || checkIgnorable && canPropertyBeIgnored(m, propertyName)) {
                     continue;
                 }
                 params.put(new Parameter(type, propertyName), m.getReturnType());
@@ -860,6 +863,16 @@
         return params;
     }
     
+    private static boolean canPropertyBeIgnored(Method m, String propertyName) {
+        for (Annotation ann : m.getAnnotations()) {
+            String annType = ann.annotationType().getName();
+            if ("org.apache.cxf.aegis.type.java5.IgnoreProperty".equals(annType)
+                || "javax.xml.bind.annotation.XmlTransient".equals(annType)) {
+                return true;
+            }
+        }
+        return false;
+    }
     
     public static boolean isPrimitive(Class<?> type) {
         return type.isPrimitive() 

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java?rev=911772&r1=911771&r2=911772&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
Fri Feb 19 10:21:59 2010
@@ -31,7 +31,9 @@
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
+import javax.xml.bind.annotation.XmlTransient;
 
+import org.apache.cxf.aegis.type.java5.IgnoreProperty;
 import org.apache.cxf.jaxrs.ext.Description;
 import org.apache.cxf.jaxrs.ext.xml.XMLName;
 import org.apache.cxf.jaxrs.fortest.jaxb.packageinfo.Book2;
@@ -121,6 +123,7 @@
             return a;
         }
         
+        @IgnoreProperty
         public int getB() {
             return b;
         }
@@ -129,9 +132,6 @@
             return bean;
         }
         
-        public void setC(QueryBean2 c) {
-            bean = c;
-        }
     }
     
     public static class QueryBean2 {
@@ -151,9 +151,6 @@
             return bean;
         }
         
-        public void setD(QueryBean3 d) {
-            bean = d;
-        }
     }
     
     public static class QueryBean3 {
@@ -164,6 +161,7 @@
             return a;
         }
         
+        @XmlTransient
         public int getB() {
             return b;
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=911772&r1=911771&r2=911772&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Fri Feb 19 10:21:59 2010
@@ -361,13 +361,11 @@
         // 6 parameters are expected
         paramsEls = DOMUtils.getChildrenWithName(requestEls.get(0), 
                                                  WadlGenerator.WADL_NS, "param");
-        assertEquals(6, paramsEls.size());
+        assertEquals(4, paramsEls.size());
         checkParameter(paramsEls.get(0), "a", "query", "xs:int");
-        checkParameter(paramsEls.get(1), "b", "query", "xs:int");
-        checkParameter(paramsEls.get(2), "c.a", "query", "xs:int");
-        checkParameter(paramsEls.get(3), "c.b", "query", "xs:int");
-        checkParameter(paramsEls.get(4), "c.d.a", "query", "xs:int");
-        checkParameter(paramsEls.get(5), "c.d.b", "query", "xs:int");
+        checkParameter(paramsEls.get(1), "c.a", "query", "xs:int");
+        checkParameter(paramsEls.get(2), "c.b", "query", "xs:int");
+        checkParameter(paramsEls.get(3), "c.d.a", "query", "xs:int");
         assertEquals(0, DOMUtils.getChildrenWithName(requestEls.get(0), 
                          WadlGenerator.WADL_NS, "representation").size());
         //check response



Mime
View raw message