| 1 |
package org.jboss.resteasy.spi.metadata; |
| 2 |
|
| 3 |
import org.jboss.resteasy.util.Types; |
| 4 |
|
| 5 |
import java.lang.reflect.Method; |
| 6 |
import java.lang.reflect.Type; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
public class ResourceLocator |
| 13 |
{ |
| 14 |
protected ResourceClass resourceClass; |
| 15 |
protected Class<?> returnType; |
| 16 |
protected Type genericReturnType; |
| 17 |
protected Method method; |
| 18 |
protected Method annotatedMethod; |
| 19 |
protected MethodParameter[] params = {}; |
| 20 |
protected String fullpath; |
| 21 |
protected String path; |
| 22 |
|
| 23 |
public ResourceLocator(ResourceClass resourceClass, Method method, Method annotatedMethod) |
| 24 |
{ |
| 25 |
this.resourceClass = resourceClass; |
| 26 |
this.annotatedMethod = annotatedMethod; |
| 27 |
this.method = method; |
| 28 |
|
| 29 |
|
| 30 |
this.genericReturnType = Types.resolveTypeVariables(resourceClass.getClazz(), method.getGenericReturnType()); |
| 31 |
this.returnType = Types.getRawType(genericReturnType); |
| 32 |
this.params = new MethodParameter[method.getParameterTypes().length]; |
| 33 |
for (int i = 0; i < method.getParameterTypes().length; i++) |
| 34 |
{ |
| 35 |
this.params[i] = new MethodParameter(this, method.getParameterTypes()[i], method.getGenericParameterTypes()[i], annotatedMethod.getParameterAnnotations()[i]); |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
public ResourceClass getResourceClass() |
| 40 |
{ |
| 41 |
return resourceClass; |
| 42 |
} |
| 43 |
|
| 44 |
public Class<?> getReturnType() |
| 45 |
{ |
| 46 |
return returnType; |
| 47 |
} |
| 48 |
|
| 49 |
public Type getGenericReturnType() |
| 50 |
{ |
| 51 |
return genericReturnType; |
| 52 |
} |
| 53 |
|
| 54 |
public Method getMethod() |
| 55 |
{ |
| 56 |
return method; |
| 57 |
} |
| 58 |
|
| 59 |
public Method getAnnotatedMethod() |
| 60 |
{ |
| 61 |
return annotatedMethod; |
| 62 |
} |
| 63 |
|
| 64 |
public MethodParameter[] getParams() |
| 65 |
{ |
| 66 |
return params; |
| 67 |
} |
| 68 |
|
| 69 |
public String getFullpath() |
| 70 |
{ |
| 71 |
return fullpath; |
| 72 |
} |
| 73 |
|
| 74 |
public String getPath() |
| 75 |
{ |
| 76 |
return path; |
| 77 |
} |
| 78 |
|
| 79 |
@Override |
| 80 |
public String toString() { |
| 81 |
return method.toString(); |
| 82 |
} |
| 83 |
} |