use of jakarta.websocket.server.ServerEndpointConfig in project tomcat by apache.
the class PojoEndpointServer method onOpen.
@Override
public void onOpen(Session session, EndpointConfig endpointConfig) {
ServerEndpointConfig sec = (ServerEndpointConfig) endpointConfig;
PojoMethodMapping methodMapping = (PojoMethodMapping) sec.getUserProperties().get(Constants.POJO_METHOD_MAPPING_KEY);
setMethodMapping(methodMapping);
doOnOpen(session, endpointConfig);
}
use of jakarta.websocket.server.ServerEndpointConfig in project tomcat by apache.
the class WsServerContainer method findMapping.
public WsMappingResult findMapping(String path) {
// been made to use one
if (addAllowed) {
addAllowed = false;
}
// Check an exact match. Simple case as there are no templates.
ExactPathMatch match = configExactMatchMap.get(path);
if (match != null) {
return new WsMappingResult(match.getConfig(), Collections.<String, String>emptyMap());
}
// No exact match. Need to look for template matches.
UriTemplate pathUriTemplate = null;
try {
pathUriTemplate = new UriTemplate(path);
} catch (DeploymentException e) {
// Path is not valid so can't be matched to a WebSocketEndpoint
return null;
}
// Number of segments has to match
Integer key = Integer.valueOf(pathUriTemplate.getSegmentCount());
ConcurrentSkipListMap<String, TemplatePathMatch> templateMatches = configTemplateMatchMap.get(key);
if (templateMatches == null) {
// no matches
return null;
}
// List is in alphabetical order of normalised templates.
// Correct match is the first one that matches.
ServerEndpointConfig sec = null;
Map<String, String> pathParams = null;
for (TemplatePathMatch templateMatch : templateMatches.values()) {
pathParams = templateMatch.getUriTemplate().match(pathUriTemplate);
if (pathParams != null) {
sec = templateMatch.getConfig();
break;
}
}
if (sec == null) {
// No match
return null;
}
return new WsMappingResult(sec, pathParams);
}
use of jakarta.websocket.server.ServerEndpointConfig in project tomcat by apache.
the class TestWsServerContainer method testDuplicatePaths13.
/*
* POJO programmatic followed by programmatic duplicate.
*/
@Test(expected = DeploymentException.class)
public void testDuplicatePaths13() throws Exception {
WsServerContainer sc = new WsServerContainer(new TesterServletContext());
ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(Pojo.class, "/foo").build();
sc.addEndpoint(Pojo.class);
sc.addEndpoint(configA);
}
use of jakarta.websocket.server.ServerEndpointConfig in project tomcat by apache.
the class TestWsServerContainer method testDuplicatePaths01.
@Test(expected = DeploymentException.class)
public void testDuplicatePaths01() throws Exception {
WsServerContainer sc = new WsServerContainer(new TesterServletContext());
ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(Object.class, "/a/b/c").build();
ServerEndpointConfig configB = ServerEndpointConfig.Builder.create(Object.class, "/a/b/c").build();
sc.addEndpoint(configA);
sc.addEndpoint(configB);
}
use of jakarta.websocket.server.ServerEndpointConfig in project tomcat by apache.
the class TestWsServerContainer method testDuplicatePaths03.
@Test(expected = DeploymentException.class)
public void testDuplicatePaths03() 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);
}
Aggregations