Author: remy.maucherat(a)jboss.com
Date: 2008-10-29 11:16:52 -0400 (Wed, 29 Oct 2008)
New Revision: 825
Modified:
trunk/build.xml
trunk/java/org/apache/tomcat/bayeux/TomcatBayeux.java
trunk/test/java/org/apache/jboss/web/comet/CometServletTest1.java
trunk/test/java/org/apache/jboss/web/comet/CometServletTest2.java
trunk/test/webapps/cometd/WEB-INF/web.xml
Log:
- Add some stuff to the Comet test.
- Make UUID identical to Tomcat (but & paste made it use another class, although it
should not make any difference).
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-10-28 21:56:15 UTC (rev 824)
+++ trunk/build.xml 2008-10-29 15:16:52 UTC (rev 825)
@@ -835,7 +835,6 @@
source="${compile.source}"
optimize="${compile.optimize}"
classpath="${tomcat.classes}">
- <include name="org/apache/cometd/**" />
</javac>
</target>
Modified: trunk/java/org/apache/tomcat/bayeux/TomcatBayeux.java
===================================================================
--- trunk/java/org/apache/tomcat/bayeux/TomcatBayeux.java 2008-10-28 21:56:15 UTC (rev
824)
+++ trunk/java/org/apache/tomcat/bayeux/TomcatBayeux.java 2008-10-29 15:16:52 UTC (rev
825)
@@ -16,7 +16,6 @@
*/
package org.apache.tomcat.bayeux;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -147,9 +146,25 @@
public String createUUID(String idprefix) {
if (idprefix==null) idprefix="";
- return idprefix + Arrays.toString(UUIDGenerator.randomUUID(false));
+ return idprefix + TomcatBayeux.toString(UUIDGenerator.randomUUID(false));
}
+ protected static String toString(byte[] data) {
+ return toString(data,0,data!=null?data.length:0);
+ }
+
+ protected static String toString(byte[] data, int offset, int length) {
+ StringBuffer buf = new StringBuffer("{");
+ if ( data != null && length > 0 ) {
+ buf.append(data[offset++]);
+ for (int i = offset; i < length; i++) {
+ buf.append(", ").append(data[i]);
+ }
+ }
+ buf.append("}");
+ return buf.toString();
+ }
+
public List<Channel> getChannels() {
return java.util.Arrays.asList(channels.entrySet().toArray(new Channel[0]));
}
Modified: trunk/test/java/org/apache/jboss/web/comet/CometServletTest1.java
===================================================================
--- trunk/test/java/org/apache/jboss/web/comet/CometServletTest1.java 2008-10-28 21:56:15
UTC (rev 824)
+++ trunk/test/java/org/apache/jboss/web/comet/CometServletTest1.java 2008-10-29 15:16:52
UTC (rev 825)
@@ -31,14 +31,14 @@
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
-import org.jboss.web.comet.CometEvent;
-import org.jboss.web.comet.CometProcessor;
+import org.jboss.servlet.http.HttpEvent;
+import org.jboss.servlet.http.HttpEventServlet;
-public class CometServletTest1 extends HttpServlet implements CometProcessor {
+public class CometServletTest1 extends HttpServlet implements HttpEventServlet {
int count = 0;
- public void event(CometEvent event) throws IOException, ServletException {
+ public void event(HttpEvent event) throws IOException, ServletException {
System.out.println("[" +
event.getHttpServletRequest().getSession(true).getId() + "] " +
event.getType());
switch (event.getType()) {
case BEGIN:
@@ -55,7 +55,7 @@
// will cause the write to be performed in blocking mode.
// boolean b = true;
// while (b) {
- while (event.ready()) {
+ while (event.isWriteReady()) {
if (count % 100 == 0) {
os.println((count++) + " ");
} else {
Modified: trunk/test/java/org/apache/jboss/web/comet/CometServletTest2.java
===================================================================
--- trunk/test/java/org/apache/jboss/web/comet/CometServletTest2.java 2008-10-28 21:56:15
UTC (rev 824)
+++ trunk/test/java/org/apache/jboss/web/comet/CometServletTest2.java 2008-10-29 15:16:52
UTC (rev 825)
@@ -29,12 +29,14 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
+import org.jboss.servlet.http.HttpEvent;
+import org.jboss.servlet.http.HttpEventServlet;
-public class CometServletTest2 extends HttpServlet implements CometProcessor {
+public class CometServletTest2 extends HttpServlet implements HttpEventServlet {
int count = 0;
- public void event(CometEvent event) throws IOException, ServletException {
+ public void event(HttpEvent event) throws IOException, ServletException {
System.out.println("[" +
event.getHttpServletRequest().getSession(true).getId() + "] " +
event.getType());
switch (event.getType()) {
case BEGIN:
@@ -51,7 +53,7 @@
// will cause the write to be performed in blocking mode.
// boolean b = true;
// while (b) {
- while (event.ready()) {
+ while (event.isWriteReady()) {
if (count % 100 == 0) {
writer.write((count++) + " \r\n");
} else {
Modified: trunk/test/webapps/cometd/WEB-INF/web.xml
===================================================================
--- trunk/test/webapps/cometd/WEB-INF/web.xml 2008-10-28 21:56:15 UTC (rev 824)
+++ trunk/test/webapps/cometd/WEB-INF/web.xml 2008-10-29 15:16:52 UTC (rev 825)
@@ -19,11 +19,19 @@
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
+ <servlet>
+ <servlet-name>comettest</servlet-name>
+ <servlet-class>org.jboss.web.comet.CometServletTest1</servlet-class>
+ </servlet>
<servlet-mapping>
<servlet-name>cometd</servlet-name>
<url-pattern>/cometd/*</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>comettest</servlet-name>
+ <url-pattern>/test/*</url-pattern>
+ </servlet-mapping>
<listener>
<listener-class>org.apache.cometd.bayeux.samples.EchoChatClient</listener-class>
Show replies by date