Author: markt
Date: Sat Nov 24 23:12:49 2012
New Revision: 1413281

URL: http://svn.apache.org/viewvc?rev=1413281&view=rev
Log:
WebSocket 1.0 implementation part 1 of many.
Implement the the bootstrap code for Endpoints defined both using 
POJOS+annotations and programmatically.
At this stage the ServerContainer just dumps relevant info to stdout.
Add initial an implementation of the Echo example for each of the approaches.
Added:
    tomcat/trunk/java/org/apache/websocket/
    tomcat/trunk/java/org/apache/websocket/ClientContainerImpl.java   (with 
props)
    tomcat/trunk/java/org/apache/websocket/ServerContainerImpl.java   (with 
props)
    tomcat/trunk/java/org/apache/websocket/Util.java   (with props)
    tomcat/trunk/java/org/apache/websocket/WsSci.java   (with props)
    tomcat/trunk/java/org/apache/websocket/WsServlet.java   (with props)
    tomcat/trunk/res/META-INF/default/
    tomcat/trunk/res/META-INF/websocket-impl.jar/
    tomcat/trunk/res/META-INF/websocket-impl.jar/services/
    
tomcat/trunk/res/META-INF/websocket-impl.jar/services/javax.servlet.ServletContainerInitializer
   (with props)
    tomcat/trunk/test/org/apache/websocket/
    tomcat/trunk/test/org/apache/websocket/TestUtil.java   (with props)
    
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAnnotation.java
   (with props)
    
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoEndpoint.java  
 (with props)
    
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/WsConfigListener.java
   (with props)
Modified:
    tomcat/trunk/build.xml
    tomcat/trunk/conf/catalina.properties
    tomcat/trunk/java/javax/websocket/ContainerProvider.java
    tomcat/trunk/java/javax/websocket/WebSocketEndpoint.java
    tomcat/trunk/webapps/examples/WEB-INF/web.xml

Modified: tomcat/trunk/build.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/build.xml?rev=1413281&r1=1413280&r2=1413281&view=diff
==============================================================================
--- tomcat/trunk/build.xml (original)
+++ tomcat/trunk/build.xml Sat Nov 24 23:12:49 2012
@@ -89,6 +89,7 @@
   <property name="jsp-api.jar" value="${tomcat.build}/lib/jsp-api.jar"/>
   <property name="el-api.jar" value="${tomcat.build}/lib/el-api.jar"/>
   <property name="websocket-api.jar" 
value="${tomcat.build}/lib/websocket-api.jar"/>
+  <property name="websocket-impl.jar" 
value="${tomcat.build}/lib/websocket-impl.jar"/>
   <property name="catalina.jar" value="${tomcat.build}/lib/catalina.jar"/>
   <property name="catalina-tribes.jar" 
value="${tomcat.build}/lib/catalina-tribes.jar"/>
   <property name="catalina-ha.jar" 
value="${tomcat.build}/lib/catalina-ha.jar"/>
@@ -114,6 +115,7 @@
   <property name="jsp-api-src.jar" value="${tomcat.src.jars}/jsp-api-src.jar"/>
   <property name="el-api-src.jar" value="${tomcat.src.jars}/el-api-src.jar"/>
   <property name="websocket-api-src.jar" 
value="${tomcat.src.jars}/websocket-api-src.jar"/>
+  <property name="websocket-impl-src.jar" 
value="${tomcat.src.jars}/websocket-impl-src.jar"/>
   <property name="catalina-src.jar" 
value="${tomcat.src.jars}/catalina-src.jar"/>
   <property name="catalina-tribes-src.jar" 
value="${tomcat.src.jars}/catalina-tribes-src.jar"/>
   <property name="catalina-ha-src.jar" 
value="${tomcat.src.jars}/catalina-ha-src.jar"/>
@@ -285,6 +287,11 @@
     <include name="javax/websocket/**" />
   </patternset>
 
+  <patternset id="files.websocket-impl">
+    <include name="org/apache/websocket/**" />
+    <include name="org/apache/websocket/**" />
+  </patternset>
+
   <patternset id="files.bootstrap">
     <include name="org/apache/catalina/startup/Bootstrap.*" />
     <include name="org/apache/catalina/startup/catalina.properties" />
@@ -376,6 +383,7 @@
     <patternset refid="files.el-api" />
     <patternset refid="files.servlet-api" />
     <patternset refid="files.websocket-api" />
+    <patternset refid="files.websocket-impl" />
     <patternset refid="files.tomcat-api" />
     <!-- These pattern sets conflict so include files directly
       <patternset refid="files.tomcat-coyote" />
@@ -622,11 +630,7 @@
     <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>
@@ -660,12 +664,18 @@
       filesId="files.el-api"
       manifest="${tomcat.manifests}/el-api.jar.manifest" />
 
-    <!-- WebSocket 1.0 Implementation JAR File -->
+    <!-- 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="${websocket-impl.jar}"
+      filesDir="${tomcat.classes}"
+      filesId="files.websocket-impl"
+      meta-inf="${tomcat.manifests}/websocket-impl.jar"/>
+
     <!-- Bootstrap JAR File -->
     <jarIt jarfile="${bootstrap.jar}"
       filesDir="${tomcat.classes}"
@@ -1714,6 +1724,7 @@ Apache Tomcat ${version} native binaries
         <include name="jasper-el.jar"/>
         <include name="servlet-api.jar"/>
         <include name="websocket-api.jar"/>
+        <include name="websocket-impl.jar"/>
         <include name="tomcat-coyote.jar"/>
         <include name="tomcat-util.jar"/>
       </fileset>
@@ -2243,12 +2254,17 @@ Apache Tomcat ${version} native binaries
       filesId="files.el-api"
       manifest="${tomcat.manifests}/el-api.jar.manifest" />
 
-    <!-- WebSocket 1.0 EL Implementation JAR File -->
+    <!-- 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="${websocket-impl-src.jar}"
+      filesDir="java"
+      filesId="files.websocket-impl" />
+
     <!-- Bootstrap JAR File -->
     <jarIt jarfile="${bootstrap-src.jar}"
       filesDir="java"
@@ -2647,6 +2663,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}">
@@ -2655,6 +2673,7 @@ Read the Building page on the Apache Tom
           <exclude name="**/package.html" />
           <exclude name="**/LocalStrings_*" />
         </fileset>
+        <zipfileset dir="@{meta-inf}" prefix="META-INF/" />
         <zipfileset file="@{notice}" fullpath="META-INF/NOTICE" />
         <zipfileset file="@{license}" fullpath="META-INF/LICENSE" />
       </jar>

Modified: tomcat/trunk/conf/catalina.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/conf/catalina.properties?rev=1413281&r1=1413280&r2=1413281&view=diff
==============================================================================
--- tomcat/trunk/conf/catalina.properties (original)
+++ tomcat/trunk/conf/catalina.properties Sat Nov 24 23:12:49 2012
@@ -99,7 +99,7 @@ tomcat-api.jar,tomcat-util.jar,tomcat-co
 tomcat-jni.jar,tomcat-spdy.jar,\
 tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\
 tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,\
-tomcat-jdbc.jar,\
+tomcat-jdbc.jar,websocket-api.jar\
 commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,\
 commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,\
 
commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,\

Modified: tomcat/trunk/java/javax/websocket/ContainerProvider.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/ContainerProvider.java?rev=1413281&r1=1413280&r2=1413281&view=diff
==============================================================================
--- tomcat/trunk/java/javax/websocket/ContainerProvider.java (original)
+++ tomcat/trunk/java/javax/websocket/ContainerProvider.java Sat Nov 24 
23:12:49 2012
@@ -16,15 +16,31 @@
  */
 package javax.websocket;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
 public class ContainerProvider {
 
+    private static final String CONTAINER_PROVIDER_IMPL =
+            "org.apache.websocket.ServerContainerImpl";
+
     public static ServerContainer getServerContainer() {
-        // TODO
-        return null;
+        // TODO SecurityManager
+        ServerContainer result = null;
+        try {
+            Class<?> clazz = Class.forName(CONTAINER_PROVIDER_IMPL);
+            Method m = clazz.getMethod("getServerContainer", (Class<?>[]) 
null);
+            result = (ServerContainer) m.invoke(null, (Object[]) null);
+        } catch (ClassNotFoundException | NoSuchMethodException |
+                SecurityException | IllegalAccessException |
+                IllegalArgumentException | InvocationTargetException e) {
+            e.printStackTrace();
+        }
+
+        return result;
     }
 
     public static ClientContainer getClientContainer() {
-        // TODO
         return null;
     }
 }

Modified: tomcat/trunk/java/javax/websocket/WebSocketEndpoint.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/WebSocketEndpoint.java?rev=1413281&r1=1413280&r2=1413281&view=diff
==============================================================================
--- tomcat/trunk/java/javax/websocket/WebSocketEndpoint.java (original)
+++ tomcat/trunk/java/javax/websocket/WebSocketEndpoint.java Sat Nov 24 
23:12:49 2012
@@ -25,6 +25,9 @@ import java.lang.annotation.Target;
 @Target(ElementType.TYPE)
 public @interface WebSocketEndpoint {
 
+    /**
+     * URI or URI-template that the annotated class should be mapped to.
+     */
     public String value();
 
     public String[] subprotocols() default {};

Added: tomcat/trunk/java/org/apache/websocket/ClientContainerImpl.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/websocket/ClientContainerImpl.java?rev=1413281&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/websocket/ClientContainerImpl.java (added)
+++ tomcat/trunk/java/org/apache/websocket/ClientContainerImpl.java Sat Nov 24 
23:12:49 2012
@@ -0,0 +1,83 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  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.
+ */
+package org.apache.websocket;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.websocket.ClientContainer;
+import javax.websocket.DeploymentException;
+import javax.websocket.Session;
+
+public class ClientContainerImpl implements ClientContainer {
+
+    @Override
+    public void connectToServer(Object endpoint, URI path)
+            throws DeploymentException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public Set<Session> getActiveSessions() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public long getMaxSessionIdleTimeout() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void setMaxSessionIdleTimeout(long timeout) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public long getMaxBinaryMessageBufferSize() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void setMaxBinaryMessageBufferSize(long max) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public long getMaxTextMessageBufferSize() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void setMaxTextMessageBufferSize(long max) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public Set<String> getInstalledExtensions() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Propchange: tomcat/trunk/java/org/apache/websocket/ClientContainerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/websocket/ServerContainerImpl.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/websocket/ServerContainerImpl.java?rev=1413281&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/websocket/ServerContainerImpl.java (added)
+++ tomcat/trunk/java/org/apache/websocket/ServerContainerImpl.java Sat Nov 24 
23:12:49 2012
@@ -0,0 +1,99 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  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.
+ */
+package org.apache.websocket;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import javax.websocket.DeploymentException;
+import javax.websocket.Endpoint;
+import javax.websocket.ServerContainer;
+import javax.websocket.ServerEndpointConfiguration;
+
+public class ServerContainerImpl extends ClientContainerImpl implements
+        ServerContainer {
+
+    // Needs to be a WekaHashMap to prevent memory leaks when a context is
+    // stopped
+    private static Map<ClassLoader, ServerContainerImpl>
+            classLoaderContainerMap = new WeakHashMap<>();
+    private static ReadWriteLock classLoaderContainerMapLock =
+            new  ReentrantReadWriteLock();
+
+    public static ServerContainerImpl getServerContainer() {
+        // TODO SecurityManager
+        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+
+        ServerContainerImpl result = null;
+
+        Lock readlock = classLoaderContainerMapLock.readLock();
+        try {
+            readlock.lock();
+            result = classLoaderContainerMap.get(tccl);
+        } finally {
+            readlock.unlock();
+        }
+
+        if (result == null) {
+            Lock writeLock = classLoaderContainerMapLock.writeLock();
+            try {
+                writeLock.lock();
+                result = classLoaderContainerMap.get(tccl);
+                if (result == null) {
+                    result = new ServerContainerImpl();
+                    classLoaderContainerMap.put(tccl, result);
+                }
+            } finally {
+                writeLock.unlock();
+            }
+        }
+        return result;
+    }
+
+    private ServerContainerImpl() {
+        // Hide default constructor
+    }
+
+    @Override
+    public void publishServer(Class<? extends Endpoint> clazz)
+            throws DeploymentException {
+
+        try {
+            Endpoint ep = clazz.newInstance();
+            ServerEndpointConfiguration config =
+                    (ServerEndpointConfiguration) 
ep.getEndpointConfiguration();
+            String path = Util.getServletMappingPath(config.getPath());
+
+            // TODO Replace following debug code with something useful.
+            System.out.println("Class [" + clazz.getName() +
+                    "] deployed to path [" + path + "]");
+        } catch (InstantiationException | IllegalAccessException e) {
+            // TODO i18n
+            throw new DeploymentException(
+                    "Failed to instantiate specified Endpoint", e);
+        }
+    }
+
+    public void publishServer(Class<?> pojo, String path) {
+        // TODO Replace following debug code with something useful.
+        System.out.println("Class [" + pojo.getName() +
+                "] deployed to path [" + path + "]");
+    }
+}

Propchange: tomcat/trunk/java/org/apache/websocket/ServerContainerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/websocket/Util.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/websocket/Util.java?rev=1413281&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/websocket/Util.java (added)
+++ tomcat/trunk/java/org/apache/websocket/Util.java Sat Nov 24 23:12:49 2012
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ */
+package org.apache.websocket;
+
+class Util {
+
+    private Util() {
+        // Hide default constructor
+    }
+
+    static String getServletMappingPath(String wsPath) {
+        int templateStart = wsPath.indexOf('{');
+        if (templateStart == -1) {
+            if (wsPath.charAt(wsPath.length() - 1) == '/') {
+                return wsPath + '*';
+            } else {
+                return wsPath + "/*";
+            }
+        } else {
+            String temp = wsPath.substring(0, templateStart);
+            if (temp.charAt(temp.length() - 1) == '/') {
+                return temp + '*';
+            } else {
+                return temp.substring(0, temp.lastIndexOf('/') + 1) + '*';
+            }
+        }
+    }
+}

Propchange: tomcat/trunk/java/org/apache/websocket/Util.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/websocket/WsSci.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/websocket/WsSci.java?rev=1413281&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/websocket/WsSci.java (added)
+++ tomcat/trunk/java/org/apache/websocket/WsSci.java Sat Nov 24 23:12:49 2012
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  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.
+ */
+package org.apache.websocket;
+
+import java.util.Set;
+
+import javax.servlet.ServletContainerInitializer;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.HandlesTypes;
+import javax.websocket.WebSocketEndpoint;
+
+@HandlesTypes({WebSocketEndpoint.class})
+public class WsSci implements ServletContainerInitializer {
+
+    @Override
+    public void onStartup(Set<Class<?>> clazzes, ServletContext ctx)
+            throws ServletException {
+        if (clazzes == null || clazzes.size() == 0) {
+            return;
+        }
+        ServerContainerImpl sc = ServerContainerImpl.getServerContainer();
+
+        for (Class<?> clazz : clazzes) {
+            WebSocketEndpoint anotation =
+                    clazz.getAnnotation(WebSocketEndpoint.class);
+            String mappingPath = Util.getServletMappingPath(anotation.value());
+            sc.publishServer(clazz, mappingPath);
+        }
+    }
+
+}

Propchange: tomcat/trunk/java/org/apache/websocket/WsSci.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/websocket/WsServlet.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/websocket/WsServlet.java?rev=1413281&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/websocket/WsServlet.java (added)
+++ tomcat/trunk/java/org/apache/websocket/WsServlet.java Sat Nov 24 23:12:49 
2012
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ */
+package org.apache.websocket;
+
+public class WsServlet {
+
+}

Propchange: tomcat/trunk/java/org/apache/websocket/WsServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
tomcat/trunk/res/META-INF/websocket-impl.jar/services/javax.servlet.ServletContainerInitializer
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/res/META-INF/websocket-impl.jar/services/javax.servlet.ServletContainerInitializer?rev=1413281&view=auto
==============================================================================
--- 
tomcat/trunk/res/META-INF/websocket-impl.jar/services/javax.servlet.ServletContainerInitializer
 (added)
+++ 
tomcat/trunk/res/META-INF/websocket-impl.jar/services/javax.servlet.ServletContainerInitializer
 Sat Nov 24 23:12:49 2012
@@ -0,0 +1 @@
+org.apache.websocket.WsSci

Propchange: 
tomcat/trunk/res/META-INF/websocket-impl.jar/services/javax.servlet.ServletContainerInitializer
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/test/org/apache/websocket/TestUtil.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/websocket/TestUtil.java?rev=1413281&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/websocket/TestUtil.java (added)
+++ tomcat/trunk/test/org/apache/websocket/TestUtil.java Sat Nov 24 23:12:49 
2012
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  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.
+ */
+package org.apache.websocket;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class TestUtil {
+
+    @Test
+    public void testGetServletMappingPath() throws Exception {
+        Assert.assertEquals("/foo/*",
+                Util.getServletMappingPath("/foo"));
+        Assert.assertEquals("/foo/*",
+                Util.getServletMappingPath("/foo/"));
+        Assert.assertEquals("/foo/bar/*",
+                Util.getServletMappingPath("/foo/bar"));
+        Assert.assertEquals("/foo/bar/*",
+                Util.getServletMappingPath("/foo/bar/"));
+        Assert.assertEquals("/foo/*",
+                Util.getServletMappingPath("/foo/{bar}"));
+        Assert.assertEquals("/foo/*",
+                Util.getServletMappingPath("/foo/{bar}/"));
+        Assert.assertEquals("/foo/*",
+                Util.getServletMappingPath("/foo/x{bar}"));
+        Assert.assertEquals("/foo/*",
+                Util.getServletMappingPath("/foo/x{bar}/"));
+    }
+}

Propchange: tomcat/trunk/test/org/apache/websocket/TestUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAnnotation.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAnnotation.java?rev=1413281&view=auto
==============================================================================
--- 
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAnnotation.java
 (added)
+++ 
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAnnotation.java
 Sat Nov 24 23:12:49 2012
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  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.
+ */
+package websocket.echo;
+
+import javax.websocket.WebSocketEndpoint;
+
+@WebSocketEndpoint("/websocket/echoAnnotation")
+public class EchoAnnotation {
+
+}

Propchange: 
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAnnotation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoEndpoint.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoEndpoint.java?rev=1413281&view=auto
==============================================================================
--- 
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoEndpoint.java 
(added)
+++ 
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoEndpoint.java 
Sat Nov 24 23:12:49 2012
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  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.
+ */
+package websocket.echo;
+
+import javax.websocket.DefaultServerConfiguration;
+import javax.websocket.Endpoint;
+import javax.websocket.EndpointConfiguration;
+import javax.websocket.ServerEndpointConfiguration;
+import javax.websocket.Session;
+
+public class EchoEndpoint extends Endpoint{
+
+    private static ServerEndpointConfiguration config =
+            new DefaultServerConfiguration("/websocket/echoProgrammatic");
+
+    @Override
+    public EndpointConfiguration getEndpointConfiguration() {
+        return config;
+    }
+
+    @Override
+    public void onOpen(Session session) {
+        // TODO Auto-generated method stub
+
+    }
+}

Propchange: 
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/WsConfigListener.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/WsConfigListener.java?rev=1413281&view=auto
==============================================================================
--- 
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/WsConfigListener.java
 (added)
+++ 
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/WsConfigListener.java
 Sat Nov 24 23:12:49 2012
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  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.
+ */
+package websocket.echo;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.annotation.WebListener;
+import javax.websocket.ContainerProvider;
+import javax.websocket.DeploymentException;
+import javax.websocket.ServerContainer;
+
+@WebListener
+public class WsConfigListener implements ServletContextListener {
+
+    @Override
+    public void contextInitialized(ServletContextEvent sce) {
+        ServerContainer sc = ContainerProvider.getServerContainer();
+        try {
+            sc.publishServer(EchoEndpoint.class);
+        } catch (DeploymentException e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+
+    @Override
+    public void contextDestroyed(ServletContextEvent sce) {
+        // NO-OP
+    }
+}

Propchange: 
tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/WsConfigListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tomcat/trunk/webapps/examples/WEB-INF/web.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/web.xml?rev=1413281&r1=1413280&r2=1413281&view=diff
==============================================================================
--- tomcat/trunk/webapps/examples/WEB-INF/web.xml (original)
+++ tomcat/trunk/webapps/examples/WEB-INF/web.xml Sat Nov 24 23:12:49 2012
@@ -20,7 +20,7 @@
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                       http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
   version="3.0"
-  metadata-complete="true">
+  metadata-complete="false">
 
     <description>
       Servlet and JSP Examples.



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

Reply via email to