cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [3/4] git commit: Remove some reflection code that's not needed by dropping support for Jetty 7
Date Tue, 05 Aug 2014 17:53:42 GMT
Remove some reflection code that's not needed by dropping support for Jetty 7


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/944eb0ba
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/944eb0ba
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/944eb0ba

Branch: refs/heads/master
Commit: 944eb0ba1043bd4daf9cf087b66bc9cab10b8ff2
Parents: 13dfe0f
Author: Daniel Kulp <dkulp@apache.org>
Authored: Tue Aug 5 12:39:35 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Tue Aug 5 12:39:35 2014 -0400

----------------------------------------------------------------------
 .../http_jetty/JettyHTTPDestination.java        | 69 ++------------------
 1 file changed, 6 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/944eb0ba/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
index 703b552..3907b26 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
@@ -38,7 +38,6 @@ import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.ReflectionUtil;
 import org.apache.cxf.configuration.jsse.TLSServerParameters;
 import org.apache.cxf.configuration.security.CertificateConstraintsType;
 import org.apache.cxf.continuations.ContinuationProvider;
@@ -52,11 +51,9 @@ import org.apache.cxf.transport.http.DestinationRegistry;
 import org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProvider;
 import org.apache.cxf.transport.https.CertConstraintsJaxBUtils;
 import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
-import org.eclipse.jetty.http.Generator;
-import org.eclipse.jetty.io.AbstractConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
 import org.eclipse.jetty.server.AbstractHttpConnection.Output;
 import org.eclipse.jetty.server.Request;
-import org.springframework.util.ClassUtils;
 
 
 public class JettyHTTPDestination extends AbstractHTTPDestination {
@@ -208,24 +205,7 @@ public class JettyHTTPDestination extends AbstractHTTPDestination {
                              HttpServletResponse resp) throws IOException {
         doService(servletContext, req, resp);
     }
-    
-    static AbstractConnection getConnectionForRequest(Request r) {
-        try {
-            return (AbstractConnection)r.getClass().getMethod("getConnection").invoke(r);
-        } catch (Exception ex) {
-            return null;
-        }
-    }
-    
-    private void setHeadFalse(AbstractConnection con) {
-        try {
-            Generator gen = (Generator)con.getClass().getMethod("getGenerator").invoke(con);
-            gen.setHead(false);
-        } catch (Exception ex) {
-            //ignore - can continue
-        }
-    }
-    
+        
     protected void doService(ServletContext context,
                              HttpServletRequest req,
                              HttpServletResponse resp) throws IOException {
@@ -235,14 +215,6 @@ public class JettyHTTPDestination extends AbstractHTTPDestination {
         Request baseRequest = (req instanceof Request) 
             ? (Request)req : getCurrentRequest();
             
-        if (!"HEAD".equals(req.getMethod())) {
-            //bug in Jetty with persistent connections that if a HEAD is
-            //sent, a _head flag is never reset
-            AbstractConnection c = getConnectionForRequest(baseRequest);
-            if (c != null) {
-                setHeadFalse(c);
-            }
-        }
         HTTPServerPolicy sp = getServer();
         if (sp.isSetRedirectURL()) {
             resp.sendRedirect(sp.getRedirectURL());
@@ -384,40 +356,11 @@ public class JettyHTTPDestination extends AbstractHTTPDestination {
         }
     }
     
-    private AbstractConnection getCurrentConnection() {
-        // AbstractHttpConnection on Jetty 7.6, HttpConnection on Jetty <=7.5
-        Class<?> cls = null;
-        try {
-            cls = ClassUtils.forName("org.eclipse.jetty.server.AbstractHttpConnection",
-                                     AbstractConnection.class.getClassLoader());
-        } catch (Exception e) {
-            //ignore
-        }
-        if (cls == null) {
-            try {
-                cls = ClassUtils.forName("org.eclipse.jetty.server.HttpConnection",
-                                         AbstractConnection.class.getClassLoader());
-            } catch (Exception e) {
-                //ignore
-            }
-        }
-
-        try {
-            return (AbstractConnection)ReflectionUtil
-                .setAccessible(cls.getMethod("getCurrentConnection")).invoke(null);
-        } catch (Exception e) {
-            //ignore
-        }
-        return null;
+    private AbstractHttpConnection getCurrentConnection() {
+        return AbstractHttpConnection.getCurrentConnection();
     }
     private Request getCurrentRequest() {
-        AbstractConnection con = getCurrentConnection();
-        try {
-            return (Request)ReflectionUtil
-                .setAccessible(con.getClass().getMethod("getRequest")).invoke(con);
-        } catch (Exception e) {
-            //ignore
-        }
-        return null;
+        AbstractHttpConnection con = getCurrentConnection();
+        return con.getRequest();
     }
 }


Mime
View raw message