Author: dkulp Date: Tue Mar 13 20:35:53 2012 New Revision: 1300344 URL: http://svn.apache.org/viewvc?rev=1300344&view=rev Log: Merged revisions 1300343 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes
................ r1300343 | dkulp | 2012-03-13 16:35:00 -0400 (Tue, 13 Mar 2012) | 9 lines Merged revisions 1300342 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1300342 | dkulp | 2012-03-13 16:34:14 -0400 (Tue, 13 Mar 2012) | 1 line [CXF-4175] more fixes for Jetty compatibility ........ ................ Modified: cxf/branches/2.4.x-fixes/ (props changed) cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java Propchange: cxf/branches/2.4.x-fixes/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Mar 13 20:35:53 2012 @@ -1,2 +1,2 @@ -/cxf/branches/2.5.x-fixes:1299092,1299637,1299725,1300270 -/cxf/trunk:1298830,1299635,1299682 +/cxf/branches/2.5.x-fixes:1299092,1299637,1299725,1300270,1300343 +/cxf/trunk:1298830,1299635,1299682,1300342 Propchange: cxf/branches/2.4.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=1300344&r1=1300343&r2=1300344&view=diff ============================================================================== --- cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java (original) +++ cxf/branches/2.4.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java Tue Mar 13 20:35:53 2012 @@ -51,10 +51,10 @@ import org.apache.cxf.transport.https.Ce import org.apache.cxf.transports.http.QueryHandler; import org.apache.cxf.transports.http.QueryHandlerRegistry; import org.apache.cxf.transports.http.StemMatchingQueryHandler; +import org.eclipse.jetty.http.Generator; import org.eclipse.jetty.io.AbstractConnection; -import org.eclipse.jetty.server.AsyncHttpConnection; -import org.eclipse.jetty.server.BlockingHttpConnection; import org.eclipse.jetty.server.Request; +import org.springframework.util.ClassUtils; public class JettyHTTPDestination extends AbstractHTTPDestination { @@ -221,6 +221,15 @@ public class JettyHTTPDestination extend } } + private void setHeadFalse(AbstractConnection con) { + try { + Generator gen = (Generator)con.getClass().getMethod("getGenerator").invoke(con); + gen.setHead(true); + } catch (Exception ex) { + //ignore - can continue + } + } + protected void doService(ServletContext context, HttpServletRequest req, HttpServletResponse resp) throws IOException { @@ -235,11 +244,7 @@ public class JettyHTTPDestination extend //sent, a _head flag is never reset AbstractConnection c = getConnectionForRequest(baseRequest); if (c != null) { - if (c instanceof AsyncHttpConnection) { - ((AsyncHttpConnection)c).getGenerator().setHead(false); - } else if (c instanceof BlockingHttpConnection) { - ((BlockingHttpConnection)c).getGenerator().setHead(false); - } + setHeadFalse(c); } } if (getServer().isSetRedirectURL()) { @@ -377,8 +382,23 @@ public class JettyHTTPDestination extend } private AbstractConnection getCurrentConnection() { - Class<?> cls = AsyncHttpConnection.class.getSuperclass(); // 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); @@ -389,10 +409,11 @@ public class JettyHTTPDestination extend } private Request getCurrentRequest() { AbstractConnection con = getCurrentConnection(); - if (con instanceof AsyncHttpConnection) { - return ((AsyncHttpConnection)con).getRequest(); - } else if (con instanceof BlockingHttpConnection) { - return ((BlockingHttpConnection)con).getRequest(); + try { + return (Request)ReflectionUtil + .setAccessible(con.getClass().getMethod("getRequest")).invoke(con); + } catch (Exception e) { + //ignore } return null; }
