@Override public boolean keep(AnnotatedMethod m) { return m.getMethod().getReturnType() == returnType; } });
@Override public boolean keep(AnnotatedMethod m) { return m.getMethod().getReturnType() == returnType; } });
@Override public boolean keep(AnnotatedMethod m) { return !Modifier.isPublic(m.getMethod().getModifiers()); } });
@Override public boolean keep(AnnotatedMethod m) { return m.getMethod().getName().startsWith(prefix); } });
@Override public boolean keep(AnnotatedMethod m) { return !Modifier.isPublic(m.getMethod().getModifiers()); } });
@Override public boolean keep(AnnotatedMethod m) { return m.getMethod().getName().startsWith(prefix); } });
methods = methods.withMetaAnnotation(HttpMethod.class); for (AnnotatedMethod method : methods) { if (!Objects.equals(method.getMethod().getName(), link.method())) { continue;
private void checkResourceClassSetters(final MethodList methodList, final boolean encodedFlag, Collection<Parameter> injectableParameters) { for (AnnotatedMethod method : methodList.withoutMetaAnnotation(HttpMethod.class) .withoutAnnotation(Path.class) .hasNumParams(1) .hasReturnType(void.class) .nameStartsWith("set")) { Parameter p = Parameter.create( handlerClass, method.getMethod().getDeclaringClass(), encodedFlag || method.isAnnotationPresent(Encoded.class), method.getParameterTypes()[0], method.getGenericParameterTypes()[0], method.getAnnotations()); if (null != p) { ResourceMethodValidator.validateParameter(p, method.getMethod(), method.getMethod().toGenericString(), "1", InvocableValidator.isSingleton(handlerClass)); // we do not inject entity parameters into class instance fields and properties. if (p.getSource() != Parameter.Source.ENTITY) { injectableParameters.add(p); } } } }
private void checkResourceClassSetters(final MethodList methodList, final boolean encodedFlag, Collection<Parameter> injectableParameters) { for (AnnotatedMethod method : methodList.withoutMetaAnnotation(HttpMethod.class) .withoutAnnotation(Path.class) .hasNumParams(1) .hasReturnType(void.class) .nameStartsWith("set")) { Parameter p = Parameter.create( handlerClass, method.getMethod().getDeclaringClass(), encodedFlag || method.isAnnotationPresent(Encoded.class), method.getParameterTypes()[0], method.getGenericParameterTypes()[0], method.getAnnotations()); if (null != p) { ResourceMethodValidator.validateParameter(p, method.getMethod(), method.getMethod().toGenericString(), "1", InvocableValidator.isSingleton(handlerClass)); // we do not inject entity parameters into class instance fields and properties. if (p.getSource() != Parameter.Source.ENTITY) { injectableParameters.add(p); } } } }
private void checkForNonPublicMethodIssues() { final MethodList allDeclaredMethods = new MethodList(getAllDeclaredMethods(handlerClass)); // non-public resource methods for (AnnotatedMethod m : allDeclaredMethods.withMetaAnnotation(HttpMethod.class) .withoutAnnotation(Path.class).isNotPublic()) { Errors.warning(handlerClass, LocalizationMessages.NON_PUB_RES_METHOD(m.getMethod().toGenericString())); } // non-public sub-resource methods for (AnnotatedMethod m : allDeclaredMethods.withMetaAnnotation(HttpMethod.class) .withAnnotation(Path.class).isNotPublic()) { Errors.warning(handlerClass, LocalizationMessages.NON_PUB_SUB_RES_METHOD(m.getMethod().toGenericString())); } // non-public sub-resource locators for (AnnotatedMethod m : allDeclaredMethods.withoutMetaAnnotation(HttpMethod.class) .withAnnotation(Path.class).isNotPublic()) { Errors.warning(handlerClass, LocalizationMessages.NON_PUB_SUB_RES_LOC(m.getMethod().toGenericString())); } }
private void checkForNonPublicMethodIssues() { final MethodList allDeclaredMethods = new MethodList(getAllDeclaredMethods(handlerClass)); // non-public resource methods for (AnnotatedMethod m : allDeclaredMethods.withMetaAnnotation(HttpMethod.class) .withoutAnnotation(Path.class).isNotPublic()) { Errors.warning(handlerClass, LocalizationMessages.NON_PUB_RES_METHOD(m.getMethod().toGenericString())); } // non-public sub-resource methods for (AnnotatedMethod m : allDeclaredMethods.withMetaAnnotation(HttpMethod.class) .withAnnotation(Path.class).isNotPublic()) { Errors.warning(handlerClass, LocalizationMessages.NON_PUB_SUB_RES_METHOD(m.getMethod().toGenericString())); } // non-public sub-resource locators for (AnnotatedMethod m : allDeclaredMethods.withoutMetaAnnotation(HttpMethod.class) .withAnnotation(Path.class).isNotPublic()) { Errors.warning(handlerClass, LocalizationMessages.NON_PUB_SUB_RES_LOC(m.getMethod().toGenericString())); } }
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)); } } }
@Override public boolean keep(AnnotatedMethod m) { return m.getMethod().getReturnType() == returnType; } });
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.getMethod().getName().startsWith(prefix); } });
@Override public boolean keep(AnnotatedMethod m) { return !Modifier.isPublic(m.getMethod().getModifiers()); } });
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 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); } }