rootNode.addInvoker(fullpath, invoker); } else { root.addInvoker(classExpression, fullpath, invoker); rootNode.addInvoker(fullpath, locator); } else { root.addInvoker(classExpression, fullpath, locator);
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 void addInvoker(String path, ResourceInvoker invoker) { MethodExpression expression = addExpression(path, invoker); size++; bounded.add(path, expression); } protected MethodExpression addExpression(String path, ResourceInvoker invoker)
private void removeRegistration(ResourceMethodRegistry rm, String path, Method method) { try { if (rm.isWiderMatching()) { RootNode rootNode = get(rm, "rootNode"); rootNode.removeBinding(path, method); } else { String methodpath = method.getAnnotation(Path.class).value(); String classExpression = path.replace(methodpath, ""); if (classExpression.endsWith("/")) { classExpression.substring(0, classExpression.length() - 1); } RootClassNode root = get(rm, "root"); root.removeBinding(classExpression, path, method); } } catch (Exception e) { LOGGER.error("Could not remove method registration from path {}, {}", e, path, method); } }
public ResourceInvoker match(HttpRequest request, int start) { return root.match(request, start).match(request, start); }
public Map<String, List<ResourceInvoker>> getBounded() { if (widerMatching) return rootNode.getBounded(); else return root.getBounded(); }
public int getSize() { int size = 0; for (ClassExpression exp : bounded.values()) { size += exp.getRoot().getSize(); } return size; }
private void removeRegistration(String base, Class<?> clazz) { for (Method method : clazz.getMethods()) { Path path = method.getAnnotation(Path.class); Set<String> httpMethods = IsHttpMethod.getHttpMethods(method); if (path == null && httpMethods == null) continue; ResteasyUriBuilder builder = new ResteasyUriBuilderImpl(); if (base != null) builder.path(base); if (clazz.isAnnotationPresent(Path.class)) builder.path(clazz); String classExpression = builder.getPath(); if (path != null) builder.path(method); String fullpath = builder.getPath(); if (fullpath == null) fullpath = ""; if (widerMatching) rootNode.removeBinding(fullpath, method); else root.removeBinding(classExpression, fullpath, method); } }
public ResourceInvoker getResourceInvoker(HttpRequest request) { try { String currentUri = ((ResteasyUriInfo)request.getUri()).getEncodedMatchedPaths().get(0); int startAt = currentUri.length(); return root.match(request, startAt); } catch (RuntimeException e) { throw e; } } }
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; }
/** * Number of endpoints registered. * * @return number of endpoints registered */ public int getSize() { if (widerMatching) return rootNode.getSize(); else return root.getSize(); }
rootNode.addInvoker(fullpath, invoker); } else { root.addInvoker(classExpression, fullpath, invoker); rootNode.addInvoker(fullpath, locator); } else { root.addInvoker(classExpression, fullpath, locator);
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); } }
@Override public void removeRegistrations(ResourceClass resourceClass) { for (ResourceMethod method : resourceClass.getResourceMethods()) { if (widerMatching) rootNode.removeBinding(method.getFullpath(), method.getMethod()); else root.removeBinding(resourceClass.getPath(), method.getFullpath(), method.getMethod()); } for (ResourceLocator method : resourceClass.getResourceLocators()) { if (widerMatching) rootNode.removeBinding(method.getFullpath(), method.getMethod()); else root.removeBinding(resourceClass.getPath(), method.getFullpath(), method.getMethod()); } }
/** * Find a resource to invoke on. * * @return resource invoker */ public ResourceInvoker getResourceInvoker(HttpRequest request) { RESTEasyTracingLogger tracingLogger = RESTEasyTracingLogger.getInstance(request); final long timestamp = tracingLogger.timestamp("MATCH_SUMMARY"); try { if (widerMatching) { return rootNode.match(request, 0); } else { return root.match(request, 0); } } catch (RuntimeException e) { throw e; } finally { tracingLogger.logDuration("MATCH_SUMMARY", timestamp); } } }
public Map<String, List<ResourceInvoker>> getBounded() { if (widerMatching) return rootNode.getBounded(); else return root.getBounded(); }
public int getSize() { int size = 0; for (ClassExpression exp : bounded.values()) { size += exp.getRoot().getSize(); } return size; }
public void addInvoker(String path, ResourceInvoker invoker) { MethodExpression expression = addExpression(path, invoker); size++; bounded.add(path, expression); } protected MethodExpression addExpression(String path, ResourceInvoker invoker)
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 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); } }