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); }
@Override public boolean matches(final String path) { int idx = path.indexOf('?'); if (idx >= 0) { // match only non-query part return getMatcher(path.substring(0,idx)).matches(); } else { // match entire path return getMatcher(path).matches(); } } }
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); }
@Override public boolean matches(final String path) { int idx = path.indexOf('?'); if (idx >= 0) { // match only non-query part return getMatcher(path.substring(0,idx)).matches(); } else { // match entire path return getMatcher(path).matches(); } } }
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); } }
@Override public boolean matches(final String path) { int idx = path.indexOf('?'); if (idx >= 0) { // match only non-query part return getMatcher(path.substring(0,idx)).matches(); } else { // match entire path return getMatcher(path).matches(); } } }
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); } }
@Override public boolean matches(final String path) { int idx = path.indexOf('?'); if (idx >= 0) { // match only non-query part return getMatcher(path.substring(0,idx)).matches(); } else { // match entire path return getMatcher(path).matches(); } } }
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 + "]"); }
@Override public String getPathMatch(String path) { Matcher matcher = getMatcher(path); if (matcher.matches()) { if (matcher.groupCount() >= 1) { int idx = matcher.start(1); if (idx > 0) { if (path.charAt(idx - 1) == '/') { idx--; } return path.substring(0,idx); } } return path; } return null; }
/** * 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()); } }
@Override public String getPathInfo(String path) { // Path Info only valid for PREFIX_GLOB types if (group == PathSpecGroup.PREFIX_GLOB) { Matcher matcher = getMatcher(path); if (matcher.matches()) { if (matcher.groupCount() >= 1) { String pathInfo = matcher.group(1); if ("".equals(pathInfo)) { return "/"; } else { return pathInfo; } } } } return null; }
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));
@Override public String getPathMatch(String path) { Matcher matcher = getMatcher(path); if (matcher.matches()) { if (matcher.groupCount() >= 1) { int idx = matcher.start(1); if (idx > 0) { if (path.charAt(idx - 1) == '/') { idx--; } return path.substring(0,idx); } } return path; } return null; }
new RegexPathSpec(WEBSOCKET_STDERR_UPDATES_PATTERN), new StderrUpdateSocketCreator(jobManager)); new RegexPathSpec(WEBSOCKET_STDOUT_UPDATES_PATTERN), new StdoutUpdateSocketCreator(jobManager));
@Override public String getPathInfo(String path) { // Path Info only valid for PREFIX_GLOB types if (group == PathSpecGroup.PREFIX_GLOB) { Matcher matcher = getMatcher(path); if (matcher.matches()) { if (matcher.groupCount() >= 1) { String pathInfo = matcher.group(1); if ("".equals(pathInfo)) { return "/"; } else { return pathInfo; } } } } return null; }
@Override public String getPathMatch(String path) { Matcher matcher = getMatcher(path); if (matcher.matches()) { if (matcher.groupCount() >= 1) { int idx = matcher.start(1); if (idx > 0) { if (path.charAt(idx - 1) == '/') { idx--; } return path.substring(0,idx); } } return path; } return null; }
@Override public String getPathInfo(String path) { // Path Info only valid for PREFIX_GLOB types if (group == PathSpecGroup.PREFIX_GLOB) { Matcher matcher = getMatcher(path); if (matcher.matches()) { if (matcher.groupCount() >= 1) { String pathInfo = matcher.group(1); if ("".equals(pathInfo)) { return "/"; } else { return pathInfo; } } } } return null; }
@Override public String getPathMatch(String path) { Matcher matcher = getMatcher(path); if (matcher.matches()) { if (matcher.groupCount() >= 1) { int idx = matcher.start(1); if (idx > 0) { if (path.charAt(idx - 1) == '/') { idx--; } return path.substring(0,idx); } } return path; } return null; }
@Override public String getPathInfo(String path) { // Path Info only valid for PREFIX_GLOB types if (group == PathSpecGroup.PREFIX_GLOB) { Matcher matcher = getMatcher(path); if (matcher.matches()) { if (matcher.groupCount() >= 1) { String pathInfo = matcher.group(1); if ("".equals(pathInfo)) { return "/"; } else { return pathInfo; } } } } return null; }