for (String path : webSocketHandlers.keySet()) { WebSocketCreator webSocketCreator = WebSocketCreatorFactory.create(webSocketHandlers.get(path)); webSocketConfiguration.addMapping(new ServletPathSpec(path), webSocketCreator);
public static PathSpec asPathSpec(String pathSpecString) { if ((pathSpecString == null) || (pathSpecString.length() < 1)) { throw new RuntimeException("Path Spec String must start with '^', '/', or '*.': got [" + pathSpecString + "]"); } return pathSpecString.charAt(0) == '^' ? new RegexPathSpec(pathSpecString):new ServletPathSpec(pathSpecString); }
public static PathSpec asPathSpec(String pathSpecString) { if ((pathSpecString == null) || (pathSpecString.length() < 1)) { throw new RuntimeException("Path Spec String must start with '^', '/', or '*.': got [" + pathSpecString + "]"); } return pathSpecString.charAt(0) == '^' ? new RegexPathSpec(pathSpecString):new ServletPathSpec(pathSpecString); }
private PathSpec toPathSpec(String rawSpec) { if ((rawSpec == null) || (rawSpec.length() < 1)) { throw new RuntimeException("Path Spec String must start with '^', '/', or '*.': got [" + rawSpec + "]"); } if (rawSpec.charAt(0) == '^') { return new RegexPathSpec(rawSpec); } else { return new ServletPathSpec(rawSpec); } }
private PathSpec toPathSpec(String rawSpec) { if ((rawSpec == null) || (rawSpec.length() < 1)) { throw new RuntimeException("Path Spec String must start with '^', '/', or '*.': got [" + rawSpec + "]"); } if (rawSpec.charAt(0) == '^') { return new RegexPathSpec(rawSpec); } else { return new ServletPathSpec(rawSpec); } }
private PathSpec toPathSpec(String rawspec) { // Determine what kind of path spec we are working with if (rawspec.charAt(0) == '/' || rawspec.startsWith("*.") || rawspec.startsWith("servlet|")) { return new ServletPathSpec(rawspec); } else if (rawspec.charAt(0) == '^' || rawspec.startsWith("regex|")) { return new RegexPathSpec(rawspec); } else if (rawspec.startsWith("uri-template|")) { return new UriTemplatePathSpec(rawspec.substring("uri-template|".length())); } // TODO: add ability to load arbitrary jetty-http PathSpec implementation // TODO: perhaps via "fully.qualified.class.name|spec" style syntax throw new IllegalArgumentException("Unrecognized path spec syntax [" + rawspec + "]"); }
filter.addMapping(new ServletPathSpec("/foo/*"),new SingleWebSocketCreator(FooSocket.class)); filter.addMapping(new ServletPathSpec("/bar/*"),new SingleWebSocketCreator(BarSocket.class)); filter.addMapping(new ServletPathSpec("/*.ws"),new SingleWebSocketCreator(WsTypeSocket.class)); filter.addMapping(new RegexPathSpec("/chat/room/[a-zA-z_]*/public"),new SingleWebSocketCreator(ChatSocket.class));
/** * Manually add a WebSocket mapping. * * @param spec the pathspec to respond on * @param creator the websocket creator to activate on the provided mapping * @deprecated use {@link #addMapping(PathSpec, WebSocketCreator)} instead. */ @Deprecated public void addMapping(org.eclipse.jetty.websocket.server.pathmap.PathSpec spec, WebSocketCreator creator) { if (spec instanceof org.eclipse.jetty.websocket.server.pathmap.ServletPathSpec) { addMapping(new ServletPathSpec(spec.getSpec()), creator); } else if (spec instanceof org.eclipse.jetty.websocket.server.pathmap.RegexPathSpec) { addMapping(new RegexPathSpec(spec.getSpec()), creator); } else { throw new RuntimeException("Unsupported (Deprecated) PathSpec implementation type: " + spec.getClass().getName()); } }
wsfilter.addMapping(new ServletPathSpec("/time/"), new TimeSocketCreator());
for (String path : webSocketHandlers.keySet()) { WebSocketCreator webSocketCreator = WebSocketCreatorFactory.create(webSocketHandlers.get(path)); webSocketConfiguration.addMapping(new ServletPathSpec(path), webSocketCreator);
pm.put(new ServletPathSpec(pathSpec),_servletNameMap.get(finalMapping.getServletName()));