public JaxrsResourceMethod(MetaMethod method, JaxrsHeaders headers, String rootResourcePath) { Path subResourcePath = method.getAnnotation(Path.class); String fullPath = rootResourcePath; if (fullPath.startsWith("/")) { fullPath = fullPath.substring(1); } if (fullPath.endsWith("/")) { fullPath = fullPath.substring(0, fullPath.length() - 1); } if (subResourcePath != null) { if (!subResourcePath.value().startsWith("/")) { fullPath += "/"; } fullPath += subResourcePath.value(); } this.method = method; this.path = fullPath; this.httpMethod = JaxrsGwtRequestMethodMapper.fromMethod(method); this.parameters = JaxrsResourceMethodParameters.fromMethod(method); this.methodHeaders = JaxrsHeaders.fromMethod(method); this.resourceClassHeaders = headers; }
public static JaxrsResourceMethodParameters fromMethod(MetaMethod method) { final List<Parameter> defParams = DefParameters.from(method).getParameters(); return fromMethod(method, defParams); }
public static JaxrsResourceMethodParameters fromMethod(MetaMethod method, String parameterArrayVarName) { final List<Statement> params = new ArrayList<Statement>(); final Parameter[] defParms = DefParameters.from(method).getParameters().toArray(new Parameter[0]); for (int i = 0; i < defParms.length; i++) { final MetaClass type = defParms[i].getType().asBoxed(); final Statement s = Cast.to(type, Stmt.loadVariable(parameterArrayVarName, i)); params.add(new Statement() { @Override public String generate(Context context) { return s.generate(context); } @Override public MetaClass getType() { return type; } }); } return fromMethod(method, params); }
JaxrsResourceMethodParameters.fromMethod(resourceMethod.getMethod(), "parameters");