cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1549611 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceServer.java
Date Mon, 09 Dec 2013 16:28:30 GMT
Author: sergeyb
Date: Mon Dec  9 16:28:30 2013
New Revision: 1549611

URL: http://svn.apache.org/r1549611
Log:
Minor updates to JAX-RS Spring server

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceServer.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceServer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceServer.java?rev=1549611&r1=1549610&r2=1549611&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceServer.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceServer.java
Mon Dec  9 16:28:30 2013
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.jaxrs.spring;
 
+import java.lang.annotation.Annotation;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
@@ -51,15 +52,16 @@ public class SpringResourceServer {
         List<ResourceProvider> resourceProviders = new LinkedList<ResourceProvider>();
         List<Object> jaxrsProviders = new LinkedList<Object>();
         
+        boolean checkJaxrsRoots = checkJaxrsRoots();
+        boolean checkJaxrsProviders = checkJaxrsProviders(); 
+        
         for (String beanName : ctx.getBeanDefinitionNames()) {
-            if (isBeanSupported(beanName)) {
-                if (ctx.findAnnotationOnBean(beanName, Path.class) != null) {
-                    SpringResourceFactory factory = new SpringResourceFactory(beanName);
-                    factory.setApplicationContext(ctx);
-                    resourceProviders.add(factory);
-                } else if (checkJaxrsProviders() && ctx.findAnnotationOnBean(beanName,
Provider.class) != null) {
-                    jaxrsProviders.add(ctx.getBean(beanName));
-                }
+            if (checkJaxrsRoots && isAnnotationAvailable(beanName, Path.class)) {
+                SpringResourceFactory factory = new SpringResourceFactory(beanName);
+                factory.setApplicationContext(ctx);
+                resourceProviders.add(factory);
+            } else if (checkJaxrsProviders && isAnnotationAvailable(beanName, Provider.class))
{
+                jaxrsProviders.add(ctx.getBean(beanName));
             }
         }
 
@@ -68,12 +70,26 @@ public class SpringResourceServer {
         factory.setResourceProviders(resourceProviders);
         factory.setProviders(jaxrsProviders);
         factory.setAddress(getAddress());
+        finalizeFactorySetup(factory);
         return factory.create();
     }
     
+    protected <A extends Annotation> boolean isAnnotationAvailable(String beanName,
Class<A> annClass) {
+        return isBeanSupported(beanName) 
+            && ctx.findAnnotationOnBean(beanName, annClass) != null;
+    }
+    
+    protected void finalizeFactorySetup(JAXRSServerFactoryBean factory) {
+        // complete
+    }
+    
     protected boolean checkJaxrsProviders() {
         return true;    
     }
+    
+    protected boolean checkJaxrsRoots() {
+        return true;    
+    }
 
     public String getAddress() {
         return address;



Mime
View raw message