use of javax.websocket.server.ServerEndpoint in project wildfly by wildfly.
the class UndertowJSRWebSocketDeploymentProcessor method doDeployment.
private void doDeployment(DeploymentUnit deploymentUnit, final WebSocketDeploymentInfo container, final Set<Class<?>> annotatedEndpoints, final Set<Class<? extends ServerApplicationConfig>> serverApplicationConfigClasses, final Set<Class<? extends Endpoint>> endpoints) throws DeploymentUnitProcessingException {
Set<Class<? extends Endpoint>> allScannedEndpointImplementations = new HashSet<>(endpoints);
Set<Class<?>> allScannedAnnotatedEndpoints = new HashSet<>(annotatedEndpoints);
Set<Class<?>> newAnnotatatedEndpoints = new HashSet<>();
Set<ServerEndpointConfig> serverEndpointConfigurations = new HashSet<>();
final Set<ServerApplicationConfig> configInstances = new HashSet<>();
for (Class<? extends ServerApplicationConfig> clazz : serverApplicationConfigClasses) {
try {
configInstances.add(clazz.newInstance());
} catch (InstantiationException | IllegalAccessException e) {
JsrWebSocketLogger.ROOT_LOGGER.couldNotInitializeConfiguration(clazz, e);
}
}
if (!configInstances.isEmpty()) {
for (ServerApplicationConfig config : configInstances) {
Set<Class<?>> returnedEndpoints = config.getAnnotatedEndpointClasses(allScannedAnnotatedEndpoints);
if (returnedEndpoints != null) {
newAnnotatatedEndpoints.addAll(returnedEndpoints);
}
Set<ServerEndpointConfig> endpointConfigs = config.getEndpointConfigs(allScannedEndpointImplementations);
if (endpointConfigs != null) {
serverEndpointConfigurations.addAll(endpointConfigs);
}
}
} else {
newAnnotatatedEndpoints.addAll(allScannedAnnotatedEndpoints);
}
//annotated endpoints first
for (Class<?> endpoint : newAnnotatatedEndpoints) {
if (endpoint != null) {
container.addEndpoint(endpoint);
ServerEndpoint annotation = endpoint.getAnnotation(ServerEndpoint.class);
if (annotation != null) {
String path = annotation.value();
addManagementWebsocket(deploymentUnit, endpoint, path);
}
}
}
for (final ServerEndpointConfig endpoint : serverEndpointConfigurations) {
if (endpoint != null) {
container.addEndpoint(endpoint);
addManagementWebsocket(deploymentUnit, endpoint.getEndpointClass(), endpoint.getPath());
}
}
}
Aggregations