Author: markt Date: Fri Jan 25 12:36:33 2013 New Revision: 1438471 URL: http://svn.apache.org/viewvc?rev=1438471&view=rev Log: Implement Session#getContainer() for client and server
Modified: tomcat/trunk/java/javax/websocket/Session.java tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java tomcat/trunk/java/org/apache/tomcat/websocket/server/WsProtocolHandler.java Modified: tomcat/trunk/java/javax/websocket/Session.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/websocket/Session.java?rev=1438471&r1=1438470&r2=1438471&view=diff ============================================================================== --- tomcat/trunk/java/javax/websocket/Session.java (original) +++ tomcat/trunk/java/javax/websocket/Session.java Fri Jan 25 12:36:33 2013 @@ -25,6 +25,9 @@ import java.util.Set; public interface Session { + /** + * Returns the container that created this session. + */ WebSocketContainer getContainer(); void addMessageHandler(MessageHandler listener) Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java?rev=1438471&r1=1438470&r2=1438471&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java Fri Jan 25 12:36:33 2013 @@ -46,6 +46,7 @@ public class WsSession implements Sessio private final Endpoint localEndpoint; private final WsRemoteEndpointBase wsRemoteEndpoint; private final ClassLoader applicationClassLoader; + private final WebSocketContainer webSocketContainer; private MessageHandler textMessageHandler = null; private MessageHandler binaryMessageHandler = null; @@ -65,17 +66,18 @@ public class WsSession implements Sessio * @param wsRemoteEndpoint */ public WsSession(Endpoint localEndpoint, - WsRemoteEndpointBase wsRemoteEndpoint) { + WsRemoteEndpointBase wsRemoteEndpoint, + WebSocketContainer webSocketContainer) { this.localEndpoint = localEndpoint; this.wsRemoteEndpoint = wsRemoteEndpoint; + this.webSocketContainer = webSocketContainer; applicationClassLoader = Thread.currentThread().getContextClassLoader(); } @Override public WebSocketContainer getContainer() { - // TODO Auto-generated method stub - return null; + return webSocketContainer; } 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=1438471&r1=1438470&r2=1438471&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Fri Jan 25 12:36:33 2013 @@ -145,7 +145,8 @@ public class WsWebSocketContainer implem "wsWebSocketContainer.endpointCreateFail", clazz.getName()), e); } - WsSession wsSession = new WsSession(endpoint, wsRemoteEndpointClient); + WsSession wsSession = + new WsSession(endpoint, wsRemoteEndpointClient, this); endpoint.onOpen(wsSession, clientEndpointConfiguration); Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/WsProtocolHandler.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsProtocolHandler.java?rev=1438471&r1=1438470&r2=1438471&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/server/WsProtocolHandler.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/server/WsProtocolHandler.java Fri Jan 25 12:36:33 2013 @@ -50,8 +50,7 @@ public class WsProtocolHandler implement private final Endpoint ep; private final EndpointConfiguration endpointConfig; private final ClassLoader applicationClassLoader; - private final int binaryBufferSize; - private final int textBufferSize; + private final WebSocketContainer webSocketContainer; private WsSession wsSession; @@ -61,9 +60,8 @@ public class WsProtocolHandler implement WebSocketContainer wsc) { this.ep = ep; this.endpointConfig = endpointConfig; + this.webSocketContainer = wsc; applicationClassLoader = Thread.currentThread().getContextClassLoader(); - binaryBufferSize = (int) wsc.getMaxBinaryMessageBufferSize(); - textBufferSize = (int) wsc.getMaxTextMessageBufferSize(); } @@ -87,9 +85,13 @@ public class WsProtocolHandler implement try { WsRemoteEndpointServer wsRemoteEndpointServer = new WsRemoteEndpointServer(sos); - wsSession = new WsSession(ep, wsRemoteEndpointServer); + wsSession = new WsSession( + ep, wsRemoteEndpointServer, webSocketContainer); WsFrameServer wsFrame = new WsFrameServer( - sis, binaryBufferSize, textBufferSize, wsSession); + sis, + (int) webSocketContainer.getMaxBinaryMessageBufferSize(), + (int) webSocketContainer.getMaxTextMessageBufferSize(), + wsSession); sis.setReadListener(new WsReadListener(this, wsFrame)); sos.setWriteListener( new WsWriteListener(this, wsRemoteEndpointServer)); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org