JBossWeb SVN: r2012 - tags.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-03-28 09:53:15 -0400 (Wed, 28 Mar 2012)
New Revision: 2012
Added:
tags/JBOSSWEB_7_0_14_FINAL/
Log:
Web 7.0.14.
12 years, 9 months
JBossWeb SVN: r2011 - branches/7.0.x/java/org/apache/coyote and 6 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-03-28 08:51:24 -0400 (Wed, 28 Mar 2012)
New Revision: 2011
Added:
branches/7.0.x/java/org/jboss/servlet/http/UpgradableHttpServletResponse.java
branches/7.0.x/test/java/org/jboss/web/upgrade/
branches/7.0.x/test/java/org/jboss/web/upgrade/UpgradeServletTest.java
Modified:
branches/7.0.x/java/org/apache/catalina/connector/LocalStrings.properties
branches/7.0.x/java/org/apache/catalina/connector/Response.java
branches/7.0.x/java/org/apache/catalina/connector/ResponseFacade.java
branches/7.0.x/java/org/apache/coyote/ActionCode.java
branches/7.0.x/java/org/apache/coyote/http11/Http11AprProcessor.java
branches/7.0.x/java/org/apache/coyote/http11/InternalAprInputBuffer.java
branches/7.0.x/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
branches/7.0.x/webapps/docs/changelog.xml
trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java
trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
Log:
- Port upgrade API, since it is very simple and integrated with the existing event API.
- Add recycling of the filters, just in case.
Modified: branches/7.0.x/java/org/apache/catalina/connector/LocalStrings.properties
===================================================================
--- branches/7.0.x/java/org/apache/catalina/connector/LocalStrings.properties 2012-03-28 08:18:47 UTC (rev 2010)
+++ branches/7.0.x/java/org/apache/catalina/connector/LocalStrings.properties 2012-03-28 12:51:24 UTC (rev 2011)
@@ -39,6 +39,9 @@
coyoteResponse.sendFile.ise=Cannot call sendFile() after the response has been committed
coyoteResponse.sendFile.no=Sendfile is disabled
coyoteResponse.sendFile.path=Invalid path
+coyoteResponse.upgrade.ise=Cannot call sendUpgrade() after the response has been committed
+coyoteResponse.upgrade.noEvents=Cannot upgrade from HTTP/1.1 without IO events
+coyoteResponse.upgrade.noHttpEventServlet=Cannot upgrade from HTTP/1.1 is not using an HttpEventServlet
#
# CoyoteRequest
Modified: branches/7.0.x/java/org/apache/catalina/connector/Response.java
===================================================================
--- branches/7.0.x/java/org/apache/catalina/connector/Response.java 2012-03-28 08:18:47 UTC (rev 2010)
+++ branches/7.0.x/java/org/apache/catalina/connector/Response.java 2012-03-28 12:51:24 UTC (rev 2011)
@@ -47,6 +47,7 @@
import org.apache.catalina.util.CharsetMapper;
import org.apache.catalina.util.DateTool;
import org.apache.catalina.util.StringManager;
+import org.apache.coyote.ActionCode;
import org.apache.naming.resources.CacheEntry;
import org.apache.naming.resources.ProxyDirContext;
import org.apache.tomcat.util.buf.CharChunk;
@@ -1341,6 +1342,38 @@
}
+ public void sendUpgrade()
+ throws IOException {
+
+ if (isCommitted())
+ throw new IllegalStateException
+ (sm.getString("coyoteResponse.upgrade.ise"));
+
+ if (!connector.hasIoEvents())
+ throw new IllegalStateException
+ (sm.getString("coyoteResponse.upgrade.noEvents"));
+
+ if (!request.isEventMode() || request.getAsyncContext() != null)
+ throw new IllegalStateException
+ (sm.getString("coyoteResponse.upgrade.noHttpEventServlet"));
+
+ // Ignore any call from an included servlet
+ if (included)
+ return;
+
+ // Clear any data content that has been buffered
+ resetBuffer();
+
+ // Output required by RFC2616. Protocol specific headers should have
+ // already been set.
+ setStatus(HttpServletResponse.SC_SWITCHING_PROTOCOLS);
+
+ outputBuffer.flush();
+ request.getCoyoteRequest().action(ActionCode.UPGRADE, null);
+
+ }
+
+
public void sendFile(String path, String absolutePath, long start, long end) {
if (isCommitted())
Modified: branches/7.0.x/java/org/apache/catalina/connector/ResponseFacade.java
===================================================================
--- branches/7.0.x/java/org/apache/catalina/connector/ResponseFacade.java 2012-03-28 08:18:47 UTC (rev 2010)
+++ branches/7.0.x/java/org/apache/catalina/connector/ResponseFacade.java 2012-03-28 12:51:24 UTC (rev 2011)
@@ -34,6 +34,7 @@
import org.apache.catalina.Globals;
import org.apache.catalina.security.SecurityUtil;
import org.apache.catalina.util.StringManager;
+import org.jboss.servlet.http.UpgradableHttpServletResponse;
/**
* Facade class that wraps a Coyote response object.
@@ -45,7 +46,7 @@
*/
@SuppressWarnings("deprecation")
public class ResponseFacade
- implements HttpServletResponse {
+ implements HttpServletResponse, UpgradableHttpServletResponse {
// ----------------------------------------------------------- DoPrivileged
@@ -454,6 +455,19 @@
}
+ public void sendUpgrade()
+ throws IOException {
+
+ if (isCommitted())
+ throw new IllegalStateException
+ (/*sm.getString("responseBase.reset.ise")*/);
+
+ response.setAppCommitted(true);
+
+ response.sendUpgrade();
+
+ }
+
public void setDateHeader(String name, long date) {
if (isCommitted())
Modified: branches/7.0.x/java/org/apache/coyote/ActionCode.java
===================================================================
--- branches/7.0.x/java/org/apache/coyote/ActionCode.java 2012-03-28 08:18:47 UTC (rev 2010)
+++ branches/7.0.x/java/org/apache/coyote/ActionCode.java 2012-03-28 12:51:24 UTC (rev 2011)
@@ -171,6 +171,11 @@
*/
public static final ActionCode ACTION_EVENT_WRITE = new ActionCode(27);
+ /**
+ * Ask for a protocol upgrade
+ */
+ public static final ActionCode UPGRADE = new ActionCode(28);
+
// ----------------------------------------------------------- Constructors
int code;
Modified: branches/7.0.x/java/org/apache/coyote/http11/Http11AprProcessor.java
===================================================================
--- branches/7.0.x/java/org/apache/coyote/http11/Http11AprProcessor.java 2012-03-28 08:18:47 UTC (rev 2010)
+++ branches/7.0.x/java/org/apache/coyote/http11/Http11AprProcessor.java 2012-03-28 12:51:24 UTC (rev 2011)
@@ -1297,6 +1297,10 @@
writeNotification = true;
} else if (actionCode == ActionCode.ACTION_EVENT_TIMEOUT) {
timeout = ((Integer) param).intValue();
+ } else if (actionCode == ActionCode.UPGRADE) {
+ // Switch to raw bytes mode
+ inputBuffer.removeActiveFilters();
+ outputBuffer.removeActiveFilters();
}
}
@@ -1653,7 +1657,7 @@
}
int statusCode = response.getStatus();
- if ((statusCode == 204) || (statusCode == 205)
+ if ((statusCode == 101) || (statusCode == 204) || (statusCode == 205)
|| (statusCode == 304)) {
// No entity body
outputBuffer.addActiveFilter
Modified: branches/7.0.x/java/org/apache/coyote/http11/InternalAprInputBuffer.java
===================================================================
--- branches/7.0.x/java/org/apache/coyote/http11/InternalAprInputBuffer.java 2012-03-28 08:18:47 UTC (rev 2010)
+++ branches/7.0.x/java/org/apache/coyote/http11/InternalAprInputBuffer.java 2012-03-28 12:51:24 UTC (rev 2011)
@@ -288,6 +288,15 @@
}
+ public void removeActiveFilters() {
+ // Recycle filters
+ for (int i = 0; i <= lastActiveFilter; i++) {
+ activeFilters[i].recycle();
+ }
+ lastActiveFilter = -1;
+ }
+
+
/**
* Set the swallow input flag.
*/
Modified: branches/7.0.x/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
===================================================================
--- branches/7.0.x/java/org/apache/coyote/http11/InternalAprOutputBuffer.java 2012-03-28 08:18:47 UTC (rev 2010)
+++ branches/7.0.x/java/org/apache/coyote/http11/InternalAprOutputBuffer.java 2012-03-28 12:51:24 UTC (rev 2011)
@@ -283,6 +283,15 @@
}
+ public void removeActiveFilters() {
+ // Recycle filters
+ for (int i = 0; i <= lastActiveFilter; i++) {
+ activeFilters[i].recycle();
+ }
+ lastActiveFilter = -1;
+ }
+
+
// --------------------------------------------------------- Public Methods
Added: branches/7.0.x/java/org/jboss/servlet/http/UpgradableHttpServletResponse.java
===================================================================
--- branches/7.0.x/java/org/jboss/servlet/http/UpgradableHttpServletResponse.java (rev 0)
+++ branches/7.0.x/java/org/jboss/servlet/http/UpgradableHttpServletResponse.java 2012-03-28 12:51:24 UTC (rev 2011)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.servlet.http;
+
+import java.io.IOException;
+
+/**
+ * Upgradable HTTP Servlet response.
+ *
+ * @author remm
+ */
+public interface UpgradableHttpServletResponse {
+
+ public void sendUpgrade()
+ throws IOException;
+
+}
Added: branches/7.0.x/test/java/org/jboss/web/upgrade/UpgradeServletTest.java
===================================================================
--- branches/7.0.x/test/java/org/jboss/web/upgrade/UpgradeServletTest.java (rev 0)
+++ branches/7.0.x/test/java/org/jboss/web/upgrade/UpgradeServletTest.java 2012-03-28 12:51:24 UTC (rev 2011)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.web.upgrade;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.servlet.http.HttpEvent;
+import org.jboss.servlet.http.HttpEventServlet;
+import org.jboss.servlet.http.UpgradableHttpServletResponse;
+
+@WebServlet("/upgrade")
+public class UpgradeServletTest extends HttpServlet implements HttpEventServlet {
+
+ int count = 0;
+
+ public void event(HttpEvent event) throws IOException, ServletException {
+ System.out.println("[" + event.getHttpServletRequest().getSession(true).getId() + "] " + event.getType());
+ switch (event.getType()) {
+ case BEGIN:
+ event.setTimeout(20000);
+ HttpServletResponse response = event.getHttpServletResponse();
+ if (response instanceof UpgradableHttpServletResponse) {
+ response.setHeader("Upgrade", "Foobar");
+ response.setHeader("Connection", "Upgrade");
+ ((UpgradableHttpServletResponse) response).sendUpgrade();
+ } else {
+ throw new IllegalStateException("Cannot upgrade connection");
+ }
+ break;
+ case END:
+ break;
+ case ERROR:
+ event.close();
+ break;
+ case EVENT:
+ ServletOutputStream os = event.getHttpServletResponse().getOutputStream();
+ // Using while (true): Not checking if the connection is available to writing immediately
+ // will cause the write to be performed in blocking mode.
+ // boolean b = true;
+ // while (b) {
+ while (event.isWriteReady()) {
+ if (count % 100 == 0) {
+ os.println((count++) + " ");
+ } else {
+ os.print((count++) + " ");
+ }
+ }
+ //if (event.ready())
+ // os.flush();
+ break;
+ case READ:
+ ServletInputStream is = event.getHttpServletRequest().getInputStream();
+ // Using while (true): Not checking if input is available will trigger a blocking
+ // read. No other event should be triggered (the current READ event will be in progress
+ // until the read timeouts, which will trigger an ERROR event due to an IOException).
+ // while (true) {
+ while (is.available() > 0) {
+ int c = is.read();
+ if (c > 0) {
+ System.out.print((char) c);
+ } else {
+ System.out.print(c);
+ break;
+ }
+ }
+ System.out.println();
+ break;
+ case TIMEOUT:
+ // This will cause a generic event to be sent to the servlet every time the connection is idle for
+ // a while.
+ event.resume();
+ break;
+ case WRITE:
+ break;
+ }
+ }
+
+}
Modified: branches/7.0.x/webapps/docs/changelog.xml
===================================================================
--- branches/7.0.x/webapps/docs/changelog.xml 2012-03-28 08:18:47 UTC (rev 2010)
+++ branches/7.0.x/webapps/docs/changelog.xml 2012-03-28 12:51:24 UTC (rev 2011)
@@ -24,6 +24,9 @@
<fix>
<jboss-jira>JBPAPP-8505</jboss-jira>: Add back the multi files logic for Windows. (jfclere/mturk)
</fix>
+ <add>
+ Protocol upgrade API. (remm)
+ </add>
</changelog>
</subsection>
</section>
Modified: trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java
===================================================================
--- trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java 2012-03-28 08:18:47 UTC (rev 2010)
+++ trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java 2012-03-28 12:51:24 UTC (rev 2011)
@@ -289,6 +289,10 @@
public void removeActiveFilters() {
+ // Recycle filters
+ for (int i = 0; i <= lastActiveFilter; i++) {
+ activeFilters[i].recycle();
+ }
lastActiveFilter = -1;
}
Modified: trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
===================================================================
--- trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java 2012-03-28 08:18:47 UTC (rev 2010)
+++ trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java 2012-03-28 12:51:24 UTC (rev 2011)
@@ -284,6 +284,10 @@
public void removeActiveFilters() {
+ // Recycle filters
+ for (int i = 0; i <= lastActiveFilter; i++) {
+ activeFilters[i].recycle();
+ }
lastActiveFilter = -1;
}
12 years, 9 months
JBossWeb SVN: r2010 - in trunk/java/org: jboss/web and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-03-28 04:18:47 -0400 (Wed, 28 Mar 2012)
New Revision: 2010
Removed:
trunk/java/org/jboss/web/upgrade/
Modified:
trunk/java/org/apache/catalina/connector/Response.java
Log:
Remove the suspend, since the response is not done. Also remove the new fancier API since it is not realistic to add
a new API that will be immediately removed when Servlet 3.1 is implemented.
Modified: trunk/java/org/apache/catalina/connector/Response.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Response.java 2012-03-27 23:20:28 UTC (rev 2009)
+++ trunk/java/org/apache/catalina/connector/Response.java 2012-03-28 08:18:47 UTC (rev 2010)
@@ -1371,9 +1371,6 @@
outputBuffer.flush();
request.getCoyoteRequest().action(ActionCode.UPGRADE, null);
- // Cause the response to be finished (from the application perspective)
- setSuspended(true);
-
}
12 years, 9 months
JBossWeb SVN: r2009 - in trunk: java/org/apache/coyote/http11 and 4 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-03-27 19:20:28 -0400 (Tue, 27 Mar 2012)
New Revision: 2009
Added:
trunk/java/org/jboss/servlet/http/UpgradableHttpServletResponse.java
trunk/test/java/org/jboss/web/upgrade/
trunk/test/java/org/jboss/web/upgrade/UpgradeServletTest.java
Modified:
trunk/java/org/apache/catalina/connector/LocalStrings.properties
trunk/java/org/apache/catalina/connector/Response.java
trunk/java/org/apache/catalina/connector/ResponseFacade.java
trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java
trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
trunk/test/java/org/apache/el/lang/TestELSupport.java
Log:
Add simpler connection upgrade, now using the existing HttpEventServlet API.
Modified: trunk/java/org/apache/catalina/connector/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/connector/LocalStrings.properties 2012-03-27 16:31:59 UTC (rev 2008)
+++ trunk/java/org/apache/catalina/connector/LocalStrings.properties 2012-03-27 23:20:28 UTC (rev 2009)
@@ -41,6 +41,7 @@
coyoteResponse.sendFile.path=Invalid path
coyoteResponse.upgrade.ise=Cannot call sendUpgrade() after the response has been committed
coyoteResponse.upgrade.noEvents=Cannot upgrade from HTTP/1.1 without IO events
+coyoteResponse.upgrade.noHttpEventServlet=Cannot upgrade from HTTP/1.1 is not using an HttpEventServlet
#
# CoyoteRequest
Modified: trunk/java/org/apache/catalina/connector/Response.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Response.java 2012-03-27 16:31:59 UTC (rev 2008)
+++ trunk/java/org/apache/catalina/connector/Response.java 2012-03-27 23:20:28 UTC (rev 2009)
@@ -1342,7 +1342,7 @@
}
- public void sendUpgrade(org.jboss.web.upgrade.ProtocolHandler protocolHandler)
+ public void sendUpgrade()
throws IOException {
if (isCommitted())
@@ -1353,12 +1353,24 @@
throw new IllegalStateException
(sm.getString("coyoteResponse.upgrade.noEvents"));
- request.getCoyoteRequest().action(ActionCode.UPGRADE, protocolHandler);
+ if (!request.isEventMode() || request.getAsyncContext() != null)
+ throw new IllegalStateException
+ (sm.getString("coyoteResponse.upgrade.noHttpEventServlet"));
+ // Ignore any call from an included servlet
+ if (included)
+ return;
+
+ // Clear any data content that has been buffered
+ resetBuffer();
+
// Output required by RFC2616. Protocol specific headers should have
// already been set.
setStatus(HttpServletResponse.SC_SWITCHING_PROTOCOLS);
+ outputBuffer.flush();
+ request.getCoyoteRequest().action(ActionCode.UPGRADE, null);
+
// Cause the response to be finished (from the application perspective)
setSuspended(true);
Modified: trunk/java/org/apache/catalina/connector/ResponseFacade.java
===================================================================
--- trunk/java/org/apache/catalina/connector/ResponseFacade.java 2012-03-27 16:31:59 UTC (rev 2008)
+++ trunk/java/org/apache/catalina/connector/ResponseFacade.java 2012-03-27 23:20:28 UTC (rev 2009)
@@ -34,6 +34,7 @@
import org.apache.catalina.Globals;
import org.apache.catalina.security.SecurityUtil;
import org.apache.catalina.util.StringManager;
+import org.jboss.servlet.http.UpgradableHttpServletResponse;
/**
* Facade class that wraps a Coyote response object.
@@ -45,7 +46,7 @@
*/
@SuppressWarnings("deprecation")
public class ResponseFacade
- implements HttpServletResponse {
+ implements HttpServletResponse, UpgradableHttpServletResponse {
// ----------------------------------------------------------- DoPrivileged
@@ -454,7 +455,7 @@
}
- public void sendUpgrade(org.jboss.web.upgrade.ProtocolHandler protocolHandler)
+ public void sendUpgrade()
throws IOException {
if (isCommitted())
@@ -463,7 +464,7 @@
response.setAppCommitted(true);
- response.sendUpgrade(protocolHandler);
+ response.sendUpgrade();
}
Modified: trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
===================================================================
--- trunk/java/org/apache/coyote/http11/Http11AprProcessor.java 2012-03-27 16:31:59 UTC (rev 2008)
+++ trunk/java/org/apache/coyote/http11/Http11AprProcessor.java 2012-03-27 23:20:28 UTC (rev 2009)
@@ -1297,6 +1297,10 @@
writeNotification = true;
} else if (actionCode == ActionCode.ACTION_EVENT_TIMEOUT) {
timeout = ((Integer) param).intValue();
+ } else if (actionCode == ActionCode.UPGRADE) {
+ // Switch to raw bytes mode
+ inputBuffer.removeActiveFilters();
+ outputBuffer.removeActiveFilters();
}
}
@@ -1653,7 +1657,7 @@
}
int statusCode = response.getStatus();
- if ((statusCode == 204) || (statusCode == 205)
+ if ((statusCode == 101) || (statusCode == 204) || (statusCode == 205)
|| (statusCode == 304)) {
// No entity body
outputBuffer.addActiveFilter
Modified: trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java
===================================================================
--- trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java 2012-03-27 16:31:59 UTC (rev 2008)
+++ trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java 2012-03-27 23:20:28 UTC (rev 2009)
@@ -288,6 +288,11 @@
}
+ public void removeActiveFilters() {
+ lastActiveFilter = -1;
+ }
+
+
/**
* Set the swallow input flag.
*/
Modified: trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
===================================================================
--- trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java 2012-03-27 16:31:59 UTC (rev 2008)
+++ trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java 2012-03-27 23:20:28 UTC (rev 2009)
@@ -283,6 +283,11 @@
}
+ public void removeActiveFilters() {
+ lastActiveFilter = -1;
+ }
+
+
// --------------------------------------------------------- Public Methods
Added: trunk/java/org/jboss/servlet/http/UpgradableHttpServletResponse.java
===================================================================
--- trunk/java/org/jboss/servlet/http/UpgradableHttpServletResponse.java (rev 0)
+++ trunk/java/org/jboss/servlet/http/UpgradableHttpServletResponse.java 2012-03-27 23:20:28 UTC (rev 2009)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.servlet.http;
+
+import java.io.IOException;
+
+/**
+ * Upgradable HTTP Servlet response.
+ *
+ * @author remm
+ */
+public interface UpgradableHttpServletResponse {
+
+ public void sendUpgrade()
+ throws IOException;
+
+}
Modified: trunk/test/java/org/apache/el/lang/TestELSupport.java
===================================================================
--- trunk/test/java/org/apache/el/lang/TestELSupport.java 2012-03-27 16:31:59 UTC (rev 2008)
+++ trunk/test/java/org/apache/el/lang/TestELSupport.java 2012-03-27 23:20:28 UTC (rev 2009)
@@ -23,6 +23,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
Added: trunk/test/java/org/jboss/web/upgrade/UpgradeServletTest.java
===================================================================
--- trunk/test/java/org/jboss/web/upgrade/UpgradeServletTest.java (rev 0)
+++ trunk/test/java/org/jboss/web/upgrade/UpgradeServletTest.java 2012-03-27 23:20:28 UTC (rev 2009)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.web.upgrade;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.servlet.http.HttpEvent;
+import org.jboss.servlet.http.HttpEventServlet;
+import org.jboss.servlet.http.UpgradableHttpServletResponse;
+
+@WebServlet("/upgrade")
+public class UpgradeServletTest extends HttpServlet implements HttpEventServlet {
+
+ int count = 0;
+
+ public void event(HttpEvent event) throws IOException, ServletException {
+ System.out.println("[" + event.getHttpServletRequest().getSession(true).getId() + "] " + event.getType());
+ switch (event.getType()) {
+ case BEGIN:
+ event.setTimeout(20000);
+ HttpServletResponse response = event.getHttpServletResponse();
+ if (response instanceof UpgradableHttpServletResponse) {
+ response.setHeader("Upgrade", "Foobar");
+ response.setHeader("Connection", "Upgrade");
+ ((UpgradableHttpServletResponse) response).sendUpgrade();
+ } else {
+ throw new IllegalStateException("Cannot upgrade connection");
+ }
+ break;
+ case END:
+ break;
+ case ERROR:
+ event.close();
+ break;
+ case EVENT:
+ ServletOutputStream os = event.getHttpServletResponse().getOutputStream();
+ // Using while (true): Not checking if the connection is available to writing immediately
+ // will cause the write to be performed in blocking mode.
+ // boolean b = true;
+ // while (b) {
+ while (event.isWriteReady()) {
+ if (count % 100 == 0) {
+ os.println((count++) + " ");
+ } else {
+ os.print((count++) + " ");
+ }
+ }
+ //if (event.ready())
+ // os.flush();
+ break;
+ case READ:
+ ServletInputStream is = event.getHttpServletRequest().getInputStream();
+ // Using while (true): Not checking if input is available will trigger a blocking
+ // read. No other event should be triggered (the current READ event will be in progress
+ // until the read timeouts, which will trigger an ERROR event due to an IOException).
+ // while (true) {
+ while (is.available() > 0) {
+ int c = is.read();
+ if (c > 0) {
+ System.out.print((char) c);
+ } else {
+ System.out.print(c);
+ break;
+ }
+ }
+ System.out.println();
+ break;
+ case TIMEOUT:
+ // This will cause a generic event to be sent to the servlet every time the connection is idle for
+ // a while.
+ event.resume();
+ break;
+ case WRITE:
+ break;
+ }
+ }
+
+}
12 years, 9 months
JBossWeb SVN: r2008 - in branches/7.0.x: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2012-03-27 12:31:59 -0400 (Tue, 27 Mar 2012)
New Revision: 2008
Modified:
branches/7.0.x/java/org/apache/tomcat/util/net/JIoEndpoint.java
branches/7.0.x/webapps/docs/changelog.xml
Log:
Fix AS7-3834.... Well work-around a JVM bug in fact...
Modified: branches/7.0.x/java/org/apache/tomcat/util/net/JIoEndpoint.java
===================================================================
--- branches/7.0.x/java/org/apache/tomcat/util/net/JIoEndpoint.java 2012-03-27 08:05:18 UTC (rev 2007)
+++ branches/7.0.x/java/org/apache/tomcat/util/net/JIoEndpoint.java 2012-03-27 16:31:59 UTC (rev 2008)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.net.BindException;
+import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
@@ -1077,9 +1078,21 @@
if (address == null) {
s = new Socket("localhost", port);
} else {
- s = new Socket(address, port);
- // setting soLinger to a small value will help shutdown the
- // connection quicker
+ if (address instanceof Inet6Address && ((Inet6Address)address).isLinkLocalAddress()) {
+ /* We need to work-around a java6 bug with IPv6 */
+ String addressString = address.getHostAddress();
+ if (addressString.indexOf("%") != -1) {
+ String addressStringWithoutSuffix = addressString.substring(0, addressString.indexOf("%"));
+ InetAddress addressWithoutSuffix = InetAddress.getByName(addressStringWithoutSuffix);
+ s = new Socket (addressWithoutSuffix, port , addressWithoutSuffix, 0);
+ } else {
+ s = new Socket(address, port, address, 0);
+ }
+ } else {
+ s = new Socket(address, port);
+ }
+ // setting soLinger to a small value will help shutdown the
+ // connection quicker
s.setSoLinger(true, 0);
}
} catch (Exception e) {
Modified: branches/7.0.x/webapps/docs/changelog.xml
===================================================================
--- branches/7.0.x/webapps/docs/changelog.xml 2012-03-27 08:05:18 UTC (rev 2007)
+++ branches/7.0.x/webapps/docs/changelog.xml 2012-03-27 16:31:59 UTC (rev 2008)
@@ -19,6 +19,9 @@
<subsection name="Coyote">
<changelog>
<fix>
+ <jboss-jira>AS7-3834</jboss-jira>: Socket bind for JIoEndpoint fails on shutdown when using link-local IPv6 address. (jfclere)
+ </fix>
+ <fix>
<jboss-jira>JBPAPP-8505</jboss-jira>: Add back the multi files logic for Windows. (jfclere/mturk)
</fix>
</changelog>
12 years, 9 months
JBossWeb SVN: r2007 - branches/7.0.x/webapps/docs.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2012-03-27 04:05:18 -0400 (Tue, 27 Mar 2012)
New Revision: 2007
Modified:
branches/7.0.x/webapps/docs/changelog.xml
Log:
In fact it will go in 7.0.14.
Modified: branches/7.0.x/webapps/docs/changelog.xml
===================================================================
--- branches/7.0.x/webapps/docs/changelog.xml 2012-03-27 06:53:46 UTC (rev 2006)
+++ branches/7.0.x/webapps/docs/changelog.xml 2012-03-27 08:05:18 UTC (rev 2007)
@@ -15,13 +15,19 @@
</properties>
<body>
-
-<section name="JBoss Web 7.0.13.Final (remm)">
+<section name="JBoss Web 7.0.14.Final (remm)">
<subsection name="Coyote">
<changelog>
<fix>
<jboss-jira>JBPAPP-8505</jboss-jira>: Add back the multi files logic for Windows. (jfclere/mturk)
</fix>
+ </changelog>
+ </subsection>
+</section>
+
+<section name="JBoss Web 7.0.13.Final (remm)">
+ <subsection name="Coyote">
+ <changelog>
<fix>
<jboss-jira>AS7-3851</jboss-jira>: Cleanup IPv6 logging. (remm)
</fix>
12 years, 9 months
JBossWeb SVN: r2006 - in branches/7.0.x: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2012-03-27 02:53:46 -0400 (Tue, 27 Mar 2012)
New Revision: 2006
Modified:
branches/7.0.x/java/org/apache/tomcat/jni/Library.properties
branches/7.0.x/java/org/apache/tomcat/jni/LibraryLoader.java
branches/7.0.x/webapps/docs/changelog.xml
Log:
Fix for JBPAPP-8505.
Modified: branches/7.0.x/java/org/apache/tomcat/jni/Library.properties
===================================================================
--- branches/7.0.x/java/org/apache/tomcat/jni/Library.properties 2012-03-27 06:35:11 UTC (rev 2005)
+++ branches/7.0.x/java/org/apache/tomcat/jni/Library.properties 2012-03-27 06:53:46 UTC (rev 2006)
@@ -23,8 +23,12 @@
#
# Library.properties
#
-windows.count=1
-windows.0=*tcnative-1.dll
+windows.count=5
+windows.0=?*tcnative-1
+windows.1=?libapr-1
+windows.2=?libeay32
+windows.3=?ssleay32
+windows.4=libtcnative-1
linux2.count=5
linux2.0=apr-1
Modified: branches/7.0.x/java/org/apache/tomcat/jni/LibraryLoader.java
===================================================================
--- branches/7.0.x/java/org/apache/tomcat/jni/LibraryLoader.java 2012-03-27 06:35:11 UTC (rev 2005)
+++ branches/7.0.x/java/org/apache/tomcat/jni/LibraryLoader.java 2012-03-27 06:53:46 UTC (rev 2006)
@@ -100,14 +100,15 @@
try {
System.loadLibrary(dlibName);
log.debug("Loaded: " + dlibName);
- } catch (Throwable d) {
+ if (full)
+ break;
+ }
+ catch (Throwable d) {
log.debug("Loading " + dlibName + " throws: " + d);
if (optional)
continue;
throw new UnsatisfiedLinkError(" Error: " + d.getMessage() + " " );
}
- if (full)
- break;
}
}
Modified: branches/7.0.x/webapps/docs/changelog.xml
===================================================================
--- branches/7.0.x/webapps/docs/changelog.xml 2012-03-27 06:35:11 UTC (rev 2005)
+++ branches/7.0.x/webapps/docs/changelog.xml 2012-03-27 06:53:46 UTC (rev 2006)
@@ -20,6 +20,9 @@
<subsection name="Coyote">
<changelog>
<fix>
+ <jboss-jira>JBPAPP-8505</jboss-jira>: Add back the multi files logic for Windows. (jfclere/mturk)
+ </fix>
+ <fix>
<jboss-jira>AS7-3851</jboss-jira>: Cleanup IPv6 logging. (remm)
</fix>
<fix>
12 years, 9 months
JBossWeb SVN: r2005 - in trunk: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2012-03-27 02:35:11 -0400 (Tue, 27 Mar 2012)
New Revision: 2005
Modified:
trunk/java/org/apache/tomcat/jni/Library.properties
trunk/java/org/apache/tomcat/jni/LibraryLoader.java
trunk/webapps/docs/changelog.xml
Log:
Fix JBPAPP-8505.
Modified: trunk/java/org/apache/tomcat/jni/Library.properties
===================================================================
--- trunk/java/org/apache/tomcat/jni/Library.properties 2012-03-26 14:37:14 UTC (rev 2004)
+++ trunk/java/org/apache/tomcat/jni/Library.properties 2012-03-27 06:35:11 UTC (rev 2005)
@@ -23,8 +23,12 @@
#
# Library.properties
#
-windows.count=1
-windows.0=*tcnative-1.dll
+windows.count=5
+windows.0=?*tcnative-1
+windows.1=?libapr-1
+windows.2=?libeay32
+windows.3=?ssleay32
+windows.4=libtcnative-1
linux2.count=5
linux2.0=apr-1
Modified: trunk/java/org/apache/tomcat/jni/LibraryLoader.java
===================================================================
--- trunk/java/org/apache/tomcat/jni/LibraryLoader.java 2012-03-26 14:37:14 UTC (rev 2004)
+++ trunk/java/org/apache/tomcat/jni/LibraryLoader.java 2012-03-27 06:35:11 UTC (rev 2005)
@@ -100,14 +100,15 @@
try {
System.loadLibrary(dlibName);
log.debug("Loaded: " + dlibName);
- } catch (Throwable d) {
+ if (full)
+ break;
+ }
+ catch (Throwable d) {
log.debug("Loading " + dlibName + " throws: " + d);
if (optional)
continue;
throw new UnsatisfiedLinkError(" Error: " + d.getMessage() + " " );
}
- if (full)
- break;
}
}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2012-03-26 14:37:14 UTC (rev 2004)
+++ trunk/webapps/docs/changelog.xml 2012-03-27 06:35:11 UTC (rev 2005)
@@ -20,6 +20,9 @@
<subsection name="Coyote">
<changelog>
<fix>
+ <jboss-jira>JBPAPP-8505</jboss-jira>: Add back the multi files logic for Windows. (jfclere/mturk)
+ </fix>
+ <fix>
<jboss-jira>AS7-3851</jboss-jira>: Cleanup IPv6 logging. (remm)
</fix>
<fix>
12 years, 9 months
JBossWeb SVN: r2004 - in trunk: java/org/apache/el/util and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-03-26 10:37:14 -0400 (Mon, 26 Mar 2012)
New Revision: 2004
Modified:
trunk/java/org/apache/el/parser/AstValue.java
trunk/java/org/apache/el/util/ReflectionUtil.java
trunk/webapps/docs/changelog.xml
Log:
52970: Fix enum as method invocation argument in EL
Modified: trunk/java/org/apache/el/parser/AstValue.java
===================================================================
--- trunk/java/org/apache/el/parser/AstValue.java 2012-03-16 16:54:57 UTC (rev 2003)
+++ trunk/java/org/apache/el/parser/AstValue.java 2012-03-26 14:37:14 UTC (rev 2004)
@@ -230,7 +230,8 @@
@SuppressWarnings("rawtypes") Class[] paramTypes)
throws ELException {
Target t = getTarget(ctx);
- Method m = ReflectionUtil.getMethod(t.base, t.property, paramTypes);
+ Method m = ReflectionUtil.getMethod(
+ t.base, t.property, paramTypes, null);
return new MethodInfo(m.getName(), m.getReturnType(), m
.getParameterTypes());
}
@@ -244,19 +245,20 @@
Target t = getTarget(ctx);
Method m = null;
Object[] values = null;
+ Class<?>[] types = null;
if (isParametersProvided()) {
values = ((AstMethodParameters) this.jjtGetChild(
this.jjtGetNumChildren() - 1)).getParameters(ctx);
- Class<?>[] types = getTypesFromValues(values);
- m = ReflectionUtil.getMethod(t.base, t.property, types);
+ types = getTypesFromValues(values);
} else {
- m = ReflectionUtil.getMethod(t.base, t.property, paramTypes);
values = paramValues;
+ types = paramTypes;
}
- if (m.isVarArgs()) {
- // May need to convert values
- values = toVarArgs(values, m);
- }
+ m = ReflectionUtil.getMethod(t.base, t.property, types, values);
+
+ // Handle varArgs and any co-ercion required
+ values = convertArgs(values, m);
+
Object result = null;
try {
result = m.invoke(t.base, values);
@@ -277,17 +279,34 @@
return result;
}
- private Object[] toVarArgs(Object[] src, Method m) {
- int paramCount = m.getParameterTypes().length;
+ private Object[] convertArgs(Object[] src, Method m) {
+ Class<?>[] types = m.getParameterTypes();
+ if (types.length == 0) {
+ return new Object[0];
+ }
+ int paramCount = types.length;
+
Object[] dest = new Object[paramCount];
- Object[] varArgs = (Object[]) Array.newInstance(
- m.getParameterTypes()[paramCount - 1].getComponentType(),
- src.length - (paramCount - 1));
- System.arraycopy(src, 0, dest, 0, paramCount - 1);
- System.arraycopy(src, paramCount - 1, varArgs, 0,
- src.length - (paramCount - 1));
- dest[paramCount - 1] = varArgs;
+
+ for (int i = 0; i < paramCount - 1; i++) {
+ dest[i] = ELSupport.coerceToType(src[i], types[i]);
+ }
+
+ if (m.isVarArgs()) {
+ Object[] varArgs = (Object[]) Array.newInstance(
+ m.getParameterTypes()[paramCount - 1].getComponentType(),
+ src.length - (paramCount - 1));
+ for (int i = 0; i < src.length - (paramCount - 1); i ++) {
+ varArgs[i] = ELSupport.coerceToType(src[paramCount - 1 + i],
+ types[paramCount - 1].getComponentType());
+ }
+ dest[paramCount - 1] = varArgs;
+ } else {
+ dest[paramCount - 1] = ELSupport.coerceToType(
+ src[paramCount - 1], types[paramCount - 1]);
+ }
+
return dest;
}
Modified: trunk/java/org/apache/el/util/ReflectionUtil.java
===================================================================
--- trunk/java/org/apache/el/util/ReflectionUtil.java 2012-03-16 16:54:57 UTC (rev 2003)
+++ trunk/java/org/apache/el/util/ReflectionUtil.java 2012-03-26 14:37:14 UTC (rev 2004)
@@ -23,9 +23,12 @@
import java.util.Map;
import java.util.Set;
+import javax.el.ELException;
import javax.el.MethodNotFoundException;
+import org.apache.el.lang.ELSupport;
+
/**
* Utilities for Managing Serialization and Reflection
*
@@ -106,12 +109,14 @@
* @param base the object that owns the method
* @param property the name of the method
* @param paramTypes the parameter types to use
+ * @param paramValues the parameter values
* @return the method specified
* @throws MethodNotFoundException
*/
@SuppressWarnings("null")
public static Method getMethod(Object base, Object property,
- Class<?>[] paramTypes) throws MethodNotFoundException {
+ Class<?>[] paramTypes, Object[] paramValues)
+ throws MethodNotFoundException {
if (base == null || property == null) {
throw new MethodNotFoundException(MessageFactory.get(
"error.method.notfound", base, property,
@@ -156,21 +161,37 @@
int exactMatch = 0;
boolean noMatch = false;
for (int i = 0; i < mParamCount; i++) {
- if (paramTypes[i] == null || mParamTypes[i].equals(paramTypes[i])) {
+ // Can't be null
+ if (mParamTypes[i].equals(paramTypes[i])) {
exactMatch++;
} else if (i == (mParamCount - 1) && m.isVarArgs()) {
Class<?> varType = mParamTypes[i].getComponentType();
for (int j = i; j < paramCount; j++) {
if (!isAssignableFrom(paramTypes[j], varType)) {
- break;
+ if (paramValues == null) {
+ noMatch = true;
+ break;
+ } else {
+ if (!isCoercibleFrom(paramValues[j], varType)) {
+ noMatch = true;
+ break;
+ }
+ }
}
// Don't treat a varArgs match as an exact match, it can
// lead to a varArgs method matching when the result
// should be ambiguous
}
} else if (!isAssignableFrom(paramTypes[i], mParamTypes[i])) {
- noMatch = true;
- break;
+ if (paramValues == null) {
+ noMatch = true;
+ break;
+ } else {
+ if (!isCoercibleFrom(paramValues[i], mParamTypes[i])) {
+ noMatch = true;
+ break;
+ }
+ }
}
}
if (noMatch) {
@@ -298,6 +319,17 @@
return targetClass.isAssignableFrom(src);
}
+ private static boolean isCoercibleFrom(Object src, Class<?> target) {
+ // TODO: This isn't pretty but it works. Significant refactoring would
+ // be required to avoid the exception.
+ try {
+ ELSupport.coerceToType(src, target);
+ } catch (ELException e) {
+ return false;
+ }
+ return true;
+ }
+
protected static final String paramString(Class<?>[] types) {
if (types != null) {
StringBuilder sb = new StringBuilder();
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2012-03-16 16:54:57 UTC (rev 2003)
+++ trunk/webapps/docs/changelog.xml 2012-03-26 14:37:14 UTC (rev 2004)
@@ -35,6 +35,9 @@
<fix>
<bug>52776</bug>: Fix cleanup after JspFragment.invoke. Sumitted by Karl von Randow. (markt)
</fix>
+ <fix>
+ <bug>52970</bug>: Fix enum as method invocation argument in EL. (markt)
+ </fix>
</changelog>
</subsection>
</section>
12 years, 9 months
JBossWeb SVN: r2003 - in trunk: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2012-03-16 12:54:57 -0400 (Fri, 16 Mar 2012)
New Revision: 2003
Modified:
trunk/java/org/jboss/web/upgrade/ProtocolHandler.java
trunk/java/org/jboss/web/upgrade/WebConnection.java
trunk/webapps/docs/changelog.xml
Log:
Fix glitches and add javadoc.
Modified: trunk/java/org/jboss/web/upgrade/ProtocolHandler.java
===================================================================
--- trunk/java/org/jboss/web/upgrade/ProtocolHandler.java 2012-03-14 17:31:01 UTC (rev 2002)
+++ trunk/java/org/jboss/web/upgrade/ProtocolHandler.java 2012-03-16 16:54:57 UTC (rev 2003)
@@ -22,13 +22,105 @@
package org.jboss.web.upgrade;
+/**
+ * Application can provide implementation of the ProtocolHandler interface to support
+ * protocol upgrades from HTTP/1.1. This allow access to the raw streams of the underlying
+ * connection, and full asynchronous IO for maximized scalability.
+ *
+ * @author remm
+ */
public interface ProtocolHandler {
+
+ /**
+ * Init will be called at the beginning of the processing of the upgraded connection.
+ * It can be used to initialize any relevant components that will be used for processing.
+ * Between the end of the processing of this event, and the beginning of the processing
+ * of the end or error events, it is possible to use the WebConnection object instance
+ * to write data on the open connection. Note that the WebConnection object instance
+ * methods are not synchronized, so when they are accessed by multiple threads adequate
+ * synchronization is needed. The WebConnection object will remain associated to the
+ * same connection for its entire lifecycle until it is destroyed.
+ *
+ * @param wc The WebConnection object that will be associated with this connection
+ */
public void init(WebConnection wc);
+
+ /**
+ * Destroy may be called to end the processing of the request. Components that have
+ * been initialized in the init method should be reset. After this event has
+ * been processed, the WebConnection object will be recycled and used to process
+ * other connections. In particular, this method will be called when the connection
+ * is closed asynchronously.
+ *
+ * @param wc The WebConnection object that is associated with this connection
+ */
public void destroy(WebConnection wc);
+
+ /**
+ * This indicates that input data is available, and that at least one
+ * read can be made without blocking using the given WebConnection object.
+ * The isReadReady method of the WebConnection may be used to determine
+ * if there is a risk of blocking: the Servlet must continue reading while
+ * data is reported available. When encountering a read error,
+ * the Servlet should report it by propagating the exception properly. Throwing
+ * an exception will cause the error method to be invoked, and the connection
+ * will be closed.
+ * Alternately, it is also possible to catch any exception, perform clean up
+ * on any data structure the Servlet may be using, and using the close method.
+ * It is not allowed to attempt reading data from the request
+ * object outside of the processing of this event, unless the suspend() method
+ * has been used.
+ *
+ * @param wc The WebConnection object that is associated with this connection
+ */
public void inputAvailable(WebConnection wc);
+
+ /**
+ * Write is called if the Servlet is using the isWriteReady method of the WebConnection.
+ * This means that the connection is ready to receive data to be written out. This method
+ * will never be called if the Servlet is not using the isWriteReady() method, or if the
+ * isWriteReady() method always returns true.
+ *
+ * @param wc The WebConnection object that is associated with this connection
+ */
public void outputReady(WebConnection wc);
+
+ /**
+ * Resume will be called by the container after the resume() method of the WebConnection
+ * is called, during which any operations can be performed, including closing the connection
+ * using the close() method.
+ *
+ * @param wc The WebConnection object that is associated with this connection
+ */
public void resume(WebConnection wc);
+
+ /**
+ * The connection timed out, but the connection will not be closed unless
+ * the Servlet uses the close method of the WebConnection.
+ *
+ * @param wc The WebConnection object that is associated with this connection
+ */
public void timeout(WebConnection wc);
+
+ /**
+ * Error will be called by the container in the case where an IO exception
+ * or a similar unrecoverable error occurs on the connection. Components that have
+ * been initialized in the init method should be reset. After this method has
+ * been called, the WebConnection object will be recycled and used to process
+ * other requests.
+ *
+ * @param wc The WebConnection object that is associated with this connection
+ */
public void error(WebConnection wc);
+
+ /**
+ * The end of file of the input has been reached, and no further data is
+ * available. This event is sent because it can be difficult to detect otherwise.
+ * Following the processing of this method and the processing of any subsequent
+ * method, the connection will be suspended.
+ *
+ * @param wc The WebConnection object that is associated with this connection
+ */
public void eof(WebConnection wc);
+
}
Modified: trunk/java/org/jboss/web/upgrade/WebConnection.java
===================================================================
--- trunk/java/org/jboss/web/upgrade/WebConnection.java 2012-03-14 17:31:01 UTC (rev 2002)
+++ trunk/java/org/jboss/web/upgrade/WebConnection.java 2012-03-16 16:54:57 UTC (rev 2003)
@@ -24,14 +24,89 @@
import java.io.IOException;
+/**
+ * The WebConnection object is provided by the web container and is used to allow
+ * access to the raw streams of the socket following an upgrade from HTTP/1.1.
+ *
+ * @author remm
+ */
public interface WebConnection {
+
+ /**
+ * Returns true when data may be read from the connection (the flag becomes false if no data
+ * is available to read). When the flag becomes false, the Servlet can attempt to read additional
+ * data, but it will block until data is available. If calling this method returns false, it will also
+ * request notification when the connection has data available for reading again, and the
+ * Servlet will be called back using the inputAvailable method of the ProtocolHandler.
+ *
+ * @return boolean true if data can be read without blocking
+ */
public boolean isReadReady();
+
+ /**
+ * Returns true when data may be written to the connection (the flag becomes false
+ * when the client is unable to accept data fast enough). When the flag becomes false,
+ * the Servlet must stop writing data. If there's an attempt to flush additional data
+ * to the client and data still cannot be written immediately, an IOException will be
+ * thrown. If calling this method returns false, it will also
+ * request notification when the connection becomes available for writing again, and the
+ * Servlet will be called back using the outputReady method of the ProtocolHandler.
+ * <br>
+ * Note: If the Servlet is not using isWriteReady, and is writing its output inside the
+ * container threads (inside the ProtocolHandler.resume() method processing, for example),
+ * using this method is not mandatory, and writes will block until all bytes are written.
+ *
+ * @return boolean true if data can be written without blocking
+ */
public boolean isWriteReady();
+
+ /**
+ * This method sets the timeout in milliseconds of idle time on the connection.
+ * The timeout is reset every time data is received from the connection. If a timeout occurs, the
+ * Servlet will be called back using the ProtocolHandler.timeout method which will not result in
+ * automatically closing the connection (the connection may be closed using the close() method).
+ *
+ * @param timeout The timeout in milliseconds for this connection, must be a positive value, larger than 0
+ */
public void setTimeout(int timeout);
+
+ /**
+ * Suspend processing of the connection until the configured timeout occurs,
+ * or resume() is called. In practice, this means the servlet will no longer
+ * receive read method callbacks. Reading should always be performed synchronously in
+ * the web container threads unless the connection has been suspended.
+ */
public void suspend();
- public void close() throws IOException;
+
+ /**
+ * Resume will cause the Servlet container to use the ProtocolHandler.resume()
+ * method to call back the Servlet, where the request can be processed synchronously
+ * (for example, it is possible to use this to complete the request after
+ * some asynchronous processing is done). This also resumes read events
+ * if they have been disabled using suspend. It is then possible to call suspend
+ * again later. It is also possible to call resume without calling suspend before.
+ * This method must be called asynchronously.
+ */
+ public void resume();
+
+ /**
+ * Close the connection. This will send back to the client a notice that the server
+ * has no more data to send as part of this request. The ProtocolHandler.close method will
+ * also be called by the container. This method will actually never perform any operation
+ * synchronously, it will merely mark the connection for closing.
+ */
+ public void close();
+
+ /**
+ * Read data in the given byte array.
+ */
public int read(byte[] b, int off, int len)
throws IOException;
+
+ /**
+ * Write the given bytes.
+ */
public void write(byte[] b, int off, int len)
throws IOException;
+
}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2012-03-14 17:31:01 UTC (rev 2002)
+++ trunk/webapps/docs/changelog.xml 2012-03-16 16:54:57 UTC (rev 2003)
@@ -25,6 +25,9 @@
<fix>
<jira>234</jira>: Fix parameters encoding processing issue introduced when rebasing. (remm)
</fix>
+ <add>
+ Protocol upgrade API. (remm)
+ </add>
</changelog>
</subsection>
<subsection name="Jasper">
12 years, 9 months