cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1034180 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Date Thu, 11 Nov 2010 22:21:40 GMT
Author: sergeyb
Date: Thu Nov 11 22:21:40 2010
New Revision: 1034180

URL: http://svn.apache.org/viewvc?rev=1034180&view=rev
Log:
Merged revisions 1034170 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.3.x-fixes

................
  r1034170 | sergeyb | 2010-11-11 22:02:03 +0000 (Thu, 11 Nov 2010) | 9 lines
  
  Merged revisions 1034165 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1034165 | sergeyb | 2010-11-11 21:56:57 +0000 (Thu, 11 Nov 2010) | 1 line
    
    JAX-RS : finally making the servlet api dependency optional on the client, some good refactoring
of util silos will be needed in time
  ........
................

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Nov 11 22:21:40 2010
@@ -0,0 +1,2 @@
+/cxf/branches/2.3.x-fixes:1034170
+/cxf/trunk:1034165

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1034180&r1=1034179&r2=1034180&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Thu Nov 11 22:21:40 2010
@@ -47,10 +47,6 @@ import java.util.SortedSet;
 import java.util.TreeSet;
 import java.util.logging.Logger;
 
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
@@ -63,6 +59,7 @@ import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.Providers;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PrimitiveUtils;
@@ -74,16 +71,12 @@ import org.apache.cxf.jaxrs.impl.Metadat
 import org.apache.cxf.jaxrs.impl.PathSegmentImpl;
 import org.apache.cxf.jaxrs.impl.tl.ThreadLocalContextResolver;
 import org.apache.cxf.jaxrs.impl.tl.ThreadLocalHttpHeaders;
-import org.apache.cxf.jaxrs.impl.tl.ThreadLocalHttpServletRequest;
-import org.apache.cxf.jaxrs.impl.tl.ThreadLocalHttpServletResponse;
 import org.apache.cxf.jaxrs.impl.tl.ThreadLocalMessageContext;
 import org.apache.cxf.jaxrs.impl.tl.ThreadLocalProtocolHeaders;
 import org.apache.cxf.jaxrs.impl.tl.ThreadLocalProviders;
 import org.apache.cxf.jaxrs.impl.tl.ThreadLocalProxy;
 import org.apache.cxf.jaxrs.impl.tl.ThreadLocalRequest;
 import org.apache.cxf.jaxrs.impl.tl.ThreadLocalSecurityContext;
-import org.apache.cxf.jaxrs.impl.tl.ThreadLocalServletConfig;
-import org.apache.cxf.jaxrs.impl.tl.ThreadLocalServletContext;
 import org.apache.cxf.jaxrs.impl.tl.ThreadLocalUriInfo;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 import org.apache.cxf.jaxrs.model.Parameter;
@@ -95,7 +88,12 @@ public final class InjectionUtils {
     
     private static final Logger LOG = LogUtils.getL7dLogger(InjectionUtils.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(InjectionUtils.class);
-    
+
+    private static final String SERVLET_CONFIG_CLASS_NAME = "javax.servlet.ServletConfig";
+    private static final String SERVLET_CONTEXT_CLASS_NAME = "javax.servlet.ServletContext";
+    private static final String HTTP_SERVLET_REQUEST_CLASS_NAME = "javax.servlet.http.HttpServletRequest";
+    private static final String HTTP_SERVLET_RESPONSE_CLASS_NAME = "javax.servlet.http.HttpServletResponse";
+        
     private InjectionUtils() {
         
     }
@@ -725,14 +723,12 @@ public final class InjectionUtils {
             proxy = new ThreadLocalRequest();
         }  else if (Providers.class.isAssignableFrom(type)) {
             proxy = new ThreadLocalProviders();
-        } 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);  
+            proxy = createThreadLocalServletApiContext(type.getName());  
         }
         
         return proxy;
@@ -742,18 +738,23 @@ public final class InjectionUtils {
         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 (ServletConfig.class.isAssignableFrom(type)) {
-            proxy = new ThreadLocalServletConfig();
+    private static ThreadLocalProxy createThreadLocalServletApiContext(String name) {
+        String proxyClassName = null;
+        if (HTTP_SERVLET_REQUEST_CLASS_NAME.equals(name)) {
+            proxyClassName = "org.apache.cxf.jaxrs.impl.tl.ThreadLocalHttpServletRequest";
+        } else if (HTTP_SERVLET_RESPONSE_CLASS_NAME.equals(name)) {
+            proxyClassName = "org.apache.cxf.jaxrs.impl.tl.ThreadLocalHttpServletResponse";
+        } else if (SERVLET_CONTEXT_CLASS_NAME.equals(name)) {
+            proxyClassName = "org.apache.cxf.jaxrs.impl.tl.ThreadLocalServletContext";
+        } else if (SERVLET_CONFIG_CLASS_NAME.equals(name)) {
+            proxyClassName = "org.apache.cxf.jaxrs.impl.tl.ThreadLocalServletConfig";
+        }
+        try {
+            return (ThreadLocalProxy)ClassLoaderUtils.loadClass(proxyClassName, InjectionUtils.class)
+                .newInstance();
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
         }
-        return proxy;
     }
     
     public static void injectContextProxies(AbstractResourceInfo cri, Object instance) {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1034180&r1=1034179&r2=1034180&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Thu Nov 11 22:21:40 2010
@@ -803,8 +803,9 @@ public final class JAXRSUtils {
         } else if (MessageContext.class.isAssignableFrom(clazz)) {
             o = new MessageContextImpl(m);
         }
-        
-        o = o == null ? createServletResourceValue(contextMessage, clazz) : o;
+        if (o == null && contextMessage != null && !MessageUtils.isRequestor(contextMessage))
{
+            o = createServletResourceValue(contextMessage, clazz);
+        }
         return clazz.cast(o);
     }
     



Mime
View raw message