public void removeBinding(String classExpression, String path, Method method) { if (classExpression.startsWith("/")) classExpression = classExpression.substring(1); if (classExpression.endsWith("/")) classExpression = classExpression.substring(0, classExpression.length() - 1); String regex = new ClassExpression(classExpression).getRegex(); ClassExpression ce = bounded.get(regex); if (ce == null) return; ce.getRoot().removeBinding(path, method); if (ce.getRoot().getSize() == 0) { ce.getParent().targets.remove(ce); bounded.remove(regex); } }
Pattern pattern = expression.getPattern(); Matcher matcher = pattern.matcher(path); matcher.region(start, path.length()); int length = matcher.start(expression.getNumGroups() + 1); if (length == -1) logger.log("MATCH_RUNTIME_RESOURCE", expression, expression.getRegex(), expression.getRoot().root, expression.getPathExpression()); return expression.getRoot();
public void addInvoker(String classExpression, String fullpath, ResourceInvoker invoker) { if (classExpression.startsWith("/")) classExpression = classExpression.substring(1); if (classExpression.endsWith("/")) classExpression = classExpression.substring(0, classExpression.length() - 1); ClassExpression newce = new ClassExpression(classExpression); String regex = newce.getRegex(); ClassExpression existing = bounded.get(regex); if (existing == null) { newce.getRoot().addInvoker(fullpath, invoker); addExpression(classExpression, newce); bounded.put(regex, newce); } else { existing.getRoot().addInvoker(fullpath, invoker); } } protected void addExpression(String path, ClassExpression ce)
public RootNode match(HttpRequest request, int start) { String path = request.getUri().getMatchingPath(); if (start < path.length() && path.charAt(start) == '/') start++; List<ClassExpression> potentials = new ArrayList<ClassExpression>(); potentials(path, start, potentials); Collections.sort(potentials); for (ClassExpression expression : potentials) { Pattern pattern = expression.getPattern(); Matcher matcher = pattern.matcher(path); matcher.region(start, path.length()); if (matcher.matches()) { ResteasyUriInfo uriInfo = request.getUri(); int length = matcher.start(expression.getNumGroups() + 1); if (length == -1) { uriInfo.pushMatchedURI(path); } else { String substring = path.substring(0, length); uriInfo.pushMatchedURI(substring); } return expression.getRoot(); } } throw new NotFoundException(Messages.MESSAGES.couldNotFindResourceForFullPath(request.getUri().getRequestUri())); }
public int getSize() { int size = 0; for (ClassExpression exp : bounded.values()) { size += exp.getRoot().getSize(); } return size; }
public void addInvoker(String classExpression, String fullpath, ResourceInvoker invoker) { if (classExpression.startsWith("/")) classExpression = classExpression.substring(1); if (classExpression.endsWith("/")) classExpression = classExpression.substring(0, classExpression.length() - 1); ClassExpression newce = new ClassExpression(classExpression); String regex = newce.getRegex(); ClassExpression existing = bounded.get(regex); if (existing == null) { newce.getRoot().addInvoker(fullpath, invoker); addExpression(classExpression, newce); bounded.put(regex, newce); } else { existing.getRoot().addInvoker(fullpath, invoker); } } protected void addExpression(String path, ClassExpression ce)
public Map<String, List<ResourceInvoker>> getBounded() { MultivaluedMap<String, ResourceInvoker> invokers = new MultivaluedHashMap<String, ResourceInvoker>(); for (ClassExpression exp : bounded.values()) { MultivaluedMap<String, ResourceInvoker> expBounded = exp.getRoot().getBounded(); for (MultivaluedMap.Entry<String, List<ResourceInvoker>> entry : expBounded.entrySet()) { invokers.addAll(entry.getKey(), entry.getValue()); } } return invokers; }
public void removeBinding(String classExpression, String path, Method method) { if (classExpression.startsWith("/")) classExpression = classExpression.substring(1); if (classExpression.endsWith("/")) classExpression = classExpression.substring(0, classExpression.length() - 1); String regex = new ClassExpression(classExpression).getRegex(); ClassExpression ce = bounded.get(regex); if (ce == null) return; ce.getRoot().removeBinding(path, method); if (ce.getRoot().getSize() == 0) { ce.getParent().targets.remove(ce); bounded.remove(regex); } }
Pattern pattern = expression.getPattern(); Matcher matcher = pattern.matcher(path); matcher.region(start, path.length()); int length = matcher.start(expression.getNumGroups() + 1); if (length == -1) logger.log("MATCH_RUNTIME_RESOURCE", expression, expression.getRegex(), expression.getRoot().root, expression.getPathExpression()); return expression.getRoot();
public void addInvoker(String classExpression, String fullpath, ResourceInvoker invoker) { if (classExpression.startsWith("/")) classExpression = classExpression.substring(1); if (classExpression.endsWith("/")) classExpression = classExpression.substring(0, classExpression.length() - 1); ClassExpression newce = new ClassExpression(classExpression); String regex = newce.getRegex(); ClassExpression existing = bounded.get(regex); if (existing == null) { newce.getRoot().addInvoker(fullpath, invoker); addExpression(classExpression, newce); bounded.put(regex, newce); } else { existing.getRoot().addInvoker(fullpath, invoker); } } protected void addExpression(String path, ClassExpression ce)
public int getSize() { int size = 0; for (ClassExpression exp : bounded.values()) { size += exp.getRoot().getSize(); } return size; }
public void removeBinding(String classExpression, String path, Method method) { if (classExpression.startsWith("/")) classExpression = classExpression.substring(1); if (classExpression.endsWith("/")) classExpression = classExpression.substring(0, classExpression.length() - 1); String regex = new ClassExpression(classExpression).getRegex(); ClassExpression ce = bounded.get(regex); if (ce == null) return; ce.getRoot().removeBinding(path, method); if (ce.getRoot().getSize() == 0) { ce.getParent().targets.remove(ce); bounded.remove(regex); } }
public int getSize() { int size = 0; for (ClassExpression exp : bounded.values()) { size += exp.getRoot().getSize(); } return size; }
public Map<String, List<ResourceInvoker>> getBounded() { MultivaluedMap<String, ResourceInvoker> invokers = new MultivaluedHashMap<String, ResourceInvoker>(); for (ClassExpression exp : bounded.values()) { MultivaluedMap<String, ResourceInvoker> expBounded = exp.getRoot().getBounded(); for (MultivaluedMap.Entry<String, List<ResourceInvoker>> entry : expBounded.entrySet()) { invokers.addAll(entry.getKey(), entry.getValue()); } } return invokers; }
public Map<String, List<ResourceInvoker>> getBounded() { MultivaluedMap<String, ResourceInvoker> invokers = new MultivaluedHashMap<String, ResourceInvoker>(); for (ClassExpression exp : bounded.values()) { MultivaluedMap<String, ResourceInvoker> expBounded = exp.getRoot().getBounded(); for (MultivaluedMap.Entry<String, List<ResourceInvoker>> entry : expBounded.entrySet()) { invokers.addAll(entry.getKey(), entry.getValue()); } } return invokers; }