org.glassfish.jersey.server.model.Resource.getResourceMethods()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中org.glassfish.jersey.server.model.Resource.getResourceMethods方法的一些代码示例,展示了Resource.getResourceMethods的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.getResourceMethods方法的具体详情如下:
包路径:org.glassfish.jersey.server.model.Resource
类名称:Resource
方法名:getResourceMethods

Resource.getResourceMethods介绍

[英]Provides a non-null list of resource methods available on the resource.
[中]提供资源上可用的资源方法的非空列表。

代码示例

代码示例来源:origin: jersey/jersey

/**
 * 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);
  }
}

代码示例来源:origin: jersey/jersey

/**
 * 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);
  }
}

代码示例来源:origin: jersey/jersey

/**
 * 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;
}

代码示例来源:origin: jersey/jersey

/**
 * 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;
}

代码示例来源:origin: jersey/jersey

@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;
  }
}

代码示例来源:origin: jersey/jersey

@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;
  }
}

代码示例来源:origin: jersey/jersey

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);
  }
}

代码示例来源:origin: jersey/jersey

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);
  }
}

代码示例来源:origin: jersey/jersey

/**
   * 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;
  }
}

代码示例来源:origin: jersey/jersey

/**
   * 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;
  }
}

代码示例来源:origin: jersey/jersey

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);
    }
  }
}

代码示例来源:origin: jersey/jersey

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);
    }
  }
}

代码示例来源:origin: Graylog2/graylog2-server

private void checkResources(List<Resource> resources) {
    for (ResourceMethod method : resource.getResourceMethods()) {
      final Method m = method.getInvocable().getDefinitionMethod();

代码示例来源:origin: jersey/jersey

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()));
  }
}

代码示例来源:origin: jersey/jersey

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()));
  }
}

代码示例来源:origin: jersey/jersey

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;
}

代码示例来源:origin: jersey/jersey

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;
}

代码示例来源:origin: jersey/jersey

for (org.glassfish.jersey.server.model.ResourceMethod method : resource.getResourceMethods()) {
  if (!detailedWadl && method.isExtended()) {
    continue;

代码示例来源:origin: jersey/jersey

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();
}

代码示例来源:origin: jersey/jersey

for (org.glassfish.jersey.server.model.ResourceMethod method : resource.getResourceMethods()) {
  if (!detailedWadl && method.isExtended()) {
    continue;

相关文章