/** * Create a new builder. * * @param resource Resource for which the instance is created. */ Builder(final Resource resource, final ResourceMethodStatisticsImpl.Factory methodFactory) { this(methodFactory); for (final ResourceMethod method : resource.getResourceMethods()) { getOrCreate(method); } }
/** * Create a new builder. * * @param resource Resource for which the instance is created. */ Builder(final Resource resource, final ResourceMethodStatisticsImpl.Factory methodFactory) { this(methodFactory); for (final ResourceMethod method : resource.getResourceMethods()) { getOrCreate(method); } }
/** * Provides resource methods and resource locator are available on the resource. The list is ordered so that resource * methods are positioned first before resource locator. * * @return List of resource methods and resource locator. */ public List<ResourceMethod> getAllMethods() { final LinkedList<ResourceMethod> methodsAndLocators = new LinkedList<>(getResourceMethods()); final ResourceMethod loc = getResourceLocator(); if (loc != null) { methodsAndLocators.add(loc); } return methodsAndLocators; }
/** * Provides resource methods and resource locator are available on the resource. The list is ordered so that resource * methods are positioned first before resource locator. * * @return List of resource methods and resource locator. */ public List<ResourceMethod> getAllMethods() { final LinkedList<ResourceMethod> methodsAndLocators = new LinkedList<>(getResourceMethods()); final ResourceMethod loc = getResourceLocator(); if (loc != null) { methodsAndLocators.add(loc); } return methodsAndLocators; }
@Override public List<? extends ResourceModelComponent> getComponents() { List<ResourceModelComponent> components = new LinkedList<>(); components.addAll(getChildResources()); components.addAll(getResourceMethods()); final ResourceMethod resourceLocator = getResourceLocator(); if (resourceLocator != null) { components.add(resourceLocator); } return components; } }
@Override public List<? extends ResourceModelComponent> getComponents() { List<ResourceModelComponent> components = new LinkedList<>(); components.addAll(getChildResources()); components.addAll(getResourceMethods()); final ResourceMethod resourceLocator = getResourceLocator(); if (resourceLocator != null) { components.add(resourceLocator); } return components; } }
private void processResource(final Resource resource, final String pathPrefix) { final StringBuilder pathSB = new StringBuilder(pathPrefix); if (!pathPrefix.endsWith("/") && !resource.getPath().startsWith("/")) { pathSB.append("/"); } pathSB.append(resource.getPath()); uriStatistics.put(pathSB.toString(), new ResourceStatisticsImpl.Builder(resource, methodFactory)); for (final ResourceMethod resourceMethod : resource.getResourceMethods()) { getOrCreateResourceBuilder(resourceMethod).addMethod(resourceMethod); } }
private void processResource(final Resource resource, final String pathPrefix) { final StringBuilder pathSB = new StringBuilder(pathPrefix); if (!pathPrefix.endsWith("/") && !resource.getPath().startsWith("/")) { pathSB.append("/"); } pathSB.append(resource.getPath()); uriStatistics.put(pathSB.toString(), new ResourceStatisticsImpl.Builder(resource, methodFactory)); for (final ResourceMethod resourceMethod : resource.getResourceMethods()) { getOrCreateResourceBuilder(resourceMethod).addMethod(resourceMethod); } }
/** * Determines whether the given methods can enhance the resource. * * @param resource resource to add the methods to. * @param methods methods to add. * @return {@code true} if methods can enhance the resource, {@code false} otherwise. */ private static boolean methodsSuitableForResource(final Resource resource, final List<Method> methods) { if (!resource.getResourceMethods().isEmpty()) { return true; } // If there are no handler classes/instances we want to add only non-HEAD / non-OPTIONS methods. if (resource.getHandlerInstances().isEmpty() && resource.getHandlerClasses().isEmpty()) { for (final Method method : methods) { if (!HttpMethod.HEAD.equals(method.httpMethod) && !HttpMethod.OPTIONS.equals(method.httpMethod)) { return true; } } } return false; } }
/** * Determines whether the given methods can enhance the resource. * * @param resource resource to add the methods to. * @param methods methods to add. * @return {@code true} if methods can enhance the resource, {@code false} otherwise. */ private static boolean methodsSuitableForResource(final Resource resource, final List<Method> methods) { if (!resource.getResourceMethods().isEmpty()) { return true; } // If there are no handler classes/instances we want to add only non-HEAD / non-OPTIONS methods. if (resource.getHandlerInstances().isEmpty() && resource.getHandlerClasses().isEmpty()) { for (final Method method : methods) { if (!HttpMethod.HEAD.equals(method.httpMethod) && !HttpMethod.OPTIONS.equals(method.httpMethod)) { return true; } } } return false; } }
private RuntimeResource(List<Resource> resources, List<Builder> childRuntimeResourceBuilders, RuntimeResource parent, String regex) { this.parent = parent; this.pathPattern = resources.get(0).getPathPattern(); this.resources = new ArrayList<>(resources); this.regex = regex; this.resourceMethods = new ArrayList<>(); this.resourceLocators = new ArrayList<>(); this.childRuntimeResources = new ArrayList<>(); for (Builder childRuntimeResourceBuilder : childRuntimeResourceBuilders) { this.childRuntimeResources.add(childRuntimeResourceBuilder.build(this)); } Collections.sort(this.childRuntimeResources, COMPARATOR); for (final Resource res : this.resources) { this.resourceMethods.addAll(res.getResourceMethods()); final ResourceMethod resourceLocator = res.getResourceLocator(); if (resourceLocator != null) { this.resourceLocators.add(resourceLocator); } } }
private RuntimeResource(List<Resource> resources, List<Builder> childRuntimeResourceBuilders, RuntimeResource parent, String regex) { this.parent = parent; this.pathPattern = resources.get(0).getPathPattern(); this.resources = new ArrayList<>(resources); this.regex = regex; this.resourceMethods = new ArrayList<>(); this.resourceLocators = new ArrayList<>(); this.childRuntimeResources = new ArrayList<>(); for (Builder childRuntimeResourceBuilder : childRuntimeResourceBuilders) { this.childRuntimeResources.add(childRuntimeResourceBuilder.build(this)); } Collections.sort(this.childRuntimeResources, COMPARATOR); for (final Resource res : this.resources) { this.resourceMethods.addAll(res.getResourceMethods()); final ResourceMethod resourceLocator = res.getResourceLocator(); if (resourceLocator != null) { this.resourceLocators.add(resourceLocator); } } }
private void checkResources(List<Resource> resources) { for (ResourceMethod method : resource.getResourceMethods()) { final Method m = method.getInvocable().getDefinitionMethod();
private void checkResource(final Resource resource) { if (!resource.getResourceMethods().isEmpty() && resource.getResourceLocator() != null) { Errors.warning(resource, LocalizationMessages.RESOURCE_CONTAINS_RES_METHODS_AND_LOCATOR(resource, resource.getPath())); } if (resource.getPath() != null && resource.getResourceMethods().isEmpty() && resource.getChildResources().isEmpty() && resource.getResourceLocator() == null) { Errors.warning(resource, LocalizationMessages.RESOURCE_EMPTY(resource, resource.getPath())); } }
private void checkResource(final Resource resource) { if (!resource.getResourceMethods().isEmpty() && resource.getResourceLocator() != null) { Errors.warning(resource, LocalizationMessages.RESOURCE_CONTAINS_RES_METHODS_AND_LOCATOR(resource, resource.getPath())); } if (resource.getPath() != null && resource.getResourceMethods().isEmpty() && resource.getChildResources().isEmpty() && resource.getResourceLocator() == null) { Errors.warning(resource, LocalizationMessages.RESOURCE_EMPTY(resource, resource.getPath())); } }
private List<MethodRouting> createResourceMethodRouters( final RuntimeResource runtimeResource, final boolean subResourceMode) { final List<MethodRouting> methodRoutings = new ArrayList<>(); int i = 0; for (final Resource resource : runtimeResource.getResources()) { final Resource parentResource = runtimeResource.getParent() == null ? null : runtimeResource.getParentResources().get(i++); final UriTemplate template = resource.getPathPattern().getTemplate(); final PushMatchedTemplateRouter templateRouter = parentResource == null ? getTemplateRouter(subResourceMode, template, null) : getTemplateRouter(subResourceMode, parentResource.getPathPattern().getTemplate(), template); for (final ResourceMethod resourceMethod : resource.getResourceMethods()) { methodRoutings.add(new MethodRouting(resourceMethod, templateRouter, new PushMatchedMethodRouter(resourceMethod), createMethodRouter(resourceMethod))); } } return methodRoutings.isEmpty() ? Collections.emptyList() : methodRoutings; }
private List<MethodRouting> createResourceMethodRouters( final RuntimeResource runtimeResource, final boolean subResourceMode) { final List<MethodRouting> methodRoutings = new ArrayList<>(); int i = 0; for (final Resource resource : runtimeResource.getResources()) { final Resource parentResource = runtimeResource.getParent() == null ? null : runtimeResource.getParentResources().get(i++); final UriTemplate template = resource.getPathPattern().getTemplate(); final PushMatchedTemplateRouter templateRouter = parentResource == null ? getTemplateRouter(subResourceMode, template, null) : getTemplateRouter(subResourceMode, parentResource.getPathPattern().getTemplate(), template); for (final ResourceMethod resourceMethod : resource.getResourceMethods()) { methodRoutings.add(new MethodRouting(resourceMethod, templateRouter, new PushMatchedMethodRouter(resourceMethod), createMethodRouter(resourceMethod))); } } return methodRoutings.isEmpty() ? Collections.emptyList() : methodRoutings; }
for (org.glassfish.jersey.server.model.ResourceMethod method : resource.getResourceMethods()) { if (!detailedWadl && method.isExtended()) { continue;
private Resource processResource(Resource resource) { Resource.Builder resourceBuilder = Resource.builder(resource.getPath()); for (ResourceMethod resourceMethod : resource.getResourceMethods()) { ResourceMethod.Builder builder = resourceBuilder.addMethod(resourceMethod); if (resourceMethod.getInvocable().getHandlingMethod().isAnnotationPresent(Template.class)) { builder.routingResponseType(Viewable.class); } } if (resource.getResourceLocator() != null) { resourceBuilder.addMethod(resource.getResourceLocator()); } for (Resource child : resource.getChildResources()) { resourceBuilder.addChildResource(processResource(child)); } return resourceBuilder.build(); }
for (org.glassfish.jersey.server.model.ResourceMethod method : resource.getResourceMethods()) { if (!detailedWadl && method.isExtended()) { continue;