use of javax.websocket.server.ServerEndpointConfig in project tomcat70 by apache.
the class TestWsServerContainer method testDuplicatePaths_03.
@Test(expected = javax.websocket.DeploymentException.class)
public void testDuplicatePaths_03() throws Exception {
WsServerContainer sc = new WsServerContainer(new TesterServletContext());
ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(Object.class, "/a/b/{var1}").build();
ServerEndpointConfig configB = ServerEndpointConfig.Builder.create(Object.class, "/a/b/{var2}").build();
sc.addEndpoint(configA);
sc.addEndpoint(configB);
}
use of javax.websocket.server.ServerEndpointConfig in project tomcat70 by apache.
the class TestWsServerContainer method testSpecExample4.
@Test
public void testSpecExample4() throws Exception {
WsServerContainer sc = new WsServerContainer(new TesterServletContext());
ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(Object.class, "/{var1}/d").build();
ServerEndpointConfig configB = ServerEndpointConfig.Builder.create(Object.class, "/b/{var2}").build();
sc.addEndpoint(configA);
sc.addEndpoint(configB);
Assert.assertEquals(configB, sc.findMapping("/b/d").getConfig());
}
use of javax.websocket.server.ServerEndpointConfig in project tomcat70 by apache.
the class TestWsServerContainer method testDuplicatePaths_04.
@Test
public void testDuplicatePaths_04() throws Exception {
WsServerContainer sc = new WsServerContainer(new TesterServletContext());
ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(Object.class, "/a/{var1}/{var2}").build();
ServerEndpointConfig configB = ServerEndpointConfig.Builder.create(Object.class, "/a/b/{var2}").build();
sc.addEndpoint(configA);
sc.addEndpoint(configB);
Assert.assertEquals(configA, sc.findMapping("/a/x/y").getConfig());
Assert.assertEquals(configB, sc.findMapping("/a/b/y").getConfig());
}
use of javax.websocket.server.ServerEndpointConfig in project minijax by minijax.
the class MinijaxWebSocketUtils method init.
public static void init(final DeploymentInfo deploymentInfo, final MinijaxApplication application) {
final WebSocketDeploymentInfo webSockets = new WebSocketDeploymentInfo();
for (final Class<?> endpoint : application.getWebSockets()) {
final ServerEndpoint serverEndpoint = endpoint.getAnnotation(ServerEndpoint.class);
final MinijaxWebSocketConfigurator configurator = new MinijaxWebSocketConfigurator(application, endpoint);
final ServerEndpointConfig endpointConfig = ServerEndpointConfig.Builder.create(AnnotatedEndpoint.class, serverEndpoint.value()).configurator(configurator).build();
webSockets.addEndpoint(endpointConfig);
}
deploymentInfo.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, webSockets);
}
use of javax.websocket.server.ServerEndpointConfig 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