javax.ws.rs.Path.value()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(118)

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

Path.value介绍

暂无

代码示例

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

private static WebTarget addPathFromAnnotation(final AnnotatedElement ae, WebTarget target) {
  final Path p = ae.getAnnotation(Path.class);
  if (p != null) {
    target = target.path(p.value());
  }
  return target;
}

代码示例来源:origin: weibocom/motan

public static Map<Method, RestfulClientInvoker> proxy(final Class<?> iface, WebTarget base,
    final ProxyConfig config) {
  if (iface.isAnnotationPresent(Path.class)) {
    Path path = iface.getAnnotation(Path.class);
    if (!path.value().equals("") && !path.value().equals("/")) {
      base = base.path(path.value());
    }
  }
  HashMap<Method, RestfulClientInvoker> methodMap = new HashMap<Method, RestfulClientInvoker>();
  for (Method method : iface.getMethods()) {
    RestfulClientInvoker invoker = createClientInvoker(iface, method, (ResteasyWebTarget) base, config);
    methodMap.put(method, invoker);
  }
  return methodMap;
}

代码示例来源:origin: swagger-api/swagger-core

public static String getPath(javax.ws.rs.Path classLevelPath, javax.ws.rs.Path methodLevelPath, String parentPath, boolean isSubresource) {
  if (classLevelPath == null && methodLevelPath == null && StringUtils.isEmpty(parentPath)) {
    return null;
  }
  StringBuilder b = new StringBuilder();
  appendPathComponent(parentPath, b);
  if (classLevelPath != null && !isSubresource) {
    appendPathComponent(classLevelPath.value(), b);
  }
  if (methodLevelPath != null) {
    appendPathComponent(methodLevelPath.value(), b);
  }
  return b.length() == 0 ? "/" : b.toString();
}

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

private <T> Set<Resource> prefixResources(String prefix, Set<Class<? extends T>> resources) {
  final String pathPrefix = prefix.endsWith("/") ? prefix.substring(0, prefix.length() - 1) : prefix;
  return resources
      .stream()
      .map(resource -> {
        final javax.ws.rs.Path pathAnnotation = Resource.getPath(resource);
        final String resourcePathSuffix = Strings.nullToEmpty(pathAnnotation.value());
        final String resourcePath = resourcePathSuffix.startsWith("/") ? pathPrefix + resourcePathSuffix : pathPrefix + "/" + resourcePathSuffix;
        return Resource
            .builder(resource)
            .path(resourcePath)
            .build();
      })
      .collect(Collectors.toSet());
}

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

private void appendPath(final Path path) {
  if (path == null) {
    throw new IllegalArgumentException(LocalizationMessages.PARAM_NULL("path"));
  }
  appendPath(path.value());
}

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

private void appendPath(final Path path) {
  if (path == null) {
    throw new IllegalArgumentException(LocalizationMessages.PARAM_NULL("path"));
  }
  appendPath(path.value());
}

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

public synchronized Map<String, Object> generateOverview() {
  if (!overviewResult.isEmpty()) {
    return overviewResult;
  }
  final List<Map<String, Object>> apis = Lists.newArrayList();
  for (Class<?> clazz : getAnnotatedClasses()) {
    Api info = clazz.getAnnotation(Api.class);
    Path path = clazz.getAnnotation(Path.class);
    if (info == null || path == null) {
      LOG.debug("Skipping REST resource with no Api or Path annotation: <{}>", clazz.getCanonicalName());
      continue;
    }
    final String prefixedPath = prefixedPath(clazz, path.value());
    final Map<String, Object> apiDescription = Maps.newHashMap();
    apiDescription.put("name", prefixedPath.startsWith(pluginPathPrefix) ? "Plugins/" + info.value() : info.value());
    apiDescription.put("path", prefixedPath);
    apiDescription.put("description", info.description());
    apis.add(apiDescription);
  }
  Collections.sort(apis, (o1, o2) -> ComparisonChain.start().compare(o1.get("name").toString(), o2.get("name").toString()).result());
  Map<String, String> info = Maps.newHashMap();
  info.put("title", "Graylog REST API");
  overviewResult.put("apiVersion", ServerVersion.VERSION.toString());
  overviewResult.put("swaggerVersion", EMULATED_SWAGGER_VERSION);
  overviewResult.put("apis", apis);
  return overviewResult;
}

代码示例来源:origin: swagger-api/swagger-core

@Test
public void testDerivedAnnotation() {
  final Path annotation = ReflectionUtils.getAnnotation(Child.class, javax.ws.rs.Path.class);
  Assert.assertNotNull(annotation);
  Assert.assertEquals(annotation.value(), "parentInterfacePath");
}

代码示例来源:origin: aol/micro-server

public ReactiveSeq<Tuple2<String,String>> extractResources() {
  return resources.stream().peek(resource -> logMissingPath(resource))
              .filter(resource-> resource.getClass().getAnnotation(Path.class)!=null)
              .map(resource -> Tuple.tuple(resource.getClass().getName(),
                  resource.getClass().getAnnotation(Path.class).value()));
}

代码示例来源:origin: HotswapProjects/HotswapAgent

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

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

template = path == null ? "" : path.value();
String methodTemplate = methodPath.value();

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

template = path == null ? "" : path.value();
    String methodTemplate = methodPath.value();

代码示例来源:origin: apache/incubator-druid

final String basepath = ((Path) clazz.getAnnotation(Path.class)).value().substring(1); //Ignore the first "/"
final List<Class<? extends ResourceFilter>> baseResourceFilters =
  clazz.getAnnotation(ResourceFilters.class) == null ? Collections.emptyList() :

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

resourceBuilder = Resource.builder(rPathAnnotation.value());
} else {
  resourceBuilder = Resource.builder();

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

resourceBuilder = Resource.builder(rPathAnnotation.value());
} else {
  resourceBuilder = Resource.builder();

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

private void addSubResourceLocators(
      final Resource.Builder resourceBuilder,
      final MethodList methodList,
      final List<Parameter> resourceClassParameters, // parameters derived from fields and setters on the resource class
      final boolean encodedParameters,
      final boolean extended) {

    for (AnnotatedMethod am : methodList.withoutMetaAnnotation(HttpMethod.class).withAnnotation(Path.class)) {
      final String path = am.getAnnotation(Path.class).value();
      Resource.Builder builder = resourceBuilder;
      if (path != null && !path.isEmpty() && !"/".equals(path)) {
        builder = resourceBuilder.addChildResource(path);
      }

      builder.addMethod()
          .encodedParameters(encodedParameters || am.isAnnotationPresent(Encoded.class))
          .handledBy(handlerClass, am.getMethod())
          .handlingMethod(am.getDeclaredMethod())
          .handlerParameters(resourceClassParameters)
          .extended(extended || am.isAnnotationPresent(ExtendedResource.class));
    }
  }
}

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

private void addSubResourceLocators(
      final Resource.Builder resourceBuilder,
      final MethodList methodList,
      final List<Parameter> resourceClassParameters, // parameters derived from fields and setters on the resource class
      final boolean encodedParameters,
      final boolean extended) {

    for (AnnotatedMethod am : methodList.withoutMetaAnnotation(HttpMethod.class).withAnnotation(Path.class)) {
      final String path = am.getAnnotation(Path.class).value();
      Resource.Builder builder = resourceBuilder;
      if (path != null && !path.isEmpty() && !"/".equals(path)) {
        builder = resourceBuilder.addChildResource(path);
      }

      builder.addMethod()
          .encodedParameters(encodedParameters || am.isAnnotationPresent(Encoded.class))
          .handledBy(handlerClass, am.getMethod())
          .handlingMethod(am.getDeclaredMethod())
          .handlerParameters(resourceClassParameters)
          .extended(extended || am.isAnnotationPresent(ExtendedResource.class));
    }
  }
}

代码示例来源:origin: com.sun.jersey/jersey-server

private static void workOutSubResourceLocatorsList(
    AbstractResource resource,
    MethodList methodList,
    boolean isEncoded) {
  for (AnnotatedMethod m : methodList.hasNotMetaAnnotation(HttpMethod.class).
      hasAnnotation(Path.class)) {
    final Path mPathAnnotation = m.getAnnotation(Path.class);
    final AbstractSubResourceLocator subResourceLocator = new AbstractSubResourceLocator(
        resource,
        m.getMethod(),
        new PathValue(
          mPathAnnotation.value()),
        m.getAnnotations());
    processParameters(
        subResourceLocator.getResource().getResourceClass(),
        subResourceLocator.getMethod().getDeclaringClass(),
        subResourceLocator, m, isEncoded);
    resource.getSubResourceLocators().add(subResourceLocator);
  }
}

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

private void addSubResourceMethods(
    final Resource.Builder resourceBuilder,
    final MethodList methodList,
    final List<Parameter> resourceClassParameters, // parameters derived from fields and setters on the resource class
    final boolean encodedParameters,
    final List<MediaType> defaultConsumedTypes,
    final List<MediaType> defaultProducedTypes,
    final Collection<Class<? extends Annotation>> defaultNameBindings,
    final boolean extended
) {
  for (AnnotatedMethod am : methodList.withMetaAnnotation(HttpMethod.class).withAnnotation(Path.class)) {
    Resource.Builder childResourceBuilder = resourceBuilder.addChildResource(am.getAnnotation(Path.class).value());
    ResourceMethod.Builder methodBuilder =
        childResourceBuilder.addMethod(am.getMetaMethodAnnotations(HttpMethod.class).get(0).value())
            .consumes(resolveConsumedTypes(am, defaultConsumedTypes))
            .produces(resolveProducedTypes(am, defaultProducedTypes))
            .encodedParameters(encodedParameters || am.isAnnotationPresent(Encoded.class))
            .nameBindings(defaultNameBindings)
            .nameBindings(am.getAnnotations())
            .handledBy(handlerClass, am.getMethod())
            .handlingMethod(am.getDeclaredMethod())
            .handlerParameters(resourceClassParameters)
            .extended(extended || am.isAnnotationPresent(ExtendedResource.class));
    introspectAsyncFeatures(am, methodBuilder);
  }
}

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

private void addSubResourceMethods(
    final Resource.Builder resourceBuilder,
    final MethodList methodList,
    final List<Parameter> resourceClassParameters, // parameters derived from fields and setters on the resource class
    final boolean encodedParameters,
    final List<MediaType> defaultConsumedTypes,
    final List<MediaType> defaultProducedTypes,
    final Collection<Class<? extends Annotation>> defaultNameBindings,
    final boolean extended
) {
  for (AnnotatedMethod am : methodList.withMetaAnnotation(HttpMethod.class).withAnnotation(Path.class)) {
    Resource.Builder childResourceBuilder = resourceBuilder.addChildResource(am.getAnnotation(Path.class).value());
    ResourceMethod.Builder methodBuilder =
        childResourceBuilder.addMethod(am.getMetaMethodAnnotations(HttpMethod.class).get(0).value())
            .consumes(resolveConsumedTypes(am, defaultConsumedTypes))
            .produces(resolveProducedTypes(am, defaultProducedTypes))
            .encodedParameters(encodedParameters || am.isAnnotationPresent(Encoded.class))
            .nameBindings(defaultNameBindings)
            .nameBindings(am.getAnnotations())
            .handledBy(handlerClass, am.getMethod())
            .handlingMethod(am.getDeclaredMethod())
            .handlerParameters(resourceClassParameters)
            .extended(extended || am.isAnnotationPresent(ExtendedResource.class));
    introspectAsyncFeatures(am, methodBuilder);
  }
}

相关文章

微信公众号

最新文章

更多