public
Created

  • Download Gist
gistfile1.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
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..bf32ea0 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
@@ -1,20 +1,19 @@
package org.jboss.resteasy.core;
import org.jboss.resteasy.core.registry.RootSegment;
+import org.jboss.resteasy.logging.Logger;
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;
@@ -27,6 +26,8 @@ import java.util.Set;
*/
public class ResourceMethodRegistry implements Registry
{
+ final static Logger logger = Logger.getLogger(ResourceMethodRegistry.class);
+
protected int size;
protected ResteasyProviderFactory providerFactory;
@@ -203,6 +204,19 @@ 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 JAX-RS Annotations.");
+ return;
+ }
+ }
+ }
+
Path path = method.getAnnotation(Path.class);
Set<String> httpMethods = IsHttpMethod.getHttpMethods(method);
diff --git a/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/util/FindAnnotation.java b/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/util/FindAnnotation.java
index 3442cbf..1f67761 100644
--- a/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/util/FindAnnotation.java
+++ b/jaxrs/resteasy-jaxrs/src/main/java/org/jboss/resteasy/util/FindAnnotation.java
@@ -1,10 +1,6 @@
package org.jboss.resteasy.util;
-import javax.ws.rs.CookieParam;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.MatrixParam;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
+import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
@@ -30,7 +26,8 @@ public final class FindAnnotation
CookieParam.class,
PathParam.class,
MatrixParam.class,
- Context.class
+ Context.class,
+ FormParam.class
};
private static final Class[] findJaxRSAnnotations_TYPE = new Class[]{};

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.