public MultivaluedMap<String, Statement> getQueryParameters() { return get(QueryParam.class); }
public List<Statement> getHeaderParameters(String name) { return getHeaderParameters().get(name); }
public Statement getCookieParameter(String name) { return getParameterByName(CookieParam.class, name); }
ContextualStatementBuilder pathValue = Stmt.loadLiteral(path); for (final String pathParamExpr : JaxrsResourceMethodParameters.getPathParameterExpressions(path)) { String pathParamId = pathParamExpr; if (pathParamExpr.contains(":")) { pathParamId = pathParamExpr.split(":")[0]; Statement pathParam = marshal(params.getPathParameter(pathParamId)); if (params.needsEncoding(pathParamId)) { pathParam = encodePath(pathParam); if (params.getMatrixParameters() != null) { for (final String matrixParamName : params.getMatrixParameters().keySet()) { pathValue = pathValue.invoke("concat", ";" + matrixParamName + "=") .invoke("concat", encodePath(marshal(params.getMatrixParameter(matrixParamName)))); if (params.getQueryParameters() != null) { urlBuilder = urlBuilder.invoke(APPEND, "?"); int i = 0; for (final String queryParamName : params.getQueryParameters().keySet()) { for (final Statement queryParam : params.getQueryParameters(queryParamName)) {
public static JaxrsResourceMethodParameters fromMethod(MetaMethod method, List<? extends Statement> parameterValues) { final JaxrsResourceMethodParameters params = new JaxrsResourceMethodParameters(); int i = 0; for (final MetaParameter param : method.getParameters()) { final Statement paramValue = parameterValues.get(i++); Annotation a = param.getAnnotation(PathParam.class); if (a != null) { params.add(PathParam.class, ((PathParam) a).value(), paramValue); } else if ((a = param.getAnnotation(QueryParam.class)) != null) { params.add(QueryParam.class, ((QueryParam) a).value(), paramValue); } else if ((a = param.getAnnotation(HeaderParam.class)) != null) { params.add(HeaderParam.class, ((HeaderParam) a).value(), paramValue); } else if ((a = param.getAnnotation(MatrixParam.class)) != null) { params.add(MatrixParam.class, ((MatrixParam) a).value(), paramValue); } else if ((a = param.getAnnotation(FormParam.class)) != null) { params.add(FormParam.class, ((FormParam) a).value(), paramValue); } else if ((a = param.getAnnotation(CookieParam.class)) != null) { params.add(CookieParam.class, ((CookieParam) a).value(), paramValue); } else { params.setEntityParameter(paramValue, method); } } return params; }
if (params.getHeaderParameters() != null) { for (final String headerParamName : params.getHeaderParameters().keySet()) { ContextualStatementBuilder headerValueBuilder = Stmt.nestedCall(Stmt.newObject(StringBuilder.class)); for (final Statement headerParam : params.getHeaderParameters(headerParamName)) { if (i++ > 0) { headerValueBuilder = headerValueBuilder.invoke(APPEND, ","); if (params.getCookieParameters() != null) { for (final String cookieName : params.getCookieParameters().keySet()) { final Statement cookieParam = params.getCookieParameters().get(cookieName).get(0);
public static JaxrsResourceMethodParameters fromMethod(MetaMethod method) { final List<Parameter> defParams = DefParameters.from(method).getParameters(); return fromMethod(method, defParams); }
/** * Generates the call to * {@link RequestBuilder#sendRequest(String, com.google.gwt.http.client.RequestCallback)} for * proxy methods. * * @return statement representing the request */ private Statement generateRequest(final ContextualStatementBuilder requestBuilder, final ContextualStatementBuilder proxy) { Statement sendRequest = null; if (resourceMethod.getParameters().getEntityParameter() == null) { sendRequest = proxy.invoke("sendRequest", requestBuilder, null, responseDemarshallingCallback()); } else { final Statement body = marshal(resourceMethod.getParameters().getEntityParameter(), resourceMethod.getContentTypeHeader()); sendRequest = proxy.invoke("sendRequest", requestBuilder, body, responseDemarshallingCallback()); } return sendRequest; }
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 MultivaluedMap<String, Statement> getMatrixParameters() { return get(MatrixParam.class); }
public Statement getMatrixParameter(String name) { return getParameterByName(MatrixParam.class, name); }
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); }
public MultivaluedMap<String, Statement> getHeaderParameters() { return get(HeaderParam.class); }
public boolean needsEncoding(String paramName) { // PathSegments are encoded in PathSegmentImpl if ((MetaClassFactory.get(PathSegment.class).equals(getParameterByName(PathParam.class, paramName).getType()))) { return false; } return true; }
JaxrsResourceMethodParameters.fromMethod(resourceMethod.getMethod(), "parameters");
public MultivaluedMap<String, Statement> getFormParameters() { return get(FormParam.class); }
public Statement getPathParameter(String name) { final Statement param = getParameterByName(PathParam.class, name); if (param == null) throw new RuntimeException("No @PathParam found with name:" + name); if (MetaClassFactory.get(PathSegment.class).equals(param.getType())) { return new Statement() { @Override public String generate(Context context) { if (param instanceof Parameter) { return Stmt.castTo(PathSegmentImpl.class, Stmt.loadVariable(((Parameter) param).getName())) .invoke("getEncodedPathWithParameters").generate(context); } else { return Stmt.castTo(PathSegmentImpl.class, param).invoke("getEncodedPathWithParameters").generate(context); } } @Override public MetaClass getType() { return MetaClassFactory.get(String.class); } }; } return param; }
public MultivaluedMap<String, Statement> getCookieParameters() { return get(CookieParam.class); }