Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Last active October 13, 2016 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/4fce7f8fdbd159ab787448325f0e093c to your computer and use it in GitHub Desktop.
Save abhirockzz/4fce7f8fdbd159ab787448325f0e093c to your computer and use it in GitHub Desktop.
Custom ServerApplicationConfig implementation to deploy both Annotated and Programmatic WebSocket endpoints
public class HybridEndpointDeploymentStrategy implements ServerApplicationConfig {
@Override
public Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>> scanned) {
//return ALL the auto-detected (scanned) annotated endpoints which the container will deploy
return scanned;
}
@Override
public Set<ServerEndpointConfig> getEndpointConfigs(Set<Class<? extends Endpoint>> endpointClasses) {
Set<ServerEndpointConfig> result = new HashSet<>();
for (Class epClass : endpointClasses) {
//need to ignore Client endpoint class
if (epClass.equals(ChatBot.class)) {
ServerEndpointConfig sec = ServerEndpointConfig.Builder.create(epClass, "/chatclub").build();
result.add(sec);
}
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment