On Mar 25, 2013, at 10:01 AM, ma...@apache.org wrote: > Author: markt > Date: Mon Mar 25 15:01:41 2013 > New Revision: 1460700 > > URL: http://svn.apache.org/r1460700 > Log: > Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54740 > Update SCI scan to reflect changes in spec > > Modified: > tomcat/trunk/java/org/apache/tomcat/websocket/server/WsSci.java > > Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/WsSci.java > URL: > http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsSci.java?rev=1460700&r1=1460699&r2=1460700&view=diff > ============================================================================== > --- tomcat/trunk/java/org/apache/tomcat/websocket/server/WsSci.java (original) > +++ tomcat/trunk/java/org/apache/tomcat/websocket/server/WsSci.java Mon Mar > 25 15:01:41 2013 > @@ -16,6 +16,7 @@ > */ > package org.apache.tomcat.websocket.server; > > +import java.lang.reflect.Modifier; > import java.util.HashSet; > import java.util.Set; > > @@ -36,7 +37,7 @@ import javax.websocket.server.ServerEndp > * server. > */ > @HandlesTypes({ServerEndpoint.class, ServerEndpointConfig.class, > - ServerApplicationConfig.class}) > + Endpoint.class})
How does Tomcat handle it (or even know?) when it comes across an Endpoint class that's meant to be a client Endpoint, not a server Endpoint? Normally you would use a client Endpoint with WebSocketContainer#connectToServer(Endpoint, ClientEndpointConfig, URI) or WebSocketContainer#connectToServer(Class<? extends Endpoint>, ClientEndpointConfig, URI), but SCI will pick up client Endpoints as well as server Endpoints cases with this change. > public class WsSci implements ServletContainerInitializer { > > @Override > @@ -51,7 +52,6 @@ public class WsSci implements ServletCon > > // Group the discovered classes by type > Set<ServerApplicationConfig> serverApplicationConfigs = new > HashSet<>(); > - Set<ServerEndpointConfig> scannedEndpointConfigs = new HashSet<>(); > Set<Class<? extends Endpoint>> scannedEndpointClazzes = new > HashSet<>(); > Set<Class<?>> scannedPojoEndpoints = new HashSet<>(); > > @@ -60,6 +60,12 @@ public class WsSci implements ServletCon > String wsPackage = ContainerProvider.class.getName(); > wsPackage = wsPackage.substring(0, wsPackage.lastIndexOf('.') + > 1); > for (Class<?> clazz : clazzes) { > + int modifiers = clazz.getModifiers(); > + if (!Modifier.isPublic(clazz.getModifiers()) || > + Modifier.isAbstract(modifiers)) { > + // Non-public or abstract - skip it. > + continue; > + } > // Protect against scanning the WebSocket API JARs > if (clazz.getName().startsWith(wsPackage)) { > continue; > @@ -68,14 +74,11 @@ public class WsSci implements ServletCon > serverApplicationConfigs.add( > (ServerApplicationConfig) clazz.newInstance()); > } > - if (ServerEndpointConfig.class.isAssignableFrom(clazz)) { > + if (Endpoint.class.isAssignableFrom(clazz)) { > @SuppressWarnings("unchecked") > - Class<? extends ServerEndpointConfig> configClazz = > - (Class<? extends ServerEndpointConfig>) clazz; > - ServerEndpointConfig config = configClazz.newInstance(); > - scannedEndpointConfigs.add(config); > - scannedEndpointClazzes.add( > - (Class<? extends Endpoint>) > config.getEndpointClass()); > + Class<? extends Endpoint> endpoint = > + (Class<? extends Endpoint>) clazz; > + scannedEndpointClazzes.add(endpoint); > } > if (clazz.isAnnotationPresent(ServerEndpoint.class)) { > scannedPojoEndpoints.add(clazz); > @@ -90,7 +93,6 @@ public class WsSci implements ServletCon > Set<Class<?>> filteredPojoEndpoints = new HashSet<>(); > > if (serverApplicationConfigs.isEmpty()) { > - filteredEndpointConfigs.addAll(scannedEndpointConfigs); > filteredPojoEndpoints.addAll(scannedPojoEndpoints); > } else { > for (ServerApplicationConfig config : serverApplicationConfigs) { > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org