Author: markt Date: Thu Jun 27 22:04:44 2013 New Revision: 1497580 URL: http://svn.apache.org/r1497580 Log: WebSocket 1.0, Section 6.4 Once an Endpoint has been used, no more Endpoints can be registered
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties?rev=1497580&r1=1497579&r2=1497580&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties Thu Jun 27 22:04:44 2013 @@ -14,6 +14,7 @@ # limitations under the License. sci.newInstance.fail=Failed to create an Endpoint instance of type [{0}] +serverContainer.addNotAllowed=No further Endpoints may be registered once an attempt has been made to use one of the previously registered endpoints serverContainer.configuratorFail=Failed to create configurator of type [{0}] for POJO of type [{1}] serverContainer.duplicatePaths=Multiple Endpoints may not be deployed to using the same path [{0}] serverContainer.encoderFail=Unable to create encoder of type [{0}] Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java?rev=1497580&r1=1497579&r2=1497580&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java Thu Jun 27 22:04:44 2013 @@ -91,6 +91,7 @@ public class WsServerContainer extends W new ConcurrentHashMap<>(); private final ConcurrentHashMap<Integer,SortedSet<TemplatePathMatch>> configTemplateMatchMap = new ConcurrentHashMap<>(); + private volatile boolean addAllowed = true; private WsServerContainer() { // Hide default constructor @@ -139,6 +140,12 @@ public class WsServerContainer extends W @Override public void addEndpoint(ServerEndpointConfig sec) throws DeploymentException { + + if (!addAllowed) { + throw new DeploymentException( + sm.getString("serverContainer.addNotAllowed")); + } + if (servletContext == null) { throw new DeploymentException( sm.getString("serverContainer.servletContextMissing")); @@ -230,6 +237,12 @@ public class WsServerContainer extends W public WsMappingResult findMapping(String path) { + // Prevent registering additional endpoints once the first attempt has + // been made to use one + if (addAllowed) { + addAllowed = false; + } + // Check an exact match. Simple case as there are no templates. ServerEndpointConfig sec = configExactMatchMap.get(path); if (sec != null) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org