Java Code Examples for javax.ws.rs.HttpMethod#value()

The following examples show how to use javax.ws.rs.HttpMethod#value() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractResourceDescriptor.java    From everrest with Eclipse Public License 2.0 6 votes vote down vote up
private void addSubResourceMethod(Method method, Path subPath, HttpMethod httpMethod, List<Parameter> params, Annotation[] additional, List<MediaType> produces, List<MediaType> consumes) {
    SubResourceMethodDescriptor subResourceMethod = new SubResourceMethodDescriptorImpl(new PathValue(subPath.value()), method, httpMethod.value(), params, this, consumes, produces, additional);
    validateResourceMethod(subResourceMethod);

    Map<String, List<SubResourceMethodDescriptor>> subResourceMethods = getSubResourceMethods(subResourceMethod.getUriPattern());

    SubResourceMethodDescriptor existedSubResourceMethod = (SubResourceMethodDescriptor)findMethodResourceMediaType(subResourceMethods.get(httpMethod.value()), subResourceMethod.consumes(), subResourceMethod.produces());
    if (existedSubResourceMethod != null) {
        throw new RuntimeException(String.format("Two sub-resource method %s and %s with the same HTTP method, path, consumes and produces found", subResourceMethod, existedSubResourceMethod));
    }
    List<SubResourceMethodDescriptor> methodList = subResourceMethods.get(httpMethod.value());
    if (methodList == null) {
        methodList = new ArrayList<>();
        subResourceMethods.put(httpMethod.value(), methodList);
    }
    methodList.add(subResourceMethod);
}
 
Example 2
Source File: AnnotationUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static String getHttpMethodValue(Method m) {
    for (Annotation a : m.getAnnotations()) {
        HttpMethod httpM = a.annotationType().getAnnotation(HttpMethod.class);
        if (httpM != null) {
            return httpM.value();
        }
    }
    return null;
}
 
Example 3
Source File: AbstractResourceDescriptor.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
private void addResourceMethod(Method method, HttpMethod httpMethod, List<Parameter> params, Annotation[] additional, List<MediaType> produces, List<MediaType> consumes) {
    ResourceMethodDescriptor resourceMethod = new ResourceMethodDescriptorImpl(method, httpMethod.value(), params, this, consumes, produces, additional);
    validateResourceMethod(resourceMethod);
    ResourceMethodDescriptor existedResourceMethod = findMethodResourceMediaType(getResourceMethods(httpMethod.value()), resourceMethod.consumes(), resourceMethod.produces());
    if (existedResourceMethod != null) {
        throw new RuntimeException(String.format("Two resource method %s and %s with the same HTTP method, consumes and produces found", resourceMethod, existedResourceMethod));
    }
    resourceMethods.add(httpMethod.value(), resourceMethod);
}
 
Example 4
Source File: WebResourceFactory.java    From JaxRSProviders with Apache License 2.0 4 votes vote down vote up
private static String getHttpMethodName(final AnnotatedElement ae) {
	final HttpMethod a = ae.getAnnotation(HttpMethod.class);
	return a == null ? null : a.value();
}