Author: remy.maucherat(a)jboss.com
Date: 2008-03-12 10:29:56 -0400 (Wed, 12 Mar 2008)
New Revision: 493
Added:
trunk/test/org/apache/jboss/web/comet/CometServletTest1.java
Removed:
trunk/test/org/apache/jboss/web/comet/CometServlet.java
Log:
- Fix oops (bad class name).
Deleted: trunk/test/org/apache/jboss/web/comet/CometServlet.java
===================================================================
--- trunk/test/org/apache/jboss/web/comet/CometServlet.java 2008-03-11 12:24:32 UTC (rev
492)
+++ trunk/test/org/apache/jboss/web/comet/CometServlet.java 2008-03-12 14:29:56 UTC (rev
493)
@@ -1,95 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.comet;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.servlet.ServletException;
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServlet;
-
-import org.jboss.web.comet.CometEvent;
-import org.jboss.web.comet.CometProcessor;
-
-public class CometServletTest1 extends HttpServlet implements CometProcessor {
-
- int count = 0;
-
- public void event(CometEvent event) throws IOException, ServletException {
- System.out.println("[" +
event.getHttpServletRequest().getSession(true).getId() + "] " +
event.getType());
- switch (event.getType()) {
- case BEGIN:
- //event.suspend();
- 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.ready()) {
- 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;
- }
- }
-
-}
Copied: trunk/test/org/apache/jboss/web/comet/CometServletTest1.java (from rev 492,
trunk/test/org/apache/jboss/web/comet/CometServlet.java)
===================================================================
--- trunk/test/org/apache/jboss/web/comet/CometServletTest1.java
(rev 0)
+++ trunk/test/org/apache/jboss/web/comet/CometServletTest1.java 2008-03-12 14:29:56 UTC
(rev 493)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.comet;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+
+import org.jboss.web.comet.CometEvent;
+import org.jboss.web.comet.CometProcessor;
+
+public class CometServletTest1 extends HttpServlet implements CometProcessor {
+
+ int count = 0;
+
+ public void event(CometEvent event) throws IOException, ServletException {
+ System.out.println("[" +
event.getHttpServletRequest().getSession(true).getId() + "] " +
event.getType());
+ switch (event.getType()) {
+ case BEGIN:
+ //event.suspend();
+ 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.ready()) {
+ 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;
+ }
+ }
+
+}