cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1554292 - in /cxf/trunk: core/src/main/java/org/apache/cxf/endpoint/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ systests/jaxrs/src/test/resources/jaxrs/WEB-INF/
Date Mon, 30 Dec 2013 18:36:31 GMT
Author: sergeyb
Date: Mon Dec 30 18:36:31 2013
New Revision: 1554292

URL: http://svn.apache.org/r1554292
Log:
[CXF-5362] Allowing for more flexible setting of JAX-RS service beans and providers with the
code suggested by Dan

Modified:
    cxf/trunk/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    cxf/trunk/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml

Modified: cxf/trunk/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java?rev=1554292&r1=1554291&r2=1554292&view=diff
==============================================================================
--- cxf/trunk/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java (original)
+++ cxf/trunk/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java Mon
Dec 30 18:36:31 2013
@@ -19,6 +19,7 @@
 package org.apache.cxf.endpoint;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -237,6 +238,16 @@ public abstract class AbstractEndpointFa
         }
     }    
     
+    protected static void addToBeans(Collection<Object> beans, Object o) {
+        if (o instanceof Collection) {
+            for (Object o2: (Collection<?>)o) {
+                addToBeans(beans, o2);
+            }
+        } else {
+            beans.add(o);
+        }
+    }
+    
     protected boolean initializeAnnotationInterceptors(AnnotationInterceptors provider, Endpoint
ep) {
         boolean hasAnnotation = false;
         if (provider.getInFaultInterceptors() != null) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=1554292&r1=1554291&r2=1554292&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
Mon Dec 30 18:36:31 2013
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.jaxrs;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
@@ -282,7 +283,9 @@ public class AbstractJAXRSFactoryBean ex
      * @param entityProviders the entityProviders
      */
     public void setProviders(List<? extends Object> providers) {
-        this.entityProviders.addAll(providers);
+        List<Object> newBeans = new ArrayList<Object>();
+        addToBeans(newBeans, providers);
+        this.entityProviders.addAll(newBeans);
     }
     
     /**

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=1554292&r1=1554291&r2=1554292&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
Mon Dec 30 18:36:31 2013
@@ -19,6 +19,7 @@
 package org.apache.cxf.jaxrs;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
@@ -323,8 +324,10 @@ public class JAXRSServerFactoryBean exte
      * @param beans the list of resource instances
      */
     public void setServiceBeans(List<Object> beans) {
-        serviceFactory.setResourceClassesFromBeans(beans);
-    }
+        List<Object> newBeans = new ArrayList<Object>();
+        addToBeans(newBeans, beans);
+        serviceFactory.setResourceClassesFromBeans(newBeans);
+    }    
     
     /**
      * Sets the provider managing the life-cycle of the given resource class

Modified: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml?rev=1554292&r1=1554291&r2=1554292&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml Mon Dec 30 18:36:31
2013
@@ -88,12 +88,18 @@
     </jaxrs:server>
     <jaxrs:server id="bookservice5" address="/thebooks5/bookstore">
         <jaxrs:serviceBeans>
-            <ref bean="serviceBean"/>
+            <ref bean="xsltServiceBeans"/>
         </jaxrs:serviceBeans>
         <jaxrs:providers>
-            <ref bean="xsltProvider"/>
+            <ref bean="xsltProviders"/>
         </jaxrs:providers>
     </jaxrs:server>
+    <util:list id="xsltServiceBeans">
+        <ref bean="serviceBean"/>
+    </util:list>
+    <util:list id="xsltProviders">
+        <ref bean="xsltProvider"/>
+    </util:list>
     <jaxrs:server id="bookserviceWithStax" address="/thebooksWithStax/bookstore">
         <jaxrs:serviceBeans>
             <ref bean="serviceBean"/>



Mime
View raw message