@Override public boolean keep(AnnotatedMethod m) { return m.getAnnotation(annotation) == null; } });
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); } }
@Override public boolean keep(AnnotatedMethod m) { return m.getAnnotation(annotation) == null; } });
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); } }
@Override public boolean keep(AnnotatedMethod m) { return m.getAnnotation(annotation) != null; } });
@Override public boolean keep(AnnotatedMethod m) { return m.getAnnotation(annotation) != null; } });
@Override public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) { final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod()); // check to see if it has cache control annotation final CacheControl cc = am.getAnnotation(CacheControl.class); if (cc != null) { configuration.register(new CacheControlledResponseFilter(cc)); } }
private static List<MediaType> resolveProducedTypes(final AnnotatedMethod am, final List<MediaType> defaultProducedTypes) { // Override default types if the annotation is present on the method if (am.isAnnotationPresent(Produces.class)) { return extractMediaTypes(am.getAnnotation(Produces.class)); } return defaultProducedTypes; }
private static List<MediaType> resolveConsumedTypes(final AnnotatedMethod am, final List<MediaType> defaultConsumedTypes) { // Override default types if the annotation is present on the method if (am.isAnnotationPresent(Consumes.class)) { return extractMediaTypes(am.getAnnotation(Consumes.class)); } return defaultConsumedTypes; }
private static List<MediaType> resolveConsumedTypes(final AnnotatedMethod am, final List<MediaType> defaultConsumedTypes) { // Override default types if the annotation is present on the method if (am.isAnnotationPresent(Consumes.class)) { return extractMediaTypes(am.getAnnotation(Consumes.class)); } return defaultConsumedTypes; }
private static List<MediaType> resolveProducedTypes(final AnnotatedMethod am, final List<MediaType> defaultProducedTypes) { // Override default types if the annotation is present on the method if (am.isAnnotationPresent(Produces.class)) { return extractMediaTypes(am.getAnnotation(Produces.class)); } return defaultProducedTypes; }
@Override public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) { AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod()); // RolesAllowed on the method takes precedence over PermitAll RolesAllowed ra = am.getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(AuthCheckFilter.INSTANCE); return; } // PermitAll takes precedence over RolesAllowed on the class if (am.isAnnotationPresent(PermitAll.class)) { // Do nothing. return; } // RolesAllowed on the class takes precedence over PermitAll ra = resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(AuthCheckFilter.INSTANCE); } }
builder.append(template); Path methodPath = method.getAnnotation(Path.class); if (methodPath != null) { String methodTemplate = methodPath.value();
@Override public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) { final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod()); // DenyAll on the method take precedence over RolesAllowed and PermitAll if (am.isAnnotationPresent(DenyAll.class)) { configuration.register(new RolesAllowedRequestFilter()); return; } // RolesAllowed on the method takes precedence over PermitAll RolesAllowed ra = am.getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(new RolesAllowedRequestFilter(ra.value())); return; } // PermitAll takes precedence over RolesAllowed on the class if (am.isAnnotationPresent(PermitAll.class)) { // Do nothing. return; } // DenyAll can't be attached to classes // RolesAllowed on the class takes precedence over PermitAll ra = resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(new RolesAllowedRequestFilter(ra.value())); } }
@Override public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) { final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod()); // DenyAll on the method take precedence over RolesAllowed and PermitAll if (am.isAnnotationPresent(DenyAll.class)) { configuration.register(new RolesAllowedRequestFilter()); return; } // RolesAllowed on the method takes precedence over PermitAll RolesAllowed ra = am.getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(new RolesAllowedRequestFilter(ra.value())); return; } // PermitAll takes precedence over RolesAllowed on the class if (am.isAnnotationPresent(PermitAll.class)) { // Do nothing. return; } // DenyAll can't be attached to classes // RolesAllowed on the class takes precedence over PermitAll ra = resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class); if (ra != null) { configuration.register(new RolesAllowedRequestFilter(ra.value())); } }
/** * Create a list of parameter models for a given Java method handling a resource * method, sub-resource method or a sub-resource locator. * * @param concreteClass concrete resource method handler implementation class. * @param declaringClass the class declaring the handling Java method. * @param javaMethod Java method handling a resource method, sub-resource * method or a sub-resource locator. * @param keepEncoded set to {@code true} to disable automatic decoding * of all the method parameters. (See {@link Encoded}. * @return a list of handling method parameter models. */ public static List<Parameter> create( Class concreteClass, Class declaringClass, Method javaMethod, boolean keepEncoded) { AnnotatedMethod method = new AnnotatedMethod(javaMethod); return create( concreteClass, declaringClass, ((null != method.getAnnotation(Encoded.class)) || keepEncoded), method.getParameterTypes(), method.getGenericParameterTypes(), method.getParameterAnnotations()); }
/** * Create a list of parameter models for a given Java method handling a resource * method, sub-resource method or a sub-resource locator. * * @param concreteClass concrete resource method handler implementation class. * @param declaringClass the class declaring the handling Java method. * @param javaMethod Java method handling a resource method, sub-resource * method or a sub-resource locator. * @param keepEncoded set to {@code true} to disable automatic decoding * of all the method parameters. (See {@link Encoded}. * @return a list of handling method parameter models. */ public static List<Parameter> create( Class concreteClass, Class declaringClass, Method javaMethod, boolean keepEncoded) { AnnotatedMethod method = new AnnotatedMethod(javaMethod); return create( concreteClass, declaringClass, ((null != method.getAnnotation(Encoded.class)) || keepEncoded), method.getParameterTypes(), method.getGenericParameterTypes(), method.getParameterAnnotations()); }
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)); } } }
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)); } } }
private static List<MediaType> resolveConsumedTypes(final AnnotatedMethod am, final List<MediaType> defaultConsumedTypes) { // Override default types if the annotation is present on the method if (am.isAnnotationPresent(Consumes.class)) { return extractMediaTypes(am.getAnnotation(Consumes.class)); } return defaultConsumedTypes; }