Author: markt
Date: Wed Mar 6 14:18:57 2013
New Revision: 1453340
URL: http://svn.apache.org/r1453340
Log:
Refactoring towards v014 API (not yet complete)
Added:
tomcat/trunk/java/javax/websocket/SessionException.java (with props)
Modified:
tomcat/trunk/java/javax/websocket/WebSocketContainer.java
tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
Added: tomcat/trunk/java/javax/websocket/SessionException.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/SessionException.java?rev=1453340&view=auto
==============================================================================
--- tomcat/trunk/java/javax/websocket/SessionException.java (added)
+++ tomcat/trunk/java/javax/websocket/SessionException.java Wed Mar 6 14:18:57
2013
@@ -0,0 +1,35 @@
+/*
+ * 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;
+
+public class SessionException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Session session;
+
+
+ public SessionException(String message, Throwable cause, Session session) {
+ super(message, cause);
+ this.session = session;
+ }
+
+
+ public Session getSession() {
+ return session;
+ }
+}
Propchange: tomcat/trunk/java/javax/websocket/SessionException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/java/javax/websocket/WebSocketContainer.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/WebSocketContainer.java?rev=1453340&r1=1453339&r2=1453340&view=diff
==============================================================================
--- tomcat/trunk/java/javax/websocket/WebSocketContainer.java (original)
+++ tomcat/trunk/java/javax/websocket/WebSocketContainer.java Wed Mar 6
14:18:57 2013
@@ -34,6 +34,9 @@ public interface WebSocketContainer {
*/
void setAsyncSendTimeout(long timeout);
+ Session connectToServer(Object endpoint, URI path)
+ throws DeploymentException, IOException;
+
Session connectToServer(Class<?> annotatedEndpointClass, URI path)
throws DeploymentException, IOException;
@@ -41,6 +44,25 @@ public interface WebSocketContainer {
* Creates a new connection to the WebSocket.
*
* @param endpoint
+ * The endpoint instance that will handle responses from the
+ * server
+ * @param clientEndpointConfiguration
+ * Used to configure the new connection
+ * @param path
+ * The full URL of the WebSocket endpoint to connect to
+ *
+ * @return The WebSocket session for the connection
+ *
+ * @throws DeploymentException If the connection can not be established
+ */
+ Session connectToServer(Endpoint endpoint,
+ ClientEndpointConfig clientEndpointConfiguration, URI path)
+ throws DeploymentException, IOException;
+
+ /**
+ * Creates a new connection to the WebSocket.
+ *
+ * @param endpoint
* An instance of this class will be created to handle responses
* from the server
* @param clientEndpointConfiguration
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java?rev=1453340&r1=1453339&r2=1453340&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Wed
Mar 6 14:18:57 2013
@@ -69,6 +69,16 @@ public class WsWebSocketContainer
private int backgroundProcessCount = 0;
private int processPeriod = 10;
+
+
+ @Override
+ public Session connectToServer(Object pojo, URI path)
+ throws DeploymentException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
@Override
public Session connectToServer(Class<?> annotatedEndpointClass, URI path)
throws DeploymentException {
@@ -82,6 +92,24 @@ public class WsWebSocketContainer
ClientEndpointConfig clientEndpointConfiguration, URI path)
throws DeploymentException {
+ Endpoint endpoint;
+ try {
+ endpoint = clazz.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new DeploymentException(sm.getString(
+ "wsWebSocketContainer.endpointCreateFail",
clazz.getName()),
+ e);
+ }
+
+ return connectToServer(endpoint, clientEndpointConfiguration, path);
+ }
+
+
+ @Override
+ public Session connectToServer(Endpoint endpoint,
+ ClientEndpointConfig clientEndpointConfiguration, URI path)
+ throws DeploymentException {
+
String scheme = path.getScheme();
if (!("http".equalsIgnoreCase(scheme) ||
"https".equalsIgnoreCase(scheme))) {
@@ -165,20 +193,12 @@ public class WsWebSocketContainer
WsRemoteEndpointImplClient wsRemoteEndpointClient =
new WsRemoteEndpointImplClient(channel);
- Endpoint endpoint;
- try {
- endpoint = clazz.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- throw new DeploymentException(sm.getString(
- "wsWebSocketContainer.endpointCreateFail",
clazz.getName()),
- e);
- }
WsSession wsSession = new WsSession(endpoint, wsRemoteEndpointClient,
this, null, subProtocol, Collections.EMPTY_MAP, false,
clientEndpointConfiguration.getEncoders());
endpoint.onOpen(wsSession, clientEndpointConfiguration);
- registerSession(clazz, wsSession);
+ registerSession(endpoint.getClass(), wsSession);
// Object creation will trigger input processing
@SuppressWarnings("unused")
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]