cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1034071 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Date Thu, 11 Nov 2010 19:39:19 GMT
Author: sergeyb
Date: Thu Nov 11 19:39:19 2010
New Revision: 1034071

URL: http://svn.apache.org/viewvc?rev=1034071&view=rev
Log:
JAX-RS: another attempt on breaking the client dependency on the servlet api

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java

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=1034071&r1=1034070&r2=1034071&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
Thu Nov 11 19:39:19 2010
@@ -712,6 +712,7 @@ public final class InjectionUtils {
         return value;
     }
     
+    // TODO : investigate the possibility of using generic proxies only
     public static ThreadLocalProxy createThreadLocalProxy(Class<?> type) {
         ThreadLocalProxy proxy = null;
         if (UriInfo.class.isAssignableFrom(type)) {
@@ -728,18 +729,33 @@ public final class InjectionUtils {
             proxy = new ThreadLocalRequest();
         }  else if (Providers.class.isAssignableFrom(type)) {
             proxy = new ThreadLocalProviders();
-        } else if (HttpServletRequest.class.isAssignableFrom(type)) {
+        } else if (SearchContext.class.isAssignableFrom(type)) {
+            proxy = new ThreadLocalSearchContext();
+        } else if (MessageContext.class.isAssignableFrom(type)) {
+            proxy = new ThreadLocalMessageContext();
+        }
+        
+        if (proxy == null && isServletApiContext(type.getName())) {
+            proxy = createThreadLocalServletApiContext(type);  
+        }
+        
+        return proxy;
+    }
+    
+    private static boolean isServletApiContext(String name) { 
+        return name.startsWith("javax.servlet.");
+    }
+    
+    private static ThreadLocalProxy createThreadLocalServletApiContext(Class<?> type)
{
+        ThreadLocalProxy proxy = null;
+        if (HttpServletRequest.class.isAssignableFrom(type)) {
             proxy = new ThreadLocalHttpServletRequest();
         } else if (ServletContext.class.isAssignableFrom(type)) {
             proxy = new ThreadLocalServletContext();
         } else if (HttpServletResponse.class.isAssignableFrom(type)) {
             proxy = new ThreadLocalHttpServletResponse();
-        } else if (MessageContext.class.isAssignableFrom(type)) {
-            proxy = new ThreadLocalMessageContext();
         } else if (ServletConfig.class.isAssignableFrom(type)) {
             proxy = new ThreadLocalServletConfig();
-        } else if (SearchContext.class.isAssignableFrom(type)) {
-            proxy = new ThreadLocalSearchContext();
         }
         return proxy;
     }



Mime
View raw message