@Override public void register(Class<?> endpointClass, String contextPath) throws DeploymentException { final ErrorCollector collector = new ErrorCollector(); AnnotatedEndpoint endpoint = AnnotatedEndpoint.fromClass(endpointClass, componentProviderService, true, collector); EndpointConfig config = endpoint.getEndpointConfig(); TyrusEndpointWrapper ew = new TyrusEndpointWrapper( endpoint, config, componentProviderService, webSocketContainer, contextPath, config instanceof ServerEndpointConfig ? ((ServerEndpointConfig) config).getConfigurator() : null); if (collector.isEmpty()) { register(new TyrusEndpoint(ew)); } else { throw collector.composeComprehensiveException(); } }
@Override public void register(ServerEndpointConfig serverConfig, String contextPath) throws DeploymentException { TyrusEndpointWrapper ew; Class<?> endpointClass = serverConfig.getEndpointClass(); boolean isEndpointClass = false; do { endpointClass = endpointClass.getSuperclass(); if (endpointClass.equals(Endpoint.class)) { isEndpointClass = true; } } while (!endpointClass.equals(Object.class)); if (isEndpointClass) { // we are pretty sure that endpoint class is javax.websocket.Endpoint descendant. //noinspection unchecked ew = new TyrusEndpointWrapper( (Class<? extends Endpoint>) serverConfig.getEndpointClass(), serverConfig, componentProviderService, webSocketContainer, contextPath, serverConfig.getConfigurator()); } else { final ErrorCollector collector = new ErrorCollector(); final AnnotatedEndpoint endpoint = AnnotatedEndpoint.fromClass( serverConfig.getEndpointClass(), componentProviderService, true, collector); final EndpointConfig config = endpoint.getEndpointConfig(); ew = new TyrusEndpointWrapper( endpoint, config, componentProviderService, webSocketContainer, contextPath, config instanceof ServerEndpointConfig ? ((ServerEndpointConfig) config).getConfigurator() : null); if (!collector.isEmpty()) { throw collector.composeComprehensiveException(); } } register(new TyrusEndpoint(ew)); }