public JaxrsProxyGenerator(MetaClass remote, final GeneratorContext context, final InterceptorProvider interceptorProvider, Multimap<MetaClass, MetaClass> exceptionMappers) { this.remote = remote; this.context = context; this.exceptionMappers = exceptionMappers; this.rootResourcePath = remote.getAnnotation(Path.class).value(); this.headers = JaxrsHeaders.fromClass(remote); this.interceptorProvider = interceptorProvider; }
public Map<String, String> getHeaders() { Map<String, String> headers = new HashMap<String, String>(); if (resourceClassHeaders.get() != null) headers.putAll(resourceClassHeaders.get()); if (methodHeaders.get() != null) headers.putAll(methodHeaders.get()); return Collections.unmodifiableMap(headers); }
/** * Generates HTTP headers based on the JAX-RS annotations on the provided class or interface. * * @param clazz the JAX-RS resource class * @return headers */ public static JaxrsHeaders fromClass(MetaClass clazz) { JaxrsHeaders headers = new JaxrsHeaders(); Produces p = clazz.getAnnotation(Produces.class); if (p != null) { headers.setAcceptHeader(p.value()); } Consumes c = clazz.getAnnotation(Consumes.class); if (c != null) { headers.setContentTypeHeader(c.value()); } return headers; }
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; }
/** * Generates HTTP headers based on the JAX-RS annotations on the provided method. * * @param clazz the JAX-RS resource class * @return headers */ public static JaxrsHeaders fromMethod(MetaMethod method) { JaxrsHeaders headers = new JaxrsHeaders(); Produces p = method.getAnnotation(Produces.class); if (p != null) { headers.setAcceptHeader(p.value()); } Consumes c = method.getAnnotation(Consumes.class); if (c != null) { headers.setContentTypeHeader(c.value()); } return headers; }
public JaxrsHeaders(JaxrsHeaders headers) { this.headers.putAll(headers.get()); }