Author: markt Date: Sat Dec 22 22:08:35 2012 New Revision: 1425352 URL: http://svn.apache.org/viewvc?rev=1425352&view=rev Log: Update the WebSocket API to v011 of the JSR 356 draft
Added: tomcat/trunk/java/javax/websocket/Extension.java (with props) tomcat/trunk/java/javax/websocket/WebSocketContainer.java - copied, changed from r1424725, tomcat/trunk/java/javax/websocket/ClientContainer.java tomcat/trunk/java/javax/websocket/server/ tomcat/trunk/java/javax/websocket/server/DefaultServerConfiguration.java - copied, changed from r1424725, tomcat/trunk/java/javax/websocket/DefaultServerConfiguration.java tomcat/trunk/java/javax/websocket/server/HandshakeRequest.java - copied, changed from r1424725, tomcat/trunk/java/javax/websocket/HandshakeRequest.java tomcat/trunk/java/javax/websocket/server/ServerApplicationConfiguration.java (with props) tomcat/trunk/java/javax/websocket/server/ServerEndpointConfiguration.java - copied, changed from r1424725, tomcat/trunk/java/javax/websocket/ServerEndpointConfiguration.java tomcat/trunk/java/javax/websocket/server/WebSocketEndpoint.java - copied, changed from r1424725, tomcat/trunk/java/javax/websocket/WebSocketEndpoint.java tomcat/trunk/java/javax/websocket/server/WebSocketPathParam.java - copied, changed from r1424725, tomcat/trunk/java/javax/websocket/WebSocketPathParam.java Removed: tomcat/trunk/java/javax/websocket/ClientContainer.java tomcat/trunk/java/javax/websocket/DefaultServerConfiguration.java tomcat/trunk/java/javax/websocket/EndpointFactory.java tomcat/trunk/java/javax/websocket/HandshakeRequest.java tomcat/trunk/java/javax/websocket/ServerContainer.java tomcat/trunk/java/javax/websocket/ServerEndpointConfiguration.java tomcat/trunk/java/javax/websocket/WebSocketEndpoint.java tomcat/trunk/java/javax/websocket/WebSocketPathParam.java Modified: tomcat/trunk/java/javax/websocket/ClientEndpointConfiguration.java tomcat/trunk/java/javax/websocket/ContainerProvider.java tomcat/trunk/java/javax/websocket/DefaultClientConfiguration.java tomcat/trunk/java/javax/websocket/Endpoint.java tomcat/trunk/java/javax/websocket/HandshakeResponse.java tomcat/trunk/java/javax/websocket/RemoteEndpoint.java tomcat/trunk/java/javax/websocket/Session.java Modified: tomcat/trunk/java/javax/websocket/ClientEndpointConfiguration.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/ClientEndpointConfiguration.java?rev=1425352&r1=1425351&r2=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/ClientEndpointConfiguration.java (original) +++ tomcat/trunk/java/javax/websocket/ClientEndpointConfiguration.java Sat Dec 22 22:08:35 2012 @@ -17,6 +17,7 @@ package javax.websocket; import java.util.List; +import java.util.Map; public interface ClientEndpointConfiguration extends EndpointConfiguration { @@ -24,7 +25,7 @@ public interface ClientEndpointConfigura List<String> getExtensions(); - void beforeRequest(HandshakeRequest handshakeRequest); + void beforeRequest(Map<String, List<String>> headers); void afterResponse(HandshakeResponse handshakeResponse); } Modified: tomcat/trunk/java/javax/websocket/ContainerProvider.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/ContainerProvider.java?rev=1425352&r1=1425351&r2=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/ContainerProvider.java (original) +++ tomcat/trunk/java/javax/websocket/ContainerProvider.java Sat Dec 22 22:08:35 2012 @@ -16,45 +16,17 @@ */ package javax.websocket; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - /** * Provides access to the implementation. This version of the API is hard-coded * to use the Apache Tomcat WebSocket implementation. */ public class ContainerProvider { - private static final String CONTAINER_PROVIDER_IMPL = - "org.apache.tomcat.websocket.ServerContainerImpl"; - - /** - * Obtain a reference to the Server container used for processing incoming - * WebSocket connections. - */ - public static ServerContainer getServerContainer() { - // Note: No special handling required when running under a - // SecurityManager as the container provider implementation and - // this class have the same class loader. - 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; - } - /** * Obtain a reference to the ClientContainer used to create outgoing * WebSocket connections. */ - public static ClientContainer getClientContainer() { + public static WebSocketContainer getClientContainer() { return null; } } Modified: tomcat/trunk/java/javax/websocket/DefaultClientConfiguration.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/DefaultClientConfiguration.java?rev=1425352&r1=1425351&r2=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/DefaultClientConfiguration.java (original) +++ tomcat/trunk/java/javax/websocket/DefaultClientConfiguration.java Sat Dec 22 22:08:35 2012 @@ -18,6 +18,7 @@ package javax.websocket; import java.util.ArrayList; import java.util.List; +import java.util.Map; public class DefaultClientConfiguration implements ClientEndpointConfiguration { private List<String> preferredSubprotocols = new ArrayList<>(); @@ -68,7 +69,7 @@ public class DefaultClientConfiguration } @Override - public void beforeRequest(HandshakeRequest handshakeRequest) { + public void beforeRequest(Map<String, List<String>> headers) { // NO-OP } Modified: tomcat/trunk/java/javax/websocket/Endpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/Endpoint.java?rev=1425352&r1=1425351&r2=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/Endpoint.java (original) +++ tomcat/trunk/java/javax/websocket/Endpoint.java Sat Dec 22 22:08:35 2012 @@ -23,23 +23,25 @@ public abstract class Endpoint { * * @param session The new session. */ - public abstract void onOpen(Session session); + public abstract void onOpen(Session session, EndpointConfiguration config); /** * Event that is triggered when a session has closed. * + * @param session The session * @param closeReason Why the session was closed */ - public void onClose(CloseReason closeReason) { + public void onClose(Session session, CloseReason closeReason) { // NO-OP by default } /** * Event that is triggered when a protocol error occurs. * + * @param session The session * @param throwable The exception */ - public void onError(Throwable throwable) { + public void onError(Session session, Throwable throwable) { // NO-OP by default } } Added: tomcat/trunk/java/javax/websocket/Extension.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/Extension.java?rev=1425352&view=auto ============================================================================== --- tomcat/trunk/java/javax/websocket/Extension.java (added) +++ tomcat/trunk/java/javax/websocket/Extension.java Sat Dec 22 22:08:35 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 javax.websocket; + +import java.util.Map; + +public interface Extension { + String getName(); + Map<String,String> getParameters(); +} Propchange: tomcat/trunk/java/javax/websocket/Extension.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/java/javax/websocket/HandshakeResponse.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/HandshakeResponse.java?rev=1425352&r1=1425351&r2=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/HandshakeResponse.java (original) +++ tomcat/trunk/java/javax/websocket/HandshakeResponse.java Sat Dec 22 22:08:35 2012 @@ -21,5 +21,8 @@ import java.util.Map; public interface HandshakeResponse { + public static final String SEC_WEBSOCKET_ACCEPT = + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; + Map<String,List<String>> getHeaders(); } Modified: tomcat/trunk/java/javax/websocket/RemoteEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/RemoteEndpoint.java?rev=1425352&r1=1425351&r2=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/RemoteEndpoint.java (original) +++ tomcat/trunk/java/javax/websocket/RemoteEndpoint.java Sat Dec 22 22:08:35 2012 @@ -25,6 +25,12 @@ import java.util.concurrent.Future; public interface RemoteEndpoint { + void setBatchingAllowed(boolean batchingAllowed); + boolean getBatchingAllowed(); + void flushBatch(); + long getAsyncSendTimeout(); + void setAsyncSendTimeout(long timeout); + /** * Send the message, blocking until the message is sent. * @param text The text message to send. Modified: tomcat/trunk/java/javax/websocket/Session.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/Session.java?rev=1425352&r1=1425351&r2=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/Session.java (original) +++ tomcat/trunk/java/javax/websocket/Session.java Sat Dec 22 22:08:35 2012 @@ -18,15 +18,17 @@ package javax.websocket; import java.io.IOException; import java.net.URI; +import java.security.Principal; import java.util.List; import java.util.Map; import java.util.Set; public interface Session { - ClientContainer getContainer(); + WebSocketContainer getContainer(); - void addMessageHandler(MessageHandler listener); + void addMessageHandler(MessageHandler listener) + throws IllegalStateException; Set<MessageHandler> getMessageHandlers(); @@ -40,8 +42,6 @@ public interface Session { boolean isSecure(); - long getInactiveTime(); - boolean isOpen(); long getTimeout(); @@ -54,6 +54,8 @@ public interface Session { RemoteEndpoint getRemote(); + String getId(); + /** * Close the connection to the remote end point using the code * {@link javax.websocket.CloseReason.CloseCodes#NORMAL_CLOSURE} and an @@ -74,11 +76,13 @@ public interface Session { URI getRequestURI(); - Map<String, String[]> getRequestParameterMap(); + Map<String, List<String>> getRequestParameterMap(); String getQueryString(); Map<String,String> getPathParameters(); Map<String,Object> getUserProperties(); + + Principal getUserPrincipal(); } Copied: tomcat/trunk/java/javax/websocket/WebSocketContainer.java (from r1424725, tomcat/trunk/java/javax/websocket/ClientContainer.java) URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/WebSocketContainer.java?p2=tomcat/trunk/java/javax/websocket/WebSocketContainer.java&p1=tomcat/trunk/java/javax/websocket/ClientContainer.java&r1=1424725&r2=1425352&rev=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/ClientContainer.java (original) +++ tomcat/trunk/java/javax/websocket/WebSocketContainer.java Sat Dec 22 22:08:35 2012 @@ -19,12 +19,16 @@ package javax.websocket; import java.net.URI; import java.util.Set; -public interface ClientContainer { +public interface WebSocketContainer { - Session connectToServer(Object endpoint, URI path) + long getDefaultAsyncSendTimeout(); + + void setAsyncSendTimeout(long timeout); + + Session connectToServer(Class<?> annotatedEndpointClass, URI path) throws DeploymentException; - Session connectToServer(Endpoint endpoint, + Session connectToServer(Class<? extends Endpoint> endpoint, ClientEndpointConfiguration clientEndpointConfiguration, URI path) throws DeploymentException; @@ -42,5 +46,5 @@ public interface ClientContainer { void setMaxTextMessageBufferSize(long max); - Set<String> getInstalledExtensions(); + Set<Extension> getInstalledExtensions(); } Copied: tomcat/trunk/java/javax/websocket/server/DefaultServerConfiguration.java (from r1424725, tomcat/trunk/java/javax/websocket/DefaultServerConfiguration.java) URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/server/DefaultServerConfiguration.java?p2=tomcat/trunk/java/javax/websocket/server/DefaultServerConfiguration.java&p1=tomcat/trunk/java/javax/websocket/DefaultServerConfiguration.java&r1=1424725&r2=1425352&rev=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/DefaultServerConfiguration.java (original) +++ tomcat/trunk/java/javax/websocket/server/DefaultServerConfiguration.java Sat Dec 22 22:08:35 2012 @@ -14,60 +14,66 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package javax.websocket; +package javax.websocket.server; import java.net.URI; import java.util.ArrayList; import java.util.List; -public class DefaultServerConfiguration<T> - implements ServerEndpointConfiguration<T> { +import javax.websocket.Decoder; +import javax.websocket.Encoder; +import javax.websocket.Endpoint; +import javax.websocket.Extension; +import javax.websocket.HandshakeResponse; +public class DefaultServerConfiguration implements ServerEndpointConfiguration { + + private Class<? extends Endpoint> endpointClass; private String path; - @SuppressWarnings("unused") // TODO Remove this once implemented private List<String> subprotocols = new ArrayList<>(); - @SuppressWarnings("unused") // TODO Remove this once implemented - private List<String> extensions = new ArrayList<>(); + private List<Extension> extensions = new ArrayList<>(); private List<Encoder> encoders = new ArrayList<>(); private List<Decoder> decoders = new ArrayList<>(); - protected DefaultServerConfiguration() { - } - - @Override - public EndpointFactory<T> getEndpointFactory() { - // TODO - return null; - } - - public DefaultServerConfiguration(String path) { + public DefaultServerConfiguration(Class<? extends Endpoint> endpointClass, + String path) { + this.endpointClass = endpointClass; this.path = path; } - public DefaultServerConfiguration<T> setEncoders(List<Encoder> encoders) { - this.encoders = encoders; + public DefaultServerConfiguration setEncoders(List<Encoder> encoders) { + this.encoders.clear(); + this.encoders.addAll(encoders); return this; } - public DefaultServerConfiguration<T> setDecoders(List<Decoder> decoders) { - this.decoders = decoders; + public DefaultServerConfiguration setDecoders(List<Decoder> decoders) { + this.decoders.clear(); + this.decoders.addAll(decoders); return this; } - public DefaultServerConfiguration<T> setSubprotocols( + public DefaultServerConfiguration setSubprotocols( List<String> subprotocols) { - this.subprotocols = subprotocols; + this.subprotocols.clear(); + this.subprotocols.addAll(subprotocols); return this; } - public DefaultServerConfiguration<T> setExtensions( - List<String> extensions) { - this.extensions = extensions; + public DefaultServerConfiguration setExtensions( + List<Extension> extensions) { + this.extensions.clear(); + this.extensions.addAll(extensions); return this; } @Override + public Class<? extends Endpoint> getEndpointClass() { + return endpointClass; + } + + @Override public List<Encoder> getEncoders() { return this.encoders; } @@ -89,16 +95,15 @@ public class DefaultServerConfiguration< } @Override - public List<String> getNegotiatedExtensions( - List<String> requestedExtensions) { + public List<Extension> getNegotiatedExtensions( + List<Extension> requestedExtensions) { // TODO return null; } @Override public boolean checkOrigin(String originHeaderValue) { - // TODO - return false; + return true; } @Override Copied: tomcat/trunk/java/javax/websocket/server/HandshakeRequest.java (from r1424725, tomcat/trunk/java/javax/websocket/HandshakeRequest.java) URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/server/HandshakeRequest.java?p2=tomcat/trunk/java/javax/websocket/server/HandshakeRequest.java&p1=tomcat/trunk/java/javax/websocket/HandshakeRequest.java&r1=1424725&r2=1425352&rev=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/HandshakeRequest.java (original) +++ tomcat/trunk/java/javax/websocket/server/HandshakeRequest.java Sat Dec 22 22:08:35 2012 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package javax.websocket; +package javax.websocket.server; import java.net.URI; import java.security.Principal; @@ -23,6 +23,11 @@ import java.util.Map; public interface HandshakeRequest { + static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key"; + static final String SEC_WEBSOCKET_PROTOCOL = "Sec-WebSocket-Protocol"; + static final String SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version"; + static final String SEC_WEBSOCKET_EXTENSIONS= "Sec-WebSocket-Extensions"; + Map<String,List<String>> getHeaders(); Principal getUserPrincipal(); @@ -37,7 +42,7 @@ public interface HandshakeRequest { */ Object getSession(); - Map<String, String[]> getParameterMap(); + Map<String, List<String>> getParameterMap(); String getQueryString(); } Added: tomcat/trunk/java/javax/websocket/server/ServerApplicationConfiguration.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/server/ServerApplicationConfiguration.java?rev=1425352&view=auto ============================================================================== --- tomcat/trunk/java/javax/websocket/server/ServerApplicationConfiguration.java (added) +++ tomcat/trunk/java/javax/websocket/server/ServerApplicationConfiguration.java Sat Dec 22 22:08:35 2012 @@ -0,0 +1,26 @@ +/* + * 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 javax.websocket.server; + +import java.util.Set; + +public interface ServerApplicationConfiguration { + + Set<Class<? extends ServerEndpointConfiguration>> getEndpointConfigurationClasses(Set<Class<? extends ServerEndpointConfiguration>> scanned); + + Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>> scanned); +} Propchange: tomcat/trunk/java/javax/websocket/server/ServerApplicationConfiguration.java ------------------------------------------------------------------------------ svn:eol-style = native Copied: tomcat/trunk/java/javax/websocket/server/ServerEndpointConfiguration.java (from r1424725, tomcat/trunk/java/javax/websocket/ServerEndpointConfiguration.java) URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/server/ServerEndpointConfiguration.java?p2=tomcat/trunk/java/javax/websocket/server/ServerEndpointConfiguration.java&p1=tomcat/trunk/java/javax/websocket/ServerEndpointConfiguration.java&r1=1424725&r2=1425352&rev=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/ServerEndpointConfiguration.java (original) +++ tomcat/trunk/java/javax/websocket/server/ServerEndpointConfiguration.java Sat Dec 22 22:08:35 2012 @@ -14,18 +14,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package javax.websocket; +package javax.websocket.server; import java.net.URI; import java.util.List; -public interface ServerEndpointConfiguration<T> extends EndpointConfiguration { +import javax.websocket.Endpoint; +import javax.websocket.EndpointConfiguration; +import javax.websocket.Extension; +import javax.websocket.HandshakeResponse; - EndpointFactory<T> getEndpointFactory(); +public interface ServerEndpointConfiguration extends EndpointConfiguration { + + Class<? extends Endpoint> getEndpointClass(); String getNegotiatedSubprotocol(List<String> requestedSubprotocols); - List<String> getNegotiatedExtensions(List<String> requestedExtensions); + List<Extension> getNegotiatedExtensions(List<Extension> requestedExtensions); boolean checkOrigin(String originHeaderValue); Copied: tomcat/trunk/java/javax/websocket/server/WebSocketEndpoint.java (from r1424725, tomcat/trunk/java/javax/websocket/WebSocketEndpoint.java) URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/server/WebSocketEndpoint.java?p2=tomcat/trunk/java/javax/websocket/server/WebSocketEndpoint.java&p1=tomcat/trunk/java/javax/websocket/WebSocketEndpoint.java&r1=1424725&r2=1425352&rev=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/WebSocketEndpoint.java (original) +++ tomcat/trunk/java/javax/websocket/server/WebSocketEndpoint.java Sat Dec 22 22:08:35 2012 @@ -14,13 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package javax.websocket; +package javax.websocket.server; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import javax.websocket.Decoder; +import javax.websocket.Encoder; + @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface WebSocketEndpoint { @@ -36,5 +39,6 @@ public @interface WebSocketEndpoint { Class<? extends Encoder>[] encoders() default {}; - //Class<? extends EndpointFactory<?>> factory(); + Class<? extends DefaultServerConfiguration> configuration() + default DefaultServerConfiguration.class; } Copied: tomcat/trunk/java/javax/websocket/server/WebSocketPathParam.java (from r1424725, tomcat/trunk/java/javax/websocket/WebSocketPathParam.java) URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/server/WebSocketPathParam.java?p2=tomcat/trunk/java/javax/websocket/server/WebSocketPathParam.java&p1=tomcat/trunk/java/javax/websocket/WebSocketPathParam.java&r1=1424725&r2=1425352&rev=1425352&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/WebSocketPathParam.java (original) +++ tomcat/trunk/java/javax/websocket/server/WebSocketPathParam.java Sat Dec 22 22:08:35 2012 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package javax.websocket; +package javax.websocket.server; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org