Skip to content

Instantly share code, notes, and snippets.

@liweinan
Created February 22, 2012 12:17
Show Gist options
  • Save liweinan/1884586 to your computer and use it in GitHub Desktop.
Save liweinan/1884586 to your computer and use it in GitHub Desktop.
git diff
diff --git a/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/ResourceMethodRegistry.java b/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/ResourceMethodRegistry.java
index 2106862..6ab27a8 100644
--- a/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/ResourceMethodRegistry.java
+++ b/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/ResourceMethodRegistry.java
@@ -5,16 +5,14 @@ import org.jboss.resteasy.plugins.server.resourcefactory.JndiResourceFactory;
import org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory;
import org.jboss.resteasy.plugins.server.resourcefactory.SingletonResource;
import org.jboss.resteasy.specimpl.UriBuilderImpl;
-import org.jboss.resteasy.spi.HttpRequest;
-import org.jboss.resteasy.spi.InjectorFactory;
-import org.jboss.resteasy.spi.Registry;
-import org.jboss.resteasy.spi.ResourceFactory;
-import org.jboss.resteasy.spi.ResteasyProviderFactory;
+import org.jboss.resteasy.spi.*;
+import org.jboss.resteasy.util.FindAnnotation;
import org.jboss.resteasy.util.GetRestful;
import org.jboss.resteasy.util.IsHttpMethod;
import org.jboss.resteasy.util.Types;
import javax.ws.rs.Path;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Set;
@@ -203,6 +201,17 @@ public class ResourceMethodRegistry implements Registry
Method method = findAnnotatedMethod(clazz, implementation);
if (method != null)
{
+
+ Annotation[][] paramAnnotations = method.getParameterAnnotations();
+ int notAnnotatedParamCount = 0;
+ for (Annotation[] paramAnnotation : paramAnnotations) {
+ if (FindAnnotation.findJaxRSAnnotations(paramAnnotation).length == 0) {
+ notAnnotatedParamCount++;
+ if (notAnnotatedParamCount > 1)
+ logger.warn(implementation.getDeclaringClass().getName() + "." + implementation.getName() + "(): Resource methods MUST NOT have more than one parameter that is not annotated with one of the JaxRS Annotations.");
+ }
+ }
+
Path path = method.getAnnotation(Path.class);
Set<String> httpMethods = IsHttpMethod.getHttpMethods(method);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment