You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/08/20 15:10:51 UTC

svn commit: r1515813 - in /tomcat/tc7.0.x/trunk: ./ java/javax/websocket/ java/org/apache/tomcat/websocket/ java/org/apache/tomcat/websocket/server/ modules/websocket/java/javax/websocket/ modules/websocket/java/org/apache/tomcat/websocket/ modules/web...

Author: markt
Date: Tue Aug 20 13:10:50 2013
New Revision: 1515813

URL: http://svn.apache.org/r1515813
Log:
Move the JSR-356 WebSocket API and implementation to the main code location.
Update the build to build the JSR-356 WebSocket implementation with Java 7.
Switch the WebSocket examples to use the JSR-356 implementation.
Remove any Java 7 language features (<>, multi-catch).

Added:
    tomcat/tc7.0.x/trunk/java/javax/websocket/
      - copied from r1515191, tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/
      - copied from r1515191, tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties
      - copied, changed from r1515192, tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/LocalStrings.properties
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/UriTemplate.java
      - copied unchanged from r1515192, tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/UriTemplate.java
    tomcat/tc7.0.x/trunk/res/META-INF/default/
      - copied from r1515189, tomcat/trunk/res/META-INF/default/
    tomcat/tc7.0.x/trunk/res/META-INF/tomcat7-websocket.jar/
      - copied from r1515189, tomcat/trunk/res/META-INF/tomcat-websocket.jar/
    tomcat/tc7.0.x/trunk/res/META-INF/websocket-api.jar.manifest
      - copied unchanged from r1515189, tomcat/trunk/res/META-INF/websocket-api.jar.manifest
    tomcat/tc7.0.x/trunk/res/maven/tomcat-websocket-api.pom
      - copied unchanged from r1515286, tomcat/trunk/res/maven/tomcat-websocket-api.pom
    tomcat/tc7.0.x/trunk/res/maven/tomcat-websocket.pom
      - copied, changed from r1515286, tomcat/trunk/res/maven/tomcat-websocket.pom
    tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/
      - copied from r1515191, tomcat/tc7.0.x/trunk/modules/websocket/test/org/apache/tomcat/websocket/
    tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/server/TestUriTemplate.java
      - copied unchanged from r1515192, tomcat/tc7.0.x/trunk/modules/websocket/test/org/apache/tomcat/websocket/server/TestUriTemplate.java
    tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/chat/
      - copied from r1515189, tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/chat/
    tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/echo/
      - copied from r1515189, tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/
    tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/
      - copied from r1515189, tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/snake/
    tomcat/tc7.0.x/trunk/webapps/examples/websocket/chat.html
      - copied unchanged from r1515189, tomcat/trunk/webapps/examples/websocket/chat.html
    tomcat/tc7.0.x/trunk/webapps/examples/websocket/echo.html
      - copied unchanged from r1515189, tomcat/trunk/webapps/examples/websocket/echo.html
    tomcat/tc7.0.x/trunk/webapps/examples/websocket/index.html
      - copied unchanged from r1515189, tomcat/trunk/webapps/examples/websocket/index.html
    tomcat/tc7.0.x/trunk/webapps/examples/websocket/snake.html
      - copied unchanged from r1515189, tomcat/trunk/webapps/examples/websocket/snake.html
Removed:
    tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/
    tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/
    tomcat/tc7.0.x/trunk/modules/websocket/test/org/apache/tomcat/websocket/
Modified:
    tomcat/tc7.0.x/trunk/BUILDING.txt
    tomcat/tc7.0.x/trunk/build.properties.default
    tomcat/tc7.0.x/trunk/build.xml
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/UpgradeUtil.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsSci.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java
    tomcat/tc7.0.x/trunk/res/checkstyle/javax-import-control.xml
    tomcat/tc7.0.x/trunk/res/checkstyle/org-import-control.xml
    tomcat/tc7.0.x/trunk/test/org/apache/catalina/websocket/TestWebSocket.java
    tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/parser/TestMediaType.java
    tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/TestUtil.java
    tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/pojo/TestEncodingDecoding.java
    tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/pojo/TestPojoEndpointBase.java
    tomcat/tc7.0.x/trunk/webapps/docs/web-socket-howto.xml
    tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/chat/ChatAnnotation.java
    tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/echo/WsConfigListener.java
    tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/Snake.java
    tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java
    tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/web.xml

Modified: tomcat/tc7.0.x/trunk/BUILDING.txt
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/BUILDING.txt?rev=1515813&r1=1515812&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/BUILDING.txt (original)
+++ tomcat/tc7.0.x/trunk/BUILDING.txt Tue Aug 20 13:10:50 2013
@@ -33,11 +33,11 @@ In order to build a binary distribution 
 source distribution, do the following:
 
 
-(1) Download and Install a Java Development Kit
+(1) Download and Install a Java 6 and Java 7 Development Kit
 
- 1. If the JDK is already installed, skip to (2).
+ 1. If the JDKs are already installed, skip to (2).
 
- 2. Download a version 6 of Java Development Kit (JDK) release (use the
+ 2. Download a version 6 of the Java Development Kit (JDK) release (use the
     latest update available for your chosen version) from
 
         http://www.oracle.com/technetwork/java/javase/downloads/index.html
@@ -45,7 +45,7 @@ source distribution, do the following:
 
     Note regarding later versions of Java:
 
-      As documented elsewhere, one of components in Apache Tomcat includes
+      As documented elsewhere, one of the components in Apache Tomcat includes
       a private copy of the Apache Commons DBCP library. The source code
       for this library is downloaded, processed by the build script
       (renaming the packages) and compiled.
@@ -53,7 +53,8 @@ source distribution, do the following:
       Due to changes in JDBC interfaces implemented by the library between
       versions of Java SE specification, the library has to target specific
       version of Java and can be compiled only with the JDK version
-      implementing this version of specification.
+      implementing this version of specification. Therefore, the build Tomcat
+      build process must be executed with a Java 6 JDK.
 
       See Apache Commons DBCP project web site for more details on
       available versions of the library and its requirements,
@@ -64,11 +65,24 @@ source distribution, do the following:
       several workarounds are possible. One of them is to skip building
       the component (tomcat-dbcp.jar).
 
- 3. Install the JDK according to the instructions included with the release.
+ 3. Install the Java 6 JDK according to the instructions included with the
+    release.
 
  4. Set an environment variable JAVA_HOME to the pathname of the directory
     into which you installed the JDK release.
 
+ 5. Download a version 7 of the Java Development Kit (JDK) release (use the
+    latest update available for your chosen version) from
+
+        http://www.oracle.com/technetwork/java/javase/downloads/index.html
+        or from another JDK vendor.
+
+ 6. Install the Java 7 JDK according to the instructions included with the
+    release.
+
+* NOTE: The Java 7 JDK is only required if you wish to build Tomcat with
+  JSR-356 (Java WebSocket 1.0) support.
+
 
 (2) Install Apache Ant 1.8.x on your computer
 
@@ -158,6 +172,10 @@ ${tomcat.source}.
 
   See Apache Ant documentation for the <setproxy> task for details.
 
+* NOTE: Users wishing to build Tomcat with JSR-356 (Java WebSocket 1.0) support
+  must also set the java.7.home build property to the location of the Java 7 JDK
+  installation.
+
  3. Go to the sources directory and run Ant:
 
         cd ${tomcat.source}

Modified: tomcat/tc7.0.x/trunk/build.properties.default
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/build.properties.default?rev=1515813&r1=1515812&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/build.properties.default (original)
+++ tomcat/tc7.0.x/trunk/build.properties.default Tue Aug 20 13:10:50 2013
@@ -46,6 +46,9 @@ test.accesslog=false
 # Workaround against http://bugs.sun.com/view_bug.do?bug_id=6202721
 test.jvmarg.egd=-Djava.security.egd=file:/dev/./urandom
 
+# Location of Java7 JDK
+#java.7.home=/path/to/java7/jdk
+
 # Location of GPG executable (used only for releases)
 gpg.exec=/path/to/gpg
 

Modified: tomcat/tc7.0.x/trunk/build.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/build.xml?rev=1515813&r1=1515812&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/build.xml (original)
+++ tomcat/tc7.0.x/trunk/build.xml Tue Aug 20 13:10:50 2013
@@ -47,6 +47,7 @@
   <property name="servlet.revision" value="FR" />
   <property name="jsp.revision" value="FR" />
   <property name="el.revision" value="FR" />
+  <property name="websocket.revision" value="FR" />
 
   <!-- Release artifact base names -->
   <property name="final.name"            value="${project}-${version}" />
@@ -148,8 +149,18 @@
   <!-- jdbc-pool JARs & source JARs -->
   <property name="tomcat-jdbc.jar" value="${tomcat.pool}/tomcat-jdbc.jar"/>
   <property name="tomcat-jdbc-src.jar" value="${tomcat.pool}/tomcat-jdbc-src.jar"/>
-  
-  
+
+  <!-- WebSocket 1.0 (JSR-356) API and implementation JARs & source JARS     -->
+  <!-- The API JAR is the same as the one that ships with Tomcat 8 except    -->
+  <!-- that it does not use Java 7 features (<> and multi-catch) and has     -->
+  <!-- been compiled for Java 6. The implementation JAR includes a number of -->
+  <!-- modifications to remove the dependencies on the Servlet 3.1 APIs.     -->
+  <!-- The implementation JAR will only work with Tomcat 7.                  -->
+  <property name="websocket-api.jar" value="${tomcat.build}/lib/websocket-api.jar"/>
+  <property name="tomcat7-websocket.jar" value="${tomcat.build}/lib/tomcat7-websocket.jar"/>
+  <property name="websocket-api-src.jar" value="${tomcat.src.jars}/websocket-api-src.jar"/>
+  <property name="tomcat7-websocket-src.jar" value="${tomcat.src.jars}/tomcat7-websocket-src.jar"/>
+
   <!-- Tests To Run -->
   <property name="test.name" value="**/Test*.java"/>
   <property name="test.formatter" value="-Dorg.apache.juli.formatter=java.util.logging.SimpleFormatter"/>
@@ -274,6 +285,14 @@
     <include name="javax/el/*" />
   </patternset>
 
+  <patternset id="files.websocket-api">
+    <include name="javax/websocket/**" />
+  </patternset>
+
+  <patternset id="files.tomcat7-websocket">
+    <include name="org/apache/tomcat/websocket/**" />
+  </patternset>
+
   <patternset id="files.bootstrap">
     <include name="org/apache/catalina/startup/Bootstrap.*" />
     <include name="org/apache/catalina/startup/catalina.properties" />
@@ -358,6 +377,8 @@
     <patternset refid="files.catalina" />
     <patternset refid="files.el-api" />
     <patternset refid="files.servlet-api" />
+    <patternset refid="files.websocket-api" />
+    <patternset refid="files.tomcat7-websocket" />
     <patternset refid="files.tomcat-api" />
     <!-- These pattern sets conflict so include files directly
       <patternset refid="files.tomcat-coyote" />
@@ -551,7 +572,8 @@
     </copy>
   </target>
 
-  <target name="compile" depends="build-prepare,download-compile,compile-prepare,validate">
+  <target name="compile"
+          depends="build-prepare,download-compile,compile-prepare,validate,compile-java7">
     <!-- Compile internal server components -->
     <javac srcdir="java" destdir="${tomcat.classes}"
            debug="${compile.debug}"
@@ -565,6 +587,8 @@
       <compilerarg value="-Xlint:unchecked"/>
       <classpath refid="compile.classpath" />
       <exclude name="org/apache/naming/factory/webservices/**" />
+      <!-- Exclude classes that require Java 7 to compile -->
+      <exclude name="org/apache/tomcat/websocket/**" />
     </javac>
     <!-- Copy static resource files -->
     <copy todir="${tomcat.classes}" encoding="ISO-8859-1">
@@ -579,7 +603,33 @@
     </copy>
 
   </target>
-  
+
+  <target name="compile-java7"
+          depends="build-prepare,download-compile,compile-prepare,validate"
+          if="java.7.home" >
+    <javac srcdir="java" destdir="${tomcat.classes}"
+           debug="${compile.debug}"
+           deprecation="${compile.deprecation}"
+           source="${compile.source}"
+           target="${compile.target}"
+           optimize="${compile.optimize}"
+           excludes="**/.svn/**"
+           encoding="ISO-8859-1"
+           includeAntRuntime="true"
+           fork="true"
+           executable="${java.7.home}/bin/javac">
+      <compilerarg value="-Xlint:unchecked"/>
+      <classpath refid="compile.classpath" />
+      <!-- Only include classes that require Java 7 to compile -->
+      <include name="org/apache/tomcat/websocket/**" />
+      <!-- Not required but prevents a warning being displayed -->
+      <bootclasspath>
+        <fileset dir="${java.7.home}/jre/lib">
+          <include name="*.jar"/>
+        </fileset>
+      </bootclasspath>
+    </javac>
+  </target>
   
 
   <target name="build-manifests" unless="manifests.uptodate"
@@ -590,21 +640,18 @@
     <filter token="servlet.revision" value="${servlet.revision}"/>
     <filter token="jsp.revision" value="${jsp.revision}"/>
     <filter token="el.revision" value="${el.revision}"/>
+    <filter token="websocket.revision" value="${websocket.revision}"/>
 
     <mkdir dir="${tomcat.manifests}" />
     <copy todir="${tomcat.manifests}" overwrite="yes" filtering="yes"
       encoding="ISO-8859-1">
       <filterset refid="version.filters"/>
-      <fileset dir="${tomcat.home}/res/META-INF" >
-        <include name="*.manifest" />
-        <include name="*.license" />
-        <include name="*.notice" />
-      </fileset>
+      <fileset dir="${tomcat.home}/res/META-INF" />
     </copy>
 
   </target>
 
-  <target name="package" depends="compile,build-manifests" >
+  <target name="package" depends="compile,build-manifests,package-java7" >
     <!-- Common Annotations 1.0 JAR File -->
     <jarIt jarfile="${annotations-api.jar}"
       filesDir="${tomcat.classes}"
@@ -723,6 +770,21 @@
 
   </target>
 
+  <target name="package-java7" depends="compile,build-manifests"
+          if="java.7.home">
+    <!-- WebSocket 1.0 API JAR File -->
+    <jarIt jarfile="${websocket-api.jar}"
+      filesDir="${tomcat.classes}"
+      filesId="files.websocket-api"
+      manifest="${tomcat.manifests}/websocket-api.jar.manifest" />
+
+    <!-- WebSocket 1.0 implementation JAR File -->
+    <jarIt jarfile="${tomcat7-websocket.jar}"
+      filesDir="${tomcat.classes}"
+      filesId="files.tomcat7-websocket"
+      meta-inf="${tomcat.manifests}/tomcat7-websocket.jar"/>
+  </target>
+
   <target name="build-docs" depends="compile-prepare" description="Builds all documentation from XML sources">
 
     <copy todir="${tomcat.build}/webapps">
@@ -1057,9 +1119,13 @@
       failonerror="false"/>
     <copy file="${jdt.jar}" todir="${tomcat.embed}" />
 
+    <!-- Note the meta-inf below will work as long as there is only one JAR
+         that needs to add entries. If there is more than one a more complex
+         solution will be required. -->
     <jarIt jarfile="${tomcat-embed-core.jar}"
            filesDir="${tomcat.classes}"
-           filesId="files.tomcat-embed-core"/>
+           filesId="files.tomcat-embed-core"
+           meta-inf="${tomcat.manifests}/tomcat7-websocket.jar"/>
     <jarIt jarfile="${tomcat-embed-jasper.jar}"
            filesDir="${tomcat.classes}"
            filesId="files.tomcat-embed-jasper"/>
@@ -1145,6 +1211,8 @@
       <classpath refid="tomcat.test.classpath" />
       <include name="org/apache/**" />
       <include name="javax/**" />
+      <exclude unless="java.7.home" name="org/apache/catalina/websocket/**" />
+      <exclude unless="java.7.home" name="org/apache/tomcat/websocket/**" />
     </javac>
     <!-- Copy static resource files the tests need to load via the class     -->
     <!-- loader.                                                             -->
@@ -1163,7 +1231,7 @@
   <property name="junit.formatter.extension" value=".txt" />
 
   <target name="test" description="Runs the JUnit test cases"
-          depends="test-bio,test-nio,test-apr" >
+          depends="test-init1,test-init2,test-bio,test-nio,test-apr" >
     <fail if="test.result.error" message='Some tests completed with an Error. See ${tomcat.build}/logs for details, search for "FAILED".' />
     <fail if="test.result.failure" message='Some tests completed with a Failure. See ${tomcat.build}/logs for details, search for "FAILED".' />
   </target>
@@ -1192,6 +1260,14 @@
     <available file="${test.apr.loc}" property="apr.exists" />
   </target>
 
+  <target name="test-init1" if="java.7.home">
+    <property name="java.bin.path" value="${java.7.home}/bin/"/>
+  </target>
+
+  <target name="test-init2" unless="java.7.home">
+    <property name="java.bin.path" value=""/>
+  </target>
+
   <macrodef name="runtests"
             description="Runs the unit tests using the specified connector.
               Does not stop on errors, but sets 'test.result.error' and 'test.result.failure' properties.">
@@ -1204,7 +1280,8 @@
       <junit printsummary="yes" fork="yes" dir="." showoutput="yes"
         errorproperty="test.result.error"
         failureproperty="test.result.failure"
-        haltonfailure="${test.haltonfailure}" >
+        haltonfailure="${test.haltonfailure}"
+        jvm="${java.bin.path}java" >
 
         <jvmarg value="${test.jvmarg.egd}"/>
         <jvmarg value="-Djava.library.path=${test.apr.loc}"/>
@@ -1232,6 +1309,11 @@
             <exclude name="**/Tester*.java" />
             <!-- Exclude the tests known to fail -->
             <exclude name="org/apache/catalina/tribes/test/**" />
+            <!-- Exclude both sets of WebSocket tests unless Java 7 is       -->
+            <!-- present as the WebSocket exmaples (used by the tests) won't -->
+            <!-- build without it.                                           -->
+            <exclude unless="java.7.home" name="org/apache/catalina/websocket/**" />
+            <exclude unless="java.7.home" name="org/apache/tomcat/websocket/**" />
           </fileset>
         </batchtest>
       </junit>
@@ -1656,6 +1738,25 @@ Apache Tomcat ${version} native binaries
     </javadoc>
     <patch-javadoc dir="${tomcat.dist}/webapps/docs/elapi"
       docencoding="ISO-8859-1"/>
+    <javadoc packagenames="javax.websocket.*"
+      sourcepath="${tomcat.dist}/src/java"
+      destdir="${tomcat.dist}/webapps/docs/websocketapi"
+      version="true"
+      windowtitle="WebSocket 1.0 API Documentation - Apache Tomcat ${version}"
+      doctitle="WebSocket 1.0 API - Apache Tomcat ${version}"
+      header="&lt;b&gt;WebSocket 1.0 - Apache Tomcat ${version}&lt;/b&gt;"
+      bottom="Copyright &amp;#169; 2000-${year} Apache Software Foundation. All Rights Reserved."
+      encoding="ISO-8859-1"
+      additionalparam="-breakiterator"
+      maxmemory="256m" >
+      <classpath>
+        <path refid="compile.classpath"/>
+        <path refid="tomcat.webservices.classpath"/>
+        <path location="${ant.core.lib}"/>
+      </classpath>
+    </javadoc>
+    <patch-javadoc dir="${tomcat.dist}/webapps/docs/websocketapi"
+      docencoding="ISO-8859-1"/>
     <javadoc packagenames="org.apache.*"
       destdir="${tomcat.dist}/webapps/docs/api"
       version="true"
@@ -1674,7 +1775,8 @@ Apache Tomcat ${version} native binaries
       <link href="../servletapi"/>
       <link href="../jspapi"/>
       <link href="../elapi"/>
-      <link href="http://docs.oracle.com/javase/6/docs/api/"/>
+      <link href="../websocketapi"/>
+      <link href="http://docs.oracle.com/javase/7/docs/api/"/>
       <link href="http://commons.apache.org/proper/commons-io/javadocs/api-release/"/>
       <link href="http://docs.oracle.com/javaee/6/api/"/>
       <sourcepath>
@@ -1767,6 +1869,8 @@ Apache Tomcat ${version} native binaries
         <include name="jasper.jar"/>
         <include name="jasper-el.jar"/>
         <include name="servlet-api.jar"/>
+        <include name="websocket-api.jar"/>
+        <include name="tomcat7-websocket.jar"/>
         <include name="tomcat-coyote.jar"/>
         <include name="tomcat-util.jar"/>
       </fileset>
@@ -1938,7 +2042,10 @@ Apache Tomcat ${version} native binaries
   </target>
 
   <!-- Sets properties only required for releases -->
-  <target name="release-init" depends="gpg-init-1,gpg-init-2" />
+  <target name="release-init" depends="gpg-init-1,gpg-init-2" >
+    <fail unless="java.7.home"
+          message="The java.7.home property must be set for a release build"/>
+  </target>
 
   <target name="gpg-init-1">
     <available file="${gpg.exec}" property="gpg.exec.available"/>
@@ -2265,7 +2372,7 @@ Apache Tomcat ${version} native binaries
 
   <!-- Packages the source code in JARs to match the binary JARs -->
   <target name="package-src-jar"
-          depends="build-manifests,build-tomcat-jdbc-src">
+          depends="build-manifests,build-tomcat-jdbc-src,package-src-jar-java7">
 
     <mkdir dir="${tomcat.src.jars}" />
 
@@ -2361,6 +2468,23 @@ Apache Tomcat ${version} native binaries
     <copy file="${tomcat-jdbc-src.jar}" todir="${tomcat.src.jars}" />
   </target>
 
+  <target name="package-src-jar-java7"
+          depends="build-manifests,build-tomcat-jdbc-src"
+          if="java.7.home">
+
+    <!-- WebSocket 1.0 API JAR File -->
+    <jarIt jarfile="${websocket-api-src.jar}"
+      filesDir="java"
+      filesId="files.websocket-api"
+      manifest="${tomcat.manifests}/websocket-api.jar.manifest" />
+
+    <!-- WebSocket 1.0 implementation JAR File -->
+    <jarIt jarfile="${tomcat-websocket-src.jar}"
+      filesDir="java"
+      filesId="files.tomcat-websocket" />
+  </target>
+
+
   <!-- ========================= Cleaning Targets ========================== -->
 
   <target name="clean-depend"
@@ -2685,6 +2809,8 @@ Read the Building page on the Apache Tom
                default="${tomcat.manifests}/default.notice" />
     <attribute name="license" description="the NOTICE file to use"
                default="${tomcat.manifests}/default.license" />
+    <attribute name="meta-inf" description="additional contents for META-INF"
+               default="${tomcat.manifests}/default" />
     <sequential>
       <jar jarfile="@{jarfile}" manifest="@{manifest}">
         <fileset dir="@{filesDir}">
@@ -2693,6 +2819,8 @@ Read the Building page on the Apache Tom
           <exclude name="**/package.html" />
           <exclude name="**/LocalStrings_*" />
         </fileset>
+        <zipfileset dir="@{meta-inf}" prefix="META-INF/"
+                    excludes=".gitignore" />
         <zipfileset file="@{notice}" fullpath="META-INF/NOTICE" />
         <zipfileset file="@{license}" fullpath="META-INF/LICENSE" />
       </jar>

Copied: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties (from r1515192, tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/LocalStrings.properties)
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties?p2=tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties&p1=tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/LocalStrings.properties&r1=1515192&r2=1515813&rev=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/LocalStrings.properties (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties Tue Aug 20 13:10:50 2013
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-sci.newInstance.fail=Failed to create an Endpoint instance of type [{0}]
+sci.noWebSocketSupport=WebSocket support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocketJARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties
 
 serverContainer.addNotAllowed=No further Endpoints may be registered once an attempt has been made to use one of the previously registered endpoints
 serverContainer.configuratorFail=Failed to create configurator of type [{0}] for POJO of type [{1}]

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/UpgradeUtil.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/UpgradeUtil.java?rev=1515813&r1=1515191&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/UpgradeUtil.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/UpgradeUtil.java Tue Aug 20 13:10:50 2013
@@ -32,6 +32,7 @@ import java.util.concurrent.ConcurrentLi
 
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestWrapper;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -172,12 +173,20 @@ public class UpgradeUtil {
             }
         }
 
-        // TODO: Check if the request is wrapped and unwrap it if necessary.
-        WsHttpUpgradeHandler wsHandler =
-                ((RequestFacade) req).upgrade(WsHttpUpgradeHandler.class);
-        wsHandler.preInit(ep, sec, sc, wsRequest, subProtocol,
-                pathParams, req.isSecure());
-
+        // Small hack until the Servlet API provides a way to do this.
+        ServletRequest inner = req;
+        // Unwrap the request
+        while (inner instanceof ServletRequestWrapper) {
+            inner = ((ServletRequestWrapper) inner).getRequest();
+        }
+        if (inner instanceof RequestFacade) {
+            WsHttpUpgradeHandler wsHandler =
+                    ((RequestFacade) req).upgrade(WsHttpUpgradeHandler.class);
+            wsHandler.preInit(ep, sec, sc, wsRequest, subProtocol,
+                    pathParams, req.isSecure());
+        } else {
+            throw new ServletException("Upgrade failed");
+        }
     }
 
 

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java?rev=1515813&r1=1515191&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java Tue Aug 20 13:10:50 2013
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 
-import javax.servlet.ServletOutputStream;
 import javax.websocket.SendHandler;
 import javax.websocket.SendResult;
 
@@ -34,7 +33,7 @@ import org.apache.tomcat.websocket.WsRem
 /**
  * This is the server side {@link javax.websocket.RemoteEndpoint} implementation
  * - i.e. what the server uses to send data to the client. Communication is over
- * a {@link ServletOutputStream}.
+ * a {@link javax.servlet.ServletOutputStream}.
  */
 public class WsRemoteEndpointImplServer extends WsRemoteEndpointImplBase {
 

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsSci.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsSci.java?rev=1515813&r1=1515191&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsSci.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsSci.java Tue Aug 20 13:10:50 2013
@@ -31,6 +31,10 @@ import javax.websocket.server.ServerAppl
 import javax.websocket.server.ServerEndpoint;
 import javax.websocket.server.ServerEndpointConfig;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
 /**
  * Registers an interest in any class that is annotated with
  * {@link ServerEndpoint} so that Endpoint can be published via the WebSocket
@@ -40,10 +44,27 @@ import javax.websocket.server.ServerEndp
         Endpoint.class})
 public class WsSci implements ServletContainerInitializer {
 
+    private static boolean logMessageWritten = false;
+
+    private static final Log log =
+            LogFactory.getLog(WsSci.class);
+    private static final StringManager sm =
+            StringManager.getManager(Constants.PACKAGE_NAME);
+
     @Override
     public void onStartup(Set<Class<?>> clazzes, ServletContext ctx)
             throws ServletException {
 
+        if (!isJava7OrLater()) {
+            // The WebSocket implementation requires Java 7 so don't initialise
+            // it if Java 7 is not available.
+            if (!logMessageWritten) {
+                logMessageWritten = true;
+                log.info(sm.getString("sci.noWebSocketSupport"));
+            }
+            return;
+        }
+
         WsServerContainer sc = init(ctx);
 
         if (clazzes == null || clazzes.size() == 0) {
@@ -138,4 +159,14 @@ public class WsSci implements ServletCon
 
         return sc;
     }
+
+
+    private static boolean isJava7OrLater() {
+        try {
+            Class.forName("java.nio.channels.AsynchronousSocketChannel");
+        } catch (ClassNotFoundException e) {
+            return false;
+        }
+        return true;
+    }
 }

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java?rev=1515813&r1=1515191&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java Tue Aug 20 13:10:50 2013
@@ -323,7 +323,8 @@ public class WsServerContainer extends W
     @Override
     protected void registerSession(Endpoint endpoint, WsSession wsSession) {
         super.registerSession(endpoint, wsSession);
-        if (wsSession.getUserPrincipal() != null &&
+        if (wsSession.isOpen() &&
+                wsSession.getUserPrincipal() != null &&
                 wsSession.getHttpSessionId() != null) {
             registerAuthenticatedSession(wsSession,
                     wsSession.getHttpSessionId());

Modified: tomcat/tc7.0.x/trunk/res/checkstyle/javax-import-control.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/res/checkstyle/javax-import-control.xml?rev=1515813&r1=1515812&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/res/checkstyle/javax-import-control.xml (original)
+++ tomcat/tc7.0.x/trunk/res/checkstyle/javax-import-control.xml Tue Aug 20 13:10:50 2013
@@ -44,6 +44,9 @@
       <allow pkg="javax.servlet.jsp"/>
     </subpackage>
   </subpackage>
+  <subpackage name="websocket">
+    <allow pkg="javax.websocket"/>
+  </subpackage>
   <subpackage name="xml.ws">
     <allow pkg="javax.xwl.ws"/>
   </subpackage>

Modified: tomcat/tc7.0.x/trunk/res/checkstyle/org-import-control.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/res/checkstyle/org-import-control.xml?rev=1515813&r1=1515812&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/res/checkstyle/org-import-control.xml (original)
+++ tomcat/tc7.0.x/trunk/res/checkstyle/org-import-control.xml Tue Aug 20 13:10:50 2013
@@ -128,5 +128,24 @@
         <allow pkg="org.apache.tomcat" exact-match="true"/>
       </subpackage>
     </subpackage>
+    <subpackage name="websocket">
+      <allow pkg="javax.websocket"/>
+      <!-- Require to access HTTP Upgrade API -->
+      <allow pkg="org.apache.catalina.connector"/>
+      <!-- The Servlet 3.1 API replacement classes are in this package -->
+      <allow pkg="org.apache.coyote.http11.upgrade"/>
+      <allow pkg="org.apache.juli"/>
+      <allow pkg="org.apache.tomcat.util"/>
+      <!-- Ideally want to remove this -->
+      <allow pkg="org.apache.tomcat.websocket.pojo"/>
+      <disallow pkg="javax.servlet"/>
+      <subpackage name="pojo">
+        <allow pkg="org.apache.tomcat.websocket"/>
+      </subpackage>
+      <subpackage name="server">
+        <allow pkg="javax.servlet"/>
+        <allow pkg="org.apache.tomcat.websocket"/>
+      </subpackage>
+    </subpackage>
   </subpackage>
 </import-control>
\ No newline at end of file

Copied: tomcat/tc7.0.x/trunk/res/maven/tomcat-websocket.pom (from r1515286, tomcat/trunk/res/maven/tomcat-websocket.pom)
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/res/maven/tomcat-websocket.pom?p2=tomcat/tc7.0.x/trunk/res/maven/tomcat-websocket.pom&p1=tomcat/trunk/res/maven/tomcat-websocket.pom&r1=1515286&r2=1515813&rev=1515813&view=diff
==============================================================================
--- tomcat/trunk/res/maven/tomcat-websocket.pom (original)
+++ tomcat/tc7.0.x/trunk/res/maven/tomcat-websocket.pom Tue Aug 20 13:10:50 2013
@@ -18,7 +18,7 @@
 <project>
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.tomcat</groupId>
-  <artifactId>tomcat-websocket</artifactId>
+  <artifactId>tomcat7-websocket</artifactId>
   <version>@MAVEN.DEPLOY.VERSION@</version>
   <description>Tomcat WebSocket (JSR356) implementation</description>
   <url>http://tomcat.apache.org/</url>
@@ -38,6 +38,18 @@
     </dependency>
     <dependency>
       <groupId>org.apache.tomcat</groupId>
+      <artifactId>tomcat-catalina</artifactId>
+      <version>@MAVEN.DEPLOY.VERSION@</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>tomcat-coyote</artifactId>
+      <version>@MAVEN.DEPLOY.VERSION@</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
       <artifactId>tomcat-juli</artifactId>
       <version>@MAVEN.DEPLOY.VERSION@</version>
       <scope>compile</scope>

Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/websocket/TestWebSocket.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/websocket/TestWebSocket.java?rev=1515813&r1=1515812&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/websocket/TestWebSocket.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/websocket/TestWebSocket.java Tue Aug 20 13:10:50 2013
@@ -17,7 +17,6 @@
 package org.apache.catalina.websocket;
 
 import java.io.BufferedReader;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -45,7 +44,9 @@ import static org.junit.Assert.assertTru
 import org.junit.Test;
 
 import org.apache.catalina.Context;
+import org.apache.catalina.deploy.ApplicationListener;
 import org.apache.catalina.deploy.ContextEnvironment;
+import org.apache.catalina.servlets.DefaultServlet;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
 import org.apache.catalina.util.Base64;
@@ -53,6 +54,7 @@ import org.apache.tomcat.util.buf.B2CCon
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.C2BConverter;
 import org.apache.tomcat.util.buf.CharChunk;
+import org.apache.tomcat.websocket.TesterEchoServer;
 
 public class TestWebSocket extends TomcatBaseTest {
 
@@ -64,16 +66,21 @@ public class TestWebSocket extends Tomca
     @Test
     public void testSimple() throws Exception {
         Tomcat tomcat = getTomcatInstance();
-        File appDir = new File(getBuildDirectory(), "webapps/examples");
-        tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
+        // Must have a real docBase - just use temp
+        Context ctx = tomcat.addContext("",
+                System.getProperty("java.io.tmpdir"));
+        ctx.addApplicationListener(new ApplicationListener(
+                TesterEchoServer.Config.class.getName(), false));
 
-        tomcat.start();
+        Tomcat.addServlet(ctx, "default", new DefaultServlet());
+        ctx.addServletMapping("/", "default");
 
-        WebSocketClient client= new WebSocketClient(getPort());
+        tomcat.start();
 
+        WebSocketClient client = new WebSocketClient(getPort());
 
         // Send the WebSocket handshake
-        client.writer.write("GET /examples/websocket/echoStream HTTP/1.1" + CRLF);
+        client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
         client.writer.write("Host: foo" + CRLF);
         client.writer.write("Upgrade: websocket" + CRLF);
         client.writer.write("Connection: keep-alive, upgrade" + CRLF);
@@ -105,14 +112,21 @@ public class TestWebSocket extends Tomca
     @Test
     public void testDetectWrongVersion() throws Exception {
         Tomcat tomcat = getTomcatInstance();
-        File appDir = new File(getBuildDirectory(), "webapps/examples");
-        tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
+        // Must have a real docBase - just use temp
+        Context ctx = tomcat.addContext("",
+                System.getProperty("java.io.tmpdir"));
+        ctx.addApplicationListener(new ApplicationListener(
+                TesterEchoServer.Config.class.getName(), false));
+
+        Tomcat.addServlet(ctx, "default", new DefaultServlet());
+        ctx.addServletMapping("/", "default");
 
         tomcat.start();
+
         WebSocketClient client= new WebSocketClient(getPort());
 
         // Send the WebSocket handshake
-        client.writer.write("GET /examples/websocket/echoStream HTTP/1.1" + CRLF);
+        client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
         client.writer.write("Host: foo" + CRLF);
         client.writer.write("Upgrade: websocket" + CRLF);
         client.writer.write("Connection: upgrade" + CRLF);
@@ -141,15 +155,21 @@ public class TestWebSocket extends Tomca
     @Test
     public void testNoConnection() throws Exception {
         Tomcat tomcat = getTomcatInstance();
-        File appDir = new File(getBuildDirectory(), "webapps/examples");
-        tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
+        // Must have a real docBase - just use temp
+        Context ctx = tomcat.addContext("",
+                System.getProperty("java.io.tmpdir"));
+        ctx.addApplicationListener(new ApplicationListener(
+                TesterEchoServer.Config.class.getName(), false));
+
+        Tomcat.addServlet(ctx, "default", new DefaultServlet());
+        ctx.addServletMapping("/", "default");
 
         tomcat.start();
-        WebSocketClient client= new WebSocketClient(getPort());
 
+        WebSocketClient client= new WebSocketClient(getPort());
 
         // Send the WebSocket handshake
-        client.writer.write("GET /examples/websocket/echoStream HTTP/1.1" + CRLF);
+        client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
         client.writer.write("Host: foo" + CRLF);
         client.writer.write("Upgrade: websocket" + CRLF);
         client.writer.write("Sec-WebSocket-Version: 13" + CRLF);
@@ -157,7 +177,7 @@ public class TestWebSocket extends Tomca
         client.writer.write(CRLF);
         client.writer.flush();
 
-        // Make sure we got an upgrade response
+        // Make sure we got an error response
         String responseLine = client.reader.readLine();
         assertTrue(responseLine.startsWith("HTTP/1.1 400"));
 
@@ -169,14 +189,21 @@ public class TestWebSocket extends Tomca
     @Test
     public void testNoUpgrade() throws Exception {
         Tomcat tomcat = getTomcatInstance();
-        File appDir = new File(getBuildDirectory(), "webapps/examples");
-        tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
+        // Must have a real docBase - just use temp
+        Context ctx = tomcat.addContext("",
+                System.getProperty("java.io.tmpdir"));
+        ctx.addApplicationListener(new ApplicationListener(
+                TesterEchoServer.Config.class.getName(), false));
+
+        Tomcat.addServlet(ctx, "default", new DefaultServlet());
+        ctx.addServletMapping("/", "default");
 
         tomcat.start();
+
         WebSocketClient client= new WebSocketClient(getPort());
 
         // Send the WebSocket handshake
-        client.writer.write("GET /examples/websocket/echoStream HTTP/1.1" + CRLF);
+        client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
         client.writer.write("Host: foo" + CRLF);
         client.writer.write("Connection: upgrade" + CRLF);
         client.writer.write("Sec-WebSocket-Version: 13" + CRLF);
@@ -184,9 +211,11 @@ public class TestWebSocket extends Tomca
         client.writer.write(CRLF);
         client.writer.flush();
 
-        // Make sure we got an upgrade response
+        // Make sure we got an error response
+        // No upgrade means it is not treated an as upgrade request so a 404 is
+        // generated when the request reaches the Default Servlet.s
         String responseLine = client.reader.readLine();
-        assertTrue(responseLine.startsWith("HTTP/1.1 400"));
+        assertTrue(responseLine.startsWith("HTTP/1.1 404"));
 
         // Finished with the socket
         client.close();
@@ -195,14 +224,21 @@ public class TestWebSocket extends Tomca
     @Test
     public void testKey() throws Exception {
         Tomcat tomcat = getTomcatInstance();
-        File appDir = new File(getBuildDirectory(), "webapps/examples");
-        tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
+        // Must have a real docBase - just use temp
+        Context ctx = tomcat.addContext("",
+                System.getProperty("java.io.tmpdir"));
+        ctx.addApplicationListener(new ApplicationListener(
+                TesterEchoServer.Config.class.getName(), false));
+
+        Tomcat.addServlet(ctx, "default", new DefaultServlet());
+        ctx.addServletMapping("/", "default");
 
         tomcat.start();
+
         WebSocketClient client= new WebSocketClient(getPort());
 
         // Send the WebSocket handshake
-        client.writer.write("GET /examples/websocket/echoStream HTTP/1.1" + CRLF);
+        client.writer.write("GET " + TesterEchoServer.Config.PATH_BASIC + " HTTP/1.1" + CRLF);
         client.writer.write("Host: foo" + CRLF);
         client.writer.write("Upgrade: websocket" + CRLF);
         client.writer.write("Connection: upgrade" + CRLF);

Modified: tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/parser/TestMediaType.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/parser/TestMediaType.java?rev=1515813&r1=1515812&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/parser/TestMediaType.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/parser/TestMediaType.java Tue Aug 20 13:10:50 2013
@@ -291,4 +291,10 @@ public class TestMediaType {
         Assert.assertEquals("2", m.getParameterValue("B"));
         Assert.assertEquals("2", m.getParameterValue("b"));
     }
+
+    @Test
+    public void testBug55454() throws Exception {
+        StringReader sr = new StringReader("text/html;");
+        MediaType m = HttpParser.parseMediaType(sr);
+    }
 }

Modified: tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/TestUtil.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/TestUtil.java?rev=1515813&r1=1515191&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/TestUtil.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/TestUtil.java Tue Aug 20 13:10:50 2013
@@ -26,6 +26,11 @@ import org.junit.Test;
 
 public class TestUtil {
 
+    // Used to init SecureRandom prior to running tests
+    public static void generateMask() {
+        Util.generateMask();
+    }
+    
     @Test
     public void testGetMessageTypeSimple() {
         Assert.assertEquals(

Modified: tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/pojo/TestEncodingDecoding.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/pojo/TestEncodingDecoding.java?rev=1515813&r1=1515191&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/pojo/TestEncodingDecoding.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/pojo/TestEncodingDecoding.java Tue Aug 20 13:10:50 2013
@@ -161,23 +161,30 @@ public class TestEncodingDecoding extend
         Assert.assertEquals(MESSAGE_ONE,
                 ((MsgString) client.received.peek()).getData());
         session.close();
-        Thread.sleep(100);
-        Assert.assertTrue(Server.isLifeCycleEventCalled(
-                MsgStringEncoder.class.getName()+":init"));
-        Assert.assertTrue(Server.isLifeCycleEventCalled(
-                MsgStringDecoder.class.getName()+":init"));
-        Assert.assertTrue(Server.isLifeCycleEventCalled(
-                MsgByteEncoder.class.getName()+":init"));
-        Assert.assertTrue(Server.isLifeCycleEventCalled(
-                MsgByteDecoder.class.getName()+":init"));
-        Assert.assertTrue(Server.isLifeCycleEventCalled(
-                MsgStringEncoder.class.getName()+":destroy"));
-        Assert.assertTrue(Server.isLifeCycleEventCalled(
-                MsgStringDecoder.class.getName()+":destroy"));
-        Assert.assertTrue(Server.isLifeCycleEventCalled(
-                MsgByteEncoder.class.getName()+":destroy"));
-        Assert.assertTrue(Server.isLifeCycleEventCalled(
-                MsgByteDecoder.class.getName()+":destroy"));
+
+        // Should not take very long but some failures have been seen
+        i = testEvent(MsgStringEncoder.class.getName()+":init", 0);
+        i = testEvent(MsgStringDecoder.class.getName()+":init", i);
+        i = testEvent(MsgByteEncoder.class.getName()+":init", i);
+        i = testEvent(MsgByteDecoder.class.getName()+":init", i);
+        i = testEvent(MsgStringEncoder.class.getName()+":destroy", i);
+        i = testEvent(MsgStringDecoder.class.getName()+":destroy", i);
+        i = testEvent(MsgByteEncoder.class.getName()+":destroy", i);
+        i = testEvent(MsgByteDecoder.class.getName()+":destroy", i);
+    }
+
+    
+    private int testEvent(String name, int count) throws InterruptedException {
+        int i = count;
+        while (i < 50) {
+            if (Server.isLifeCycleEventCalled(name)) {
+                break;
+            }
+            i++;
+            Thread.sleep(100);
+        }
+        Assert.assertTrue(Server.isLifeCycleEventCalled(name));
+        return i;
     }
 
 

Modified: tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/pojo/TestPojoEndpointBase.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/pojo/TestPojoEndpointBase.java?rev=1515813&r1=1515191&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/pojo/TestPojoEndpointBase.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/pojo/TestPojoEndpointBase.java Tue Aug 20 13:10:50 2013
@@ -38,6 +38,7 @@ import org.apache.catalina.deploy.Applic
 import org.apache.catalina.servlets.DefaultServlet;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.tomcat.websocket.TestUtil;
 import org.apache.tomcat.websocket.pojo.TesterUtil.ServerConfigListener;
 import org.apache.tomcat.websocket.pojo.TesterUtil.SingletonConfigurator;
 
@@ -45,6 +46,7 @@ public class TestPojoEndpointBase extend
 
     @Test
     public void testBug54716() throws Exception {
+        TestUtil.generateMask();
         // Set up utility classes
         Bug54716 server = new Bug54716();
         SingletonConfigurator.setInstance(server);

Modified: tomcat/tc7.0.x/trunk/webapps/docs/web-socket-howto.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/web-socket-howto.xml?rev=1515813&r1=1515812&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/web-socket-howto.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/web-socket-howto.xml Tue Aug 20 13:10:50 2013
@@ -34,19 +34,63 @@
 
 <section name="Overview">
 <p>Tomcat provides support for WebSocket as defined by
-   <a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a>. This feature is
-   not yet finalised and you are encouraged to provide feedback in the form
-   of bug reports (via
-   <a href="https://issues.apache.org/bugzilla">Bugzilla</a>), suggested API
-   changes (via the <a href="mailto:dev@tomcat.apache.org">dev list</a>) or
-   other comments (again via the <a href="mailto:dev@tomcat.apache.org">dev
-   list</a>).</p>
+   <a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a>.</p>
 </section>
 
 <section name="Application development">
-<p>The API used for application development has not yet been finalised. Rather
-   than document something here that will quickly be out of date, please see the
-   Javadoc for the
+<p>Tomcat implements the Java WebSocket 1.0 API defined by <a
+   href="http://www.jcp.org/en/jsr/detail?id=356">JSR-356</a>.</p>
+
+<p>There are several example applications that demonstrate how the WebSocket API
+   can be used. You will need to look at both the client side <a
+   href="http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/websocket/">
+   HTML</a> and the server side <a
+   href="http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/">
+   code</a>.</p>
+</section>
+
+<section name="Tomcat WebSocket specific configuration">
+<p>Tomcat provides a number of Tomcat specific configuration options for
+   WebSocket. It is anticipated that these will be absorbed into the WebSocket
+   specification over time.</p>
+
+<p>The write timeout used when sending WebSocket messages in blocking mode
+   defaults to 20000 milliseconds (20 seconds). This may be changed by setting
+   the property <code>org.apache.tomcat.websocket.BLOCKING_SEND_TIMEOUT</code>
+   in the user properties collection attached to the WebSocket session. The
+   value assigned to this property should be a <code>Long</code> and represents
+   the timeout to use in milliseconds. For an infinite timeout, use
+   <code>-1</code>.</p>
+
+<p>The default buffer size for binary messages is 8192 bytes. This may be
+   changed for a web application by setting the servlet context initialization
+   parameter <code>org.apache.tomcat.websocket.binaryBufferSize</code> to the
+   desired value in bytes.</p>
+
+<p>The default buffer size for text messages is 8192 bytes. This may be
+   changed for a web application by setting the servlet context initialization
+   parameter <code>org.apache.tomcat.websocket.textBufferSize</code> to the
+   desired value in bytes.</p>
+
+<p>The Java WebSocket specification 1.0 does not permit programmatic deployment
+   after the first endpoint has started a WebSocket handshake. By default,
+   Tomcat continues to permit additional programmatic deployment. This
+   behavior is controlled by the
+   <code>org.apache.tomcat.websocket.noAddAfterHandshake</code> servlet context
+   initialization parameter. The default may be changed by setting the
+   <code>org.apache.tomcat.websocket.STRICT_SPEC_COMPLIANCE</code> system
+   property to <code>true</code> but any explicit setting on the servlet context
+   will always take priority.</p>
+</section>
+
+<section name="Deprecated proprietary API">
+
+<p>Prior to the development of JRS-356, Tomcat provided a proprietary WebSocket
+   API. This API has been deprecated in Tomcat 7 and will be removed in Tomcat
+   8. There is unlikely to be any further development of this proprietary API
+   apart from bug fixes.</p>
+
+<p>For information on this API, please see the Javadoc for the
    <a href="api/index.html?org/apache/catalina/websocket/package-summary.html">
    <code>org.apache.catalina.websocket</code></a> package. The Javadoc
    pages are not included with Tomcat binary distributions. To view them
@@ -58,14 +102,12 @@
 
 <p>There are also several example applications that demonstrate how the
    WebSocket API can be used. You'll need to look at both the client side <a
-   href="http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/examples/websocket/">
-   html</a> and the server side <a
-   href="http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/">
-   code</a>.</p>
-
-<p>Do keep in mind that the API is fluid and is likely to change, possibly
-   significantly, between point releases. The documentation will be updated once
-   the API is considered stable (unlikely to be until JSR 356 is complete).</p>
+   href="http://svn.apache.org/viewvc/tomcat/tc7.0.x/tags/TOMCAT_7_0_42/webapps/examples/websocket/">
+   HTML</a> and the server side <a
+   href="http://svn.apache.org/viewvc/tomcat/tc7.0.x/tags/TOMCAT_7_0_42/webapps/examples/WEB-INF/classes/websocket/">
+   code</a>. Note that as of 7.0.43, these sample applications have been
+   refactored to use the JSR-356 WebSocket implementation so the links above are
+   for the 7.0.42 tag.</p>
 </section>
 
 

Modified: tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/chat/ChatAnnotation.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/chat/ChatAnnotation.java?rev=1515813&r1=1515189&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/chat/ChatAnnotation.java (original)
+++ tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/chat/ChatAnnotation.java Tue Aug 20 13:10:50 2013
@@ -35,7 +35,7 @@ public class ChatAnnotation {
     private static final String GUEST_PREFIX = "Guest";
     private static final AtomicInteger connectionIds = new AtomicInteger(0);
     private static final Set<ChatAnnotation> connections =
-            new CopyOnWriteArraySet<>();
+            new CopyOnWriteArraySet<ChatAnnotation>();
 
     private final String nickname;
     private Session session;

Modified: tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/echo/WsConfigListener.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/echo/WsConfigListener.java?rev=1515813&r1=1515189&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/echo/WsConfigListener.java (original)
+++ tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/echo/WsConfigListener.java Tue Aug 20 13:10:50 2013
@@ -23,8 +23,6 @@ import javax.websocket.DeploymentExcepti
 import javax.websocket.server.ServerContainer;
 import javax.websocket.server.ServerEndpointConfig;
 
-import org.apache.tomcat.websocket.server.Constants;
-
 @WebListener
 public class WsConfigListener implements ServletContextListener {
 
@@ -32,7 +30,7 @@ public class WsConfigListener implements
     public void contextInitialized(ServletContextEvent sce) {
         ServerContainer sc =
                 (ServerContainer) sce.getServletContext().getAttribute(
-                        Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
+                        "javax.websocket.server.ServerContainer");
         try {
             sc.addEndpoint(ServerEndpointConfig.Builder.create(
                     EchoEndpoint.class, "/websocket/echoProgrammatic").build());

Modified: tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/Snake.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/Snake.java?rev=1515813&r1=1515189&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/Snake.java (original)
+++ tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/Snake.java Tue Aug 20 13:10:50 2013
@@ -33,7 +33,7 @@ public class Snake {
     private Direction direction;
     private int length = DEFAULT_LENGTH;
     private Location head;
-    private final Deque<Location> tail = new ArrayDeque<>();
+    private final Deque<Location> tail = new ArrayDeque<Location>();
     private final String hexColor;
 
     public Snake(int id, Session session) {

Modified: tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java?rev=1515813&r1=1515189&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java (original)
+++ tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java Tue Aug 20 13:10:50 2013
@@ -39,7 +39,7 @@ public class SnakeTimer {
     private static final long TICK_DELAY = 100;
 
     private static final ConcurrentHashMap<Integer, Snake> snakes =
-            new ConcurrentHashMap<>();
+            new ConcurrentHashMap<Integer, Snake>();
 
     protected static synchronized void addSnake(Snake snake) {
         if (snakes.size() == 0) {

Modified: tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/web.xml?rev=1515813&r1=1515812&r2=1515813&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/web.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/web.xml Tue Aug 20 13:10:50 2013
@@ -352,52 +352,4 @@
       <servlet-name>stock</servlet-name>
       <url-pattern>/async/stockticker</url-pattern>
     </servlet-mapping>
-
-    <!-- WebSocket Examples -->
-    <servlet>
-      <servlet-name>wsEchoStream</servlet-name>
-      <servlet-class>websocket.echo.EchoStream</servlet-class>
-    </servlet>
-    <servlet-mapping>
-      <servlet-name>wsEchoStream</servlet-name>
-      <url-pattern>/websocket/echoStream</url-pattern>
-    </servlet-mapping>
-    <servlet>
-      <servlet-name>wsEchoMessage</servlet-name>
-      <servlet-class>websocket.echo.EchoMessage</servlet-class>
-      <!-- Uncomment the following block to increase the default maximum
-           WebSocket buffer size from 2MB to 20MB which is required for the
-           Autobahn test suite to pass fully. -->
-      <!--
-      <init-param>
-        <param-name>byteBufferMaxSize</param-name>
-        <param-value>20971520</param-value>
-      </init-param>
-      <init-param>
-        <param-name>charBufferMaxSize</param-name>
-        <param-value>20971520</param-value>
-      </init-param>
-      -->
-    </servlet>
-    <servlet-mapping>
-      <servlet-name>wsEchoMessage</servlet-name>
-      <url-pattern>/websocket/echoMessage</url-pattern>
-    </servlet-mapping>
-    <servlet>
-        <servlet-name>wsChat</servlet-name>
-        <servlet-class>websocket.chat.ChatWebSocketServlet</servlet-class>
-    </servlet>
-    <servlet-mapping>
-        <servlet-name>wsChat</servlet-name>
-        <url-pattern>/websocket/chat</url-pattern>
-    </servlet-mapping>
-    <servlet>
-      <servlet-name>wsSnake</servlet-name>
-      <servlet-class>websocket.snake.SnakeWebSocketServlet</servlet-class>
-    </servlet>
-    <servlet-mapping>
-      <servlet-name>wsSnake</servlet-name>
-      <url-pattern>/websocket/snake</url-pattern>
-    </servlet-mapping>
-
 </web-app>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org