private static String getHttpMethodName(final AnnotatedElement ae) { final HttpMethod a = ae.getAnnotation(HttpMethod.class); return a == null ? null : a.value(); } }
public static String getHttpMethodFromCustomAnnotations(Method method) { for (Annotation methodAnnotation : method.getAnnotations()) { HttpMethod httpMethod = methodAnnotation.annotationType().getAnnotation(HttpMethod.class); if (httpMethod != null) { return httpMethod.value().toLowerCase(); } } return null; } }
public static ContainerException badMethodHttpMethod(Class resourceClass, Method m, HttpMethod hm) { return new ContainerException(ImplMessages.BAD_METHOD_HTTPMETHOD(resourceClass, hm.value(), m.toString())); }
public static String extractOperationMethod(Method method, Iterator<OpenAPIExtension> chain) { if (method.getAnnotation(javax.ws.rs.GET.class) != null) { return GET_METHOD; } else if (method.getAnnotation(javax.ws.rs.PUT.class) != null) { return PUT_METHOD; } else if (method.getAnnotation(javax.ws.rs.POST.class) != null) { return POST_METHOD; } else if (method.getAnnotation(javax.ws.rs.DELETE.class) != null) { return DELETE_METHOD; } else if (method.getAnnotation(javax.ws.rs.OPTIONS.class) != null) { return OPTIONS_METHOD; } else if (method.getAnnotation(javax.ws.rs.HEAD.class) != null) { return HEAD_METHOD; } else if (method.getAnnotation(DELETE.class) != null) { return DELETE_METHOD; } else if (method.getAnnotation(HttpMethod.class) != null) { HttpMethod httpMethod = method.getAnnotation(HttpMethod.class); return httpMethod.value().toLowerCase(); } else if (!StringUtils.isEmpty(getHttpMethodFromCustomAnnotations(method))) { return getHttpMethodFromCustomAnnotations(method); } else if ((ReflectionUtils.getOverriddenMethod(method)) != null) { return extractOperationMethod(ReflectionUtils.getOverriddenMethod(method), chain); } else if (chain != null && chain.hasNext()) { return chain.next().extractOperationMethod(method, chain); } else { return null; } }
private static void workOutResourceMethodsList( AbstractResource resource, MethodList methodList, boolean isEncoded, Consumes classScopeConsumesAnnotation, Produces classScopeProducesAnnotation) { for (AnnotatedMethod m : methodList.hasMetaAnnotation(HttpMethod.class). hasNotAnnotation(Path.class)) { final ReflectionHelper.ClassTypePair ct = getGenericReturnType(resource.getResourceClass(), m.getMethod()); final AbstractResourceMethod resourceMethod = new AbstractResourceMethod( resource, m.getMethod(), ct.c, ct.t, m.getMetaMethodAnnotations(HttpMethod.class).get(0).value(), m.getAnnotations()); addConsumes(m, resourceMethod, classScopeConsumesAnnotation); addProduces(m, resourceMethod, classScopeProducesAnnotation); processParameters( resourceMethod.getResource().getResourceClass(), resourceMethod.getMethod().getDeclaringClass(), resourceMethod, m, isEncoded); resource.getResourceMethods().add(resourceMethod); } }
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); } }
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); } }
public static Set<String> getHttpMethods(Method method) { HashSet<String> methods = new HashSet<String>(); for (Annotation annotation : method.getAnnotations()) { HttpMethod http = annotation.annotationType().getAnnotation(HttpMethod.class); if (http != null) methods.add(http.value()); } if (methods.size() == 0) return null; return methods; } }
private void addResourceMethods( 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).withoutAnnotation(Path.class)) { ResourceMethod.Builder methodBuilder = resourceBuilder.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); } }
private void addResourceMethods( 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).withoutAnnotation(Path.class)) { ResourceMethod.Builder methodBuilder = resourceBuilder.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); } }
private static Set<String> getHttpMethods(Method method) { HashSet<String> methods = new HashSet<String>(); for (Annotation annotation : method.getAnnotations()) { HttpMethod http = annotation.annotationType().getAnnotation(HttpMethod.class); if (http != null) methods.add(http.value()); } if (methods.size() == 0) return null; return methods; }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { Annotation httpMethodAnnotation = (Annotation) annotation; HttpMethod httpMethod = httpMethodAnnotation.annotationType().getAnnotation(HttpMethod.class); operationGenerator.setHttpMethod(httpMethod.value()); } }
public List<ResourceFilter> create(final AbstractMethod method) { if (annotationIsPresent(method, CorsAllowed.class)) { String targetMethod = HttpMethod.GET; for (Annotation ann : method.getAnnotations()) { HttpMethod m = ann.annotationType().getAnnotation(HttpMethod.class); if (m != null) { targetMethod = m.value(); break; } } ResourceFilter resourceFilter = new CorsResourceFilter(tracker, targetMethod); return singletonList(resourceFilter); } else { return emptyList(); } }
if (innerAnnotation instanceof HttpMethod) { HttpMethod httpMethod = (HttpMethod) innerAnnotation; return httpMethod.value().toLowerCase();
private static String getHttpMethodName(final AnnotatedElement ae) { final HttpMethod a = ae.getAnnotation(HttpMethod.class); return a == null ? null : a.value(); } }
private static String getHttpMethodName(final AnnotatedElement ae) { final HttpMethod a = ae.getAnnotation(HttpMethod.class); return a == null ? null : a.value(); } }
private static String getHttpMethodName(AnnotatedElement element) { HttpMethod httpMethod = element.getAnnotation(HttpMethod.class); return httpMethod == null ? null : httpMethod.value(); }
private static String getHttpMethodName(final AnnotatedElement ae) { final HttpMethod a = ae.getAnnotation(HttpMethod.class); return a == null ? null : a.value(); }
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; }