Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2013-09-06 19:28:33 +0000
committerJoakim Erdfelt2013-09-06 19:28:33 +0000
commit714bbf943ae6c0d34c8d341efbdc61afec6d5e71 (patch)
tree1ab77bd27e2d09daf7510bba74a9f05cdb38fac8
parent9008210c2e2f10d61389e2e6b873093aade3e0df (diff)
downloadorg.eclipse.jetty.project-714bbf943ae6c0d34c8d341efbdc61afec6d5e71.tar.gz
org.eclipse.jetty.project-714bbf943ae6c0d34c8d341efbdc61afec6d5e71.tar.xz
org.eclipse.jetty.project-714bbf943ae6c0d34c8d341efbdc61afec6d5e71.zip
Removing @ServerEndpoint caching, its just getting in the way
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java81
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/SimpleServerEndpointMetadata.java14
2 files changed, 47 insertions, 48 deletions
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java
index 45cfd12f32..2e58bcf637 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java
@@ -18,8 +18,6 @@
package org.eclipse.jetty.websocket.jsr356.server;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
import javax.websocket.DeploymentException;
import javax.websocket.Endpoint;
import javax.websocket.server.ServerEndpoint;
@@ -44,7 +42,6 @@ public class ServerContainer extends ClientContainer implements javax.websocket.
private final MappedWebSocketCreator mappedCreator;
private final WebSocketServerFactory webSocketServerFactory;
- private final Map<Class<?>, ServerEndpointMetadata> endpointServerMetadataCache = new ConcurrentHashMap<>();
public ServerContainer(MappedWebSocketCreator creator, WebSocketServerFactory factory)
{
@@ -57,13 +54,6 @@ public class ServerContainer extends ClientContainer implements javax.websocket.
this.webSocketServerFactory.addSessionFactory(new JsrSessionFactory(this));
}
- @Override
- protected void doStop() throws Exception
- {
- endpointServerMetadataCache.clear();
- super.doStop();
- }
-
public EndpointInstance newClientEndpointInstance(Object endpoint, ServerEndpointConfig config, String path)
{
EndpointMetadata metadata = getClientEndpointMetadata(endpoint.getClass());
@@ -98,51 +88,46 @@ public class ServerContainer extends ClientContainer implements javax.websocket.
@Override
public void addEndpoint(ServerEndpointConfig config) throws DeploymentException
{
- LOG.debug("addEndpoint({})",config);
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("addEndpoint({}) path={} endpoint={}",config,config.getPath(),config.getEndpointClass());
+ LOG.debug("Occurred from stack",new Throwable("stack"));
+ }
ServerEndpointMetadata metadata = getServerEndpointMetadata(config.getEndpointClass(),config);
addEndpoint(metadata);
}
- public ServerEndpointMetadata getServerEndpointMetadata(Class<?> endpoint, ServerEndpointConfig config) throws DeploymentException
+ public ServerEndpointMetadata getServerEndpointMetadata(final Class<?> endpoint, final ServerEndpointConfig config) throws DeploymentException
{
- synchronized (endpointServerMetadataCache)
- {
- ServerEndpointMetadata metadata = endpointServerMetadataCache.get(endpoint);
- if (metadata != null)
- {
- return metadata;
- }
-
- ServerEndpoint anno = endpoint.getAnnotation(ServerEndpoint.class);
- if (anno != null)
- {
- // Annotated takes precedence here
- AnnotatedServerEndpointMetadata ametadata = new AnnotatedServerEndpointMetadata(endpoint,config);
- AnnotatedEndpointScanner<ServerEndpoint,ServerEndpointConfig> scanner = new AnnotatedEndpointScanner<>(ametadata);
- metadata = ametadata;
- scanner.scan();
- }
- else if (Endpoint.class.isAssignableFrom(endpoint))
- {
- // extends Endpoint
- @SuppressWarnings("unchecked")
- Class<? extends Endpoint> eendpoint = (Class<? extends Endpoint>)endpoint;
- metadata = new SimpleServerEndpointMetadata(eendpoint,config);
- }
- else
- {
- StringBuilder err = new StringBuilder();
- err.append("Not a recognized websocket [");
- err.append(endpoint.getName());
- err.append("] does not extend @").append(ServerEndpoint.class.getName());
- err.append(" or extend from ").append(Endpoint.class.getName());
- throw new DeploymentException("Unable to identify as valid Endpoint: " + endpoint);
- }
-
- endpointServerMetadataCache.put(endpoint,metadata);
+ ServerEndpointMetadata metadata = null;
- return metadata;
+ ServerEndpoint anno = endpoint.getAnnotation(ServerEndpoint.class);
+ if (anno != null)
+ {
+ // Annotated takes precedence here
+ AnnotatedServerEndpointMetadata ametadata = new AnnotatedServerEndpointMetadata(endpoint,config);
+ AnnotatedEndpointScanner<ServerEndpoint, ServerEndpointConfig> scanner = new AnnotatedEndpointScanner<>(ametadata);
+ metadata = ametadata;
+ scanner.scan();
+ }
+ else if (Endpoint.class.isAssignableFrom(endpoint))
+ {
+ // extends Endpoint
+ @SuppressWarnings("unchecked")
+ Class<? extends Endpoint> eendpoint = (Class<? extends Endpoint>)endpoint;
+ metadata = new SimpleServerEndpointMetadata(eendpoint,config);
}
+ else
+ {
+ StringBuilder err = new StringBuilder();
+ err.append("Not a recognized websocket [");
+ err.append(endpoint.getName());
+ err.append("] does not extend @").append(ServerEndpoint.class.getName());
+ err.append(" or extend from ").append(Endpoint.class.getName());
+ throw new DeploymentException("Unable to identify as valid Endpoint: " + endpoint);
+ }
+
+ return metadata;
}
@Override
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/SimpleServerEndpointMetadata.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/SimpleServerEndpointMetadata.java
index 5864268d7c..ced82468ca 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/SimpleServerEndpointMetadata.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/SimpleServerEndpointMetadata.java
@@ -49,4 +49,18 @@ public class SimpleServerEndpointMetadata extends SimpleEndpointMetadata impleme
{
return config.getPath();
}
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SimpleServerEndpointMetadata [");
+ builder.append("config=").append(config.getClass().getName());
+ builder.append(",path=").append(config.getPath());
+ builder.append(",endpoint=").append(config.getEndpointClass());
+ builder.append(",decoders=").append(config.getDecoders());
+ builder.append(",encoders=").append(config.getEncoders());
+ builder.append("]");
+ return builder.toString();
+ }
}

Back to the top