private void checkUnexpectedAnnotations(ResourceMethod resourceMethod) { Invocable invocable = resourceMethod.getInvocable(); for (Annotation annotation : invocable.getHandlingMethod().getDeclaredAnnotations()) { if (PARAM_ANNOTATION_SET.contains(annotation.annotationType())) { Errors.fatal(resourceMethod, LocalizationMessages.METHOD_UNEXPECTED_ANNOTATION( invocable.getHandlingMethod().getName(), invocable.getHandler().getHandlerClass().getName(), annotation.annotationType().getName()) ); } } }
private void checkUnexpectedAnnotations(ResourceMethod resourceMethod) { Invocable invocable = resourceMethod.getInvocable(); for (Annotation annotation : invocable.getHandlingMethod().getDeclaredAnnotations()) { if (PARAM_ANNOTATION_SET.contains(annotation.annotationType())) { Errors.fatal(resourceMethod, LocalizationMessages.METHOD_UNEXPECTED_ANNOTATION( invocable.getHandlingMethod().getName(), invocable.getHandler().getHandlerClass().getName(), annotation.annotationType().getName()) ); } } }
private void checkValueProviders(ResourceMethod method) { List<? extends Function<ContainerRequest, ?>> valueProviders = ParameterValueHelper.createValueProviders(valueParamProviders, method.getInvocable()); if (valueProviders.contains(null)) { int index = valueProviders.indexOf(null); Errors.fatal(method, LocalizationMessages.ERROR_PARAMETER_MISSING_VALUE_PROVIDER(index, method.getInvocable() .getHandlingMethod())); } }
private void checkValueProviders(ResourceMethod method) { List<? extends Function<ContainerRequest, ?>> valueProviders = ParameterValueHelper.createValueProviders(valueParamProviders, method.getInvocable()); if (valueProviders.contains(null)) { int index = valueProviders.indexOf(null); Errors.fatal(method, LocalizationMessages.ERROR_PARAMETER_MISSING_VALUE_PROVIDER(index, method.getInvocable() .getHandlingMethod())); } }
@Override public void visitInvocable(final Invocable invocable) { // TODO: check invocable. Class resClass = invocable.getHandler().getHandlerClass(); if (resClass != null && !checkedClasses.contains(resClass)) { checkedClasses.add(resClass); final boolean provider = Providers.isProvider(resClass); int counter = 0; for (Annotation annotation : resClass.getAnnotations()) { if (SCOPE_ANNOTATIONS.contains(annotation.annotationType())) { counter++; } } if (counter == 0 && provider) { Errors.warning(resClass, LocalizationMessages.RESOURCE_IMPLEMENTS_PROVIDER(resClass, Providers.getProviderContracts(resClass))); } else if (counter > 1) { Errors.fatal(resClass, LocalizationMessages.RESOURCE_MULTIPLE_SCOPE_ANNOTATIONS(resClass)); } } }
@Override public void visitInvocable(final Invocable invocable) { // TODO: check invocable. Class resClass = invocable.getHandler().getHandlerClass(); if (resClass != null && !checkedClasses.contains(resClass)) { checkedClasses.add(resClass); final boolean provider = Providers.isProvider(resClass); int counter = 0; for (Annotation annotation : resClass.getAnnotations()) { if (SCOPE_ANNOTATIONS.contains(annotation.annotationType())) { counter++; } } if (counter == 0 && provider) { Errors.warning(resClass, LocalizationMessages.RESOURCE_IMPLEMENTS_PROVIDER(resClass, Providers.getProviderContracts(resClass))); } else if (counter > 1) { Errors.fatal(resClass, LocalizationMessages.RESOURCE_MULTIPLE_SCOPE_ANNOTATIONS(resClass)); } } }
private void checkParameters(ResourceMethod method) { final Invocable invocable = method.getInvocable(); final Method handlingMethod = invocable.getHandlingMethod(); int paramCount = 0; int nonAnnotatedParameters = 0; for (Parameter p : invocable.getParameters()) { validateParameter(p, handlingMethod, handlingMethod.toGenericString(), Integer.toString(++paramCount), false); if (method.getType() == ResourceMethod.JaxrsType.SUB_RESOURCE_LOCATOR && Parameter.Source.ENTITY == p.getSource()) { Errors.fatal(method, LocalizationMessages.SUBRES_LOC_HAS_ENTITY_PARAM(invocable.getHandlingMethod())); } else if (p.getAnnotations().length == 0) { nonAnnotatedParameters++; if (nonAnnotatedParameters > 1) { Errors.fatal(method, LocalizationMessages.AMBIGUOUS_NON_ANNOTATED_PARAMETER(invocable.getHandlingMethod(), invocable.getHandlingMethod().getDeclaringClass())); } } } }
private void checkParameters(ResourceMethod method) { final Invocable invocable = method.getInvocable(); final Method handlingMethod = invocable.getHandlingMethod(); int paramCount = 0; int nonAnnotatedParameters = 0; for (Parameter p : invocable.getParameters()) { validateParameter(p, handlingMethod, handlingMethod.toGenericString(), Integer.toString(++paramCount), false); if (method.getType() == ResourceMethod.JaxrsType.SUB_RESOURCE_LOCATOR && Parameter.Source.ENTITY == p.getSource()) { Errors.fatal(method, LocalizationMessages.SUBRES_LOC_HAS_ENTITY_PARAM(invocable.getHandlingMethod())); } else if (p.getAnnotations().length == 0) { nonAnnotatedParameters++; if (nonAnnotatedParameters > 1) { Errors.fatal(method, LocalizationMessages.AMBIGUOUS_NON_ANNOTATED_PARAMETER(invocable.getHandlingMethod(), invocable.getHandlingMethod().getDeclaringClass())); } } } }
@Override public void run() { int counter = 0; final Annotation[] annotations = parameter.getAnnotations(); for (Annotation a : annotations) { if (PARAM_ANNOTATION_SET.contains(a.annotationType())) { if (injectionsForbidden) { Errors.fatal(source, LocalizationMessages.SINGLETON_INJECTS_PARAMETER(reportedSourceName, reportedParameterName)); break; } counter++; if (counter > 1) { Errors.warning(source, LocalizationMessages.AMBIGUOUS_PARAMETER(reportedSourceName, reportedParameterName)); break; } } } final Type paramType = parameter.getType(); if (!isConcreteType(paramType)) { Errors.warning(source, LocalizationMessages.PARAMETER_UNRESOLVABLE(reportedParameterName, paramType, reportedSourceName)); } } });
private void visitSubResourceLocator(ResourceMethod locator) { checkParameters(locator); checkValueProviders(locator); final Invocable invocable = locator.getInvocable(); if (void.class == invocable.getRawResponseType()) { Errors.fatal(locator, LocalizationMessages.SUBRES_LOC_RETURNS_VOID(invocable.getHandlingMethod())); } // Prevent PARAM_ANNOTATION_SET annotations on a resource locator if (invocable.getHandlingMethod().getAnnotation(Path.class) != null) { checkUnexpectedAnnotations(locator); } }
private void visitSubResourceLocator(ResourceMethod locator) { checkParameters(locator); checkValueProviders(locator); final Invocable invocable = locator.getInvocable(); if (void.class == invocable.getRawResponseType()) { Errors.fatal(locator, LocalizationMessages.SUBRES_LOC_RETURNS_VOID(invocable.getHandlingMethod())); } // Prevent PARAM_ANNOTATION_SET annotations on a resource locator if (invocable.getHandlingMethod().getAnnotation(Path.class) != null) { checkUnexpectedAnnotations(locator); } }
@Override public void run() { int counter = 0; final Annotation[] annotations = parameter.getAnnotations(); for (Annotation a : annotations) { if (PARAM_ANNOTATION_SET.contains(a.annotationType())) { if (injectionsForbidden) { Errors.fatal(source, LocalizationMessages.SINGLETON_INJECTS_PARAMETER(reportedSourceName, reportedParameterName)); break; } counter++; if (counter > 1) { Errors.warning(source, LocalizationMessages.AMBIGUOUS_PARAMETER(reportedSourceName, reportedParameterName)); break; } } } final Type paramType = parameter.getType(); if (!isConcreteType(paramType)) { Errors.warning(source, LocalizationMessages.PARAMETER_UNRESOLVABLE(reportedParameterName, paramType, reportedSourceName)); } } });
Errors.fatal(method, LocalizationMessages.GET_CONSUMES_FORM_PARAM(invocable.getHandlingMethod())); break; Errors.fatal(method, LocalizationMessages.EVENT_SINK_RETURNS_TYPE(invocable.getHandlingMethod())); Errors.fatal(method, LocalizationMessages.MULTIPLE_HTTP_METHOD_DESIGNATORS(invocable.getHandlingMethod(), httpMethodAnnotations.toString()));
Errors.fatal(method, LocalizationMessages.GET_CONSUMES_FORM_PARAM(invocable.getHandlingMethod())); break; Errors.fatal(method, LocalizationMessages.EVENT_SINK_RETURNS_TYPE(invocable.getHandlingMethod())); Errors.fatal(method, LocalizationMessages.MULTIPLE_HTTP_METHOD_DESIGNATORS(invocable.getHandlingMethod(), httpMethodAnnotations.toString()));
Errors.fatal(runtimeResource, LocalizationMessages.AMBIGUOUS_FATAL_RMS(httpMethod, m1.getInvocable() .getHandlingMethod(), m2.getInvocable().getHandlingMethod(), runtimeResource.getRegex())); } else if ((producesFails && consumesOnlyIntersects)
Errors.fatal(runtimeResource, LocalizationMessages.AMBIGUOUS_FATAL_RMS(httpMethod, m1.getInvocable() .getHandlingMethod(), m2.getInvocable().getHandlingMethod(), runtimeResource.getRegex())); } else if ((producesFails && consumesOnlyIntersects)
private void checkUnexpectedAnnotations(ResourceMethod resourceMethod) { Invocable invocable = resourceMethod.getInvocable(); for (Annotation annotation : invocable.getHandlingMethod().getDeclaredAnnotations()) { if (PARAM_ANNOTATION_SET.contains(annotation.annotationType())) { Errors.fatal(resourceMethod, LocalizationMessages.METHOD_UNEXPECTED_ANNOTATION( invocable.getHandlingMethod().getName(), invocable.getHandler().getHandlerClass().getName(), annotation.annotationType().getName()) ); } } }
private void checkValueProviders(ResourceMethod method) { List<? extends Function<ContainerRequest, ?>> valueProviders = ParameterValueHelper.createValueProviders(valueParamProviders, method.getInvocable()); if (valueProviders.contains(null)) { int index = valueProviders.indexOf(null); Errors.fatal(method, LocalizationMessages.ERROR_PARAMETER_MISSING_VALUE_PROVIDER(index, method.getInvocable() .getHandlingMethod())); } }
private void checkParameters(ResourceMethod method) { final Invocable invocable = method.getInvocable(); final Method handlingMethod = invocable.getHandlingMethod(); int paramCount = 0; int nonAnnotatedParameters = 0; for (Parameter p : invocable.getParameters()) { validateParameter(p, handlingMethod, handlingMethod.toGenericString(), Integer.toString(++paramCount), false); if (method.getType() == ResourceMethod.JaxrsType.SUB_RESOURCE_LOCATOR && Parameter.Source.ENTITY == p.getSource()) { Errors.fatal(method, LocalizationMessages.SUBRES_LOC_HAS_ENTITY_PARAM(invocable.getHandlingMethod())); } else if (p.getAnnotations().length == 0) { nonAnnotatedParameters++; if (nonAnnotatedParameters > 1) { Errors.fatal(method, LocalizationMessages.AMBIGUOUS_NON_ANNOTATED_PARAMETER(invocable.getHandlingMethod(), invocable.getHandlingMethod().getDeclaringClass())); } } } }
private void visitSubResourceLocator(ResourceMethod locator) { checkParameters(locator); checkValueProviders(locator); final Invocable invocable = locator.getInvocable(); if (void.class == invocable.getRawResponseType()) { Errors.fatal(locator, LocalizationMessages.SUBRES_LOC_RETURNS_VOID(invocable.getHandlingMethod())); } // Prevent PARAM_ANNOTATION_SET annotations on a resource locator if (invocable.getHandlingMethod().getAnnotation(Path.class) != null) { checkUnexpectedAnnotations(locator); } }