tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1712736 - in /tomcat/tc8.0.x/trunk: java/org/apache/tomcat/websocket/ java/org/apache/tomcat/websocket/server/ res/checkstyle/ webapps/docs/
Date Thu, 05 Nov 2015 10:29:53 GMT
Author: remm
Date: Thu Nov  5 10:29:53 2015
New Revision: 1712736

URL: http://svn.apache.org/viewvc?rev=1712736&view=rev
Log:
Port r1712575: Use InstanceManager for server endpoint instances.

Modified:
    tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
    tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsSession.java
    tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
    tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java
    tomcat/tc8.0.x/trunk/res/checkstyle/org-import-control.xml
    tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties?rev=1712736&r1=1712735&r2=1712736&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties (original)
+++ tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties Thu Nov
 5 10:29:53 2015
@@ -99,6 +99,8 @@ wsSession.sendCloseFail=Failed to send c
 wsSession.removeHandlerFailed=Unable to remove the handler [{0}] as it was not registered
with this session
 wsSession.unknownHandler=Unable to add the message handler [{0}] as it was for the unrecognised
type [{1}]
 wsSession.unknownHandlerType=Unable to add the message handler [{0}] as it was wrapped as
the unrecognised type [{1}]
+wsSession.instanceNew=Endpoint instance registration failed
+wsSession.instanceDestroy=Endpoint instance unregistration failed
 
 # Note the following message is used as a close reason in a WebSocket control
 # frame and therefore must be 123 bytes (not characters) or less in length.

Modified: tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsSession.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsSession.java?rev=1712736&r1=1712735&r2=1712736&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsSession.java (original)
+++ tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsSession.java Thu Nov  5 10:29:53
2015
@@ -47,6 +47,7 @@ import javax.websocket.WebSocketContaine
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 
@@ -180,6 +181,15 @@ public class WsSession implements Sessio
         this.userProperties.putAll(endpointConfig.getUserProperties());
         this.id = Long.toHexString(ids.getAndIncrement());
 
+        InstanceManager instanceManager = webSocketContainer.getInstanceManager();
+        if (instanceManager != null) {
+            try {
+                instanceManager.newInstance(localEndpoint);
+            } catch (Exception e) {
+                throw new DeploymentException(sm.getString("wsSession.instanceNew"), e);
+            }
+        }
+
         if (log.isDebugEnabled()) {
             log.debug(sm.getString("wsSession.created", id));
         }
@@ -520,11 +530,15 @@ public class WsSession implements Sessio
     private void fireEndpointOnClose(CloseReason closeReason) {
 
         // Fire the onClose event
+        InstanceManager instanceManager = webSocketContainer.getInstanceManager();
         Thread t = Thread.currentThread();
         ClassLoader cl = t.getContextClassLoader();
         t.setContextClassLoader(applicationClassLoader);
         try {
             localEndpoint.onClose(this, closeReason);
+            if (instanceManager != null) {
+                instanceManager.destroyInstance(localEndpoint);
+            }
         } catch (Throwable throwable) {
             ExceptionUtils.handleThrowable(throwable);
             localEndpoint.onError(this, throwable);

Modified: tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java?rev=1712736&r1=1712735&r2=1712736&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java (original)
+++ tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Thu Nov
 5 10:29:53 2015
@@ -64,6 +64,7 @@ import javax.websocket.WebSocketContaine
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.websocket.pojo.PojoEndpointClient;
@@ -127,6 +128,15 @@ public class WsWebSocketContainer
     private int backgroundProcessCount = 0;
     private int processPeriod = Constants.DEFAULT_PROCESS_PERIOD;
 
+    private InstanceManager instanceManager;
+
+    InstanceManager getInstanceManager() {
+        return instanceManager;
+    }
+
+    protected void setInstanceManager(InstanceManager instanceManager) {
+        this.instanceManager = instanceManager;
+    }
 
     @Override
     public Session connectToServer(Object pojo, URI path)

Modified: tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java?rev=1712736&r1=1712735&r2=1712736&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java (original)
+++ tomcat/tc8.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java Thu
Nov  5 10:29:53 2015
@@ -51,6 +51,7 @@ import javax.websocket.server.ServerEndp
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.websocket.WsSession;
 import org.apache.tomcat.websocket.WsWebSocketContainer;
@@ -98,6 +99,7 @@ public class WsServerContainer extends W
     WsServerContainer(ServletContext servletContext) {
 
         this.servletContext = servletContext;
+        setInstanceManager((InstanceManager) servletContext.getAttribute(InstanceManager.class.getName()));
 
         // Configure servlet context wide defaults
         String value = servletContext.getInitParameter(

Modified: tomcat/tc8.0.x/trunk/res/checkstyle/org-import-control.xml
URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/res/checkstyle/org-import-control.xml?rev=1712736&r1=1712735&r2=1712736&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/res/checkstyle/org-import-control.xml (original)
+++ tomcat/tc8.0.x/trunk/res/checkstyle/org-import-control.xml Thu Nov  5 10:29:53 2015
@@ -159,6 +159,7 @@
     <subpackage name="websocket">
       <allow pkg="javax.websocket"/>
       <allow pkg="org.apache.juli"/>
+      <allow pkg="org.apache.tomcat"/>
       <allow pkg="org.apache.tomcat.util"/>
       <!-- Ideally want to remove this -->
       <allow pkg="org.apache.tomcat.websocket.pojo"/>

Modified: tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml?rev=1712736&r1=1712735&r2=1712736&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml Thu Nov  5 10:29:53 2015
@@ -179,6 +179,13 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="WebSocket">
+    <changelog>
+      <fix>
+        Use instance manager for server endpoint instances. (remm)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="jdbc-pool">
     <changelog>
       <fix>



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


Mime
View raw message