From 2ca6b4521b07323ae46650d4e688a4a199f42349 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 4 Apr 2011 05:19:17 +0000 Subject: [PATCH] 341736 Split jetty-nested out of war module git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2959 7e9141cc-0065-0410-87d8-b60c137991c4 --- VERSION.txt | 1 + jetty-nested/pom.xml | 4 +-- .../jetty/nested/NestedConnection.java | 13 +++++-- .../eclipse/jetty/nested/NestedConnector.java | 34 ++++++++++++++++++- .../eclipse/jetty/nested/NestedParser.java | 9 +---- pom.xml | 1 + test-jetty-nested/pom.xml | 28 +++++++++++++++ .../java/org/eclipse/jetty/nested/Dump.java | 0 .../jetty/nested/NestedJettyServlet.java | 6 +--- .../src/main/webapp/WEB-INF/jetty.xml | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../src/main/webapp/index.html | 0 .../src/main/webapp/nested/WEB-INF/web.xml | 0 .../src/main/webapp/nested/dump.jsp | 0 .../src/main/webapp/nested/index.html | 0 15 files changed, 78 insertions(+), 18 deletions(-) create mode 100644 test-jetty-nested/pom.xml rename {jetty-nested => test-jetty-nested}/src/main/java/org/eclipse/jetty/nested/Dump.java (100%) rename {jetty-nested => test-jetty-nested}/src/main/java/org/eclipse/jetty/nested/NestedJettyServlet.java (92%) rename {jetty-nested => test-jetty-nested}/src/main/webapp/WEB-INF/jetty.xml (100%) rename {jetty-nested => test-jetty-nested}/src/main/webapp/WEB-INF/web.xml (100%) rename {jetty-nested => test-jetty-nested}/src/main/webapp/index.html (100%) rename {jetty-nested => test-jetty-nested}/src/main/webapp/nested/WEB-INF/web.xml (100%) rename {jetty-nested => test-jetty-nested}/src/main/webapp/nested/dump.jsp (100%) rename {jetty-nested => test-jetty-nested}/src/main/webapp/nested/index.html (100%) diff --git a/VERSION.txt b/VERSION.txt index 952489b4916..e2023cf8a2f 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -22,6 +22,7 @@ jetty-7.4.0-SNAPSHOT + 341394 Remove 'Unavailable' JMX attributes of WebAppContext MBean + 341439 Blocking HttpClient does not use soTimeout for timeouts + 341561 Exception when adding o.e.j.s.DoSFilter as managed attribute + + 341736 Split jetty-nested out of war module + JETTY-1245 Pooled Buffers implementation + JETTY-1354 Added jetty-nested + Ensure generated fragment names are unique diff --git a/jetty-nested/pom.xml b/jetty-nested/pom.xml index 599fd9ba2b9..31a579af7a9 100644 --- a/jetty-nested/pom.xml +++ b/jetty-nested/pom.xml @@ -8,7 +8,7 @@ jetty-nested Jetty :: Nested - war + jar @@ -16,7 +16,7 @@ org.eclipse.jetty - jetty-webapp + jetty-server ${project.version} diff --git a/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedConnection.java b/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedConnection.java index 5ecc47373db..1a2d31606b1 100644 --- a/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedConnection.java +++ b/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedConnection.java @@ -26,7 +26,7 @@ public class NestedConnection extends HttpConnection super(connector, endp, connector.getServer(), - new NestedParser(request), + new NestedParser(), new NestedGenerator(connector.getResponseBuffers(),endp,response,nestedIn), new NestedRequest()); @@ -56,7 +56,7 @@ public class NestedConnection extends HttpConnection // System.err.println(fields.toString()); } - public void handle2() throws IOException, ServletException + void service() throws IOException, ServletException { setCurrentConnection(this); try @@ -81,4 +81,13 @@ public class NestedConnection extends HttpConnection return ((NestedEndPoint)_endp).getServletInputStream(); } + /* (non-Javadoc) + * @see org.eclipse.jetty.server.HttpConnection#handle() + */ + @Override + public Connection handle() throws IOException + { + throw new IllegalStateException(); + } + } diff --git a/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedConnector.java b/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedConnector.java index 86064181189..63b0370516b 100644 --- a/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedConnector.java +++ b/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedConnector.java @@ -1,10 +1,27 @@ package org.eclipse.jetty.nested; import java.io.IOException; -import org.eclipse.jetty.server.AbstractConnector; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.server.AbstractConnector; +import org.eclipse.jetty.server.Connector; + +/** + * Nested Jetty Connector + *

+ * This Jetty {@link Connector} allows a jetty instance to be nested inside another servlet container. + * Requests received by the outer servlet container should be passed to jetty using the {@link #service(ServletRequest, ServletResponse)} method of this connector. + * + */ public class NestedConnector extends AbstractConnector { + String _serverInfo; + public NestedConnector() { setAcceptors(0); @@ -33,5 +50,20 @@ public class NestedConnector extends AbstractConnector { throw new IllegalStateException(); } + + /** + * Service a request of the outer servlet container by passing it to the nested instance of Jetty. + * @param outerRequest + * @param outerResponse + * @throws IOException + * @throws ServletException + */ + public void service(ServletRequest outerRequest, ServletResponse outerResponse) throws IOException, ServletException + { + HttpServletRequest request = (HttpServletRequest)outerRequest; + HttpServletResponse response = (HttpServletResponse)outerResponse; + NestedConnection connection=new NestedConnection(this,new NestedEndPoint(request,response),request,response,_serverInfo); + connection.service(); + } } diff --git a/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedParser.java b/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedParser.java index 68739fc0a7a..015dd5bdc05 100644 --- a/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedParser.java +++ b/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedParser.java @@ -9,38 +9,31 @@ import org.eclipse.jetty.http.Parser; public class NestedParser implements Parser { - public NestedParser(HttpServletRequest request) + public NestedParser() { - // TODO Auto-generated constructor stub } public void reset(boolean returnBuffers) { - // TODO Auto-generated method stub - } public boolean isComplete() { - // TODO Auto-generated method stub return false; } public int parseAvailable() throws IOException { - // TODO Auto-generated method stub return 0; } public boolean isMoreInBuffer() throws IOException { - // TODO Auto-generated method stub return false; } public boolean isIdle() { - // TODO Auto-generated method stub return false; } diff --git a/pom.xml b/pom.xml index e63b50ce8a4..809b8600bf8 100644 --- a/pom.xml +++ b/pom.xml @@ -312,6 +312,7 @@ test-continuation-jetty6 test-jetty-servlet test-jetty-webapp + test-jetty-nested example-jetty-embedded tests diff --git a/test-jetty-nested/pom.xml b/test-jetty-nested/pom.xml new file mode 100644 index 00000000000..4d8ca4f06f4 --- /dev/null +++ b/test-jetty-nested/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + org.eclipse.jetty + jetty-project + 7.4.0-SNAPSHOT + + test-jetty-nested + Jetty :: Nested Test + war + + + + + + + org.eclipse.jetty + jetty-nested + ${project.version} + + + org.eclipse.jetty + jetty-webapp + ${project.version} + + + diff --git a/jetty-nested/src/main/java/org/eclipse/jetty/nested/Dump.java b/test-jetty-nested/src/main/java/org/eclipse/jetty/nested/Dump.java similarity index 100% rename from jetty-nested/src/main/java/org/eclipse/jetty/nested/Dump.java rename to test-jetty-nested/src/main/java/org/eclipse/jetty/nested/Dump.java diff --git a/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedJettyServlet.java b/test-jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedJettyServlet.java similarity index 92% rename from jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedJettyServlet.java rename to test-jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedJettyServlet.java index 681f61f23e9..e954b5893be 100644 --- a/jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedJettyServlet.java +++ b/test-jetty-nested/src/main/java/org/eclipse/jetty/nested/NestedJettyServlet.java @@ -102,11 +102,7 @@ public class NestedJettyServlet implements Servlet public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { - HttpServletRequest request = (HttpServletRequest)req; - HttpServletResponse response = (HttpServletResponse)res; - - NestedConnection connection=new NestedConnection(_connector,new NestedEndPoint(request,response),request,response,_context.getServerInfo()); - connection.handle2(); + _connector.service(req,res); } public String getServletInfo() diff --git a/jetty-nested/src/main/webapp/WEB-INF/jetty.xml b/test-jetty-nested/src/main/webapp/WEB-INF/jetty.xml similarity index 100% rename from jetty-nested/src/main/webapp/WEB-INF/jetty.xml rename to test-jetty-nested/src/main/webapp/WEB-INF/jetty.xml diff --git a/jetty-nested/src/main/webapp/WEB-INF/web.xml b/test-jetty-nested/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from jetty-nested/src/main/webapp/WEB-INF/web.xml rename to test-jetty-nested/src/main/webapp/WEB-INF/web.xml diff --git a/jetty-nested/src/main/webapp/index.html b/test-jetty-nested/src/main/webapp/index.html similarity index 100% rename from jetty-nested/src/main/webapp/index.html rename to test-jetty-nested/src/main/webapp/index.html diff --git a/jetty-nested/src/main/webapp/nested/WEB-INF/web.xml b/test-jetty-nested/src/main/webapp/nested/WEB-INF/web.xml similarity index 100% rename from jetty-nested/src/main/webapp/nested/WEB-INF/web.xml rename to test-jetty-nested/src/main/webapp/nested/WEB-INF/web.xml diff --git a/jetty-nested/src/main/webapp/nested/dump.jsp b/test-jetty-nested/src/main/webapp/nested/dump.jsp similarity index 100% rename from jetty-nested/src/main/webapp/nested/dump.jsp rename to test-jetty-nested/src/main/webapp/nested/dump.jsp diff --git a/jetty-nested/src/main/webapp/nested/index.html b/test-jetty-nested/src/main/webapp/nested/index.html similarity index 100% rename from jetty-nested/src/main/webapp/nested/index.html rename to test-jetty-nested/src/main/webapp/nested/index.html