private WebTarget build(WebTarget target, Object val, Object proc) { if (proc instanceof WebTargetProcessor) { WebTargetProcessor processor = (WebTargetProcessor) proc; target = processor.build(target, val); } return target; }
public static Object[] createProcessors(Class declaringClass, Method method, ClientConfiguration configuration) { return createProcessors(declaringClass, method, configuration, null); }
@Override public WebTarget build(WebTarget target, Object param) { if (param == null) return target; return (WebTarget) process(new Process() { @Override public Object process(Object target, Object value, Object processor) { return build((WebTarget)target, value, processor); } }, target, param); }
processor = new QueryParamProcessor(query.value(), genericType, annotations, configuration); processor = new QueryParamProcessor(getParamName(defaultParameterName, queryParam2.value()), genericType, annotations, configuration); processor = new HeaderParamProcessor(header.value(), genericType, annotations, configuration); processor = new HeaderParamProcessor(getParamName(defaultParameterName, header2.value()), genericType, annotations, configuration); processor = new CookieParamProcessor(cookie.value(), genericType, annotations); processor = new CookieParamProcessor(getParamName(defaultParameterName, cookie2.value()), genericType, annotations); processor = new PathParamProcessor(uriParam.value(), isEncoded, genericType, annotations, configuration); processor = new PathParamProcessor(getParamName(defaultParameterName, uriParam2.value()), isEncoded, genericType, annotations, configuration); processor = new MatrixParamProcessor(matrix.value(), genericType, annotations, configuration); processor = new MatrixParamProcessor(getParamName(defaultParameterName, matrix2.value()), genericType, annotations, configuration); processor = new FormParamProcessor(formParam.value(), genericType, annotations, configuration); processor = new FormParamProcessor(getParamName(defaultParameterName, formParam2.value()), genericType, annotations, configuration); processor = new FormProcessor(type, configuration, defaultParameterName); processor = new FormProcessor(type, configuration, defaultParameterName); processor = new CookieParamProcessor(null);
Type genericType = field.getGenericType(); Object processor = ProcessorFactory.createProcessor( clazz, defaultFormName, configuration, type, annotations, genericType, field, true); if (processor != null) .createProcessor(clazz, defaultFormName, configuration, type, annotations, genericType, method, true); if (processor != null) try hash = methodHash(method); getters.add(new GetterMethod(method, processor)); getterHashes.put(hash, method); populateMap(clazz.getSuperclass(), configuration, defaultFormName);
public static long methodHash(Method method) throws Exception { Class[] parameterTypes = method.getParameterTypes(); StringBuilder methodDesc = new StringBuilder(method.getName()).append("("); for (int j = 0; j < parameterTypes.length; j++) { methodDesc.append(getTypeString(parameterTypes[j])); } methodDesc.append(")").append(getTypeString(method.getReturnType())); return createHash(methodDesc.toString()); }
public static Object[] createProcessors(Class declaringClass, Method method, ClientConfiguration configuration, MediaType defaultConsumes) { Object[] params = new Object[method.getParameterTypes().length]; for (int i = 0; i < method.getParameterTypes().length; i++) { String parameterName = method.getParameters()[i].getName(); Class<?> type = method.getParameterTypes()[i]; Annotation[] annotations = method.getParameterAnnotations()[i]; Type genericType = method.getGenericParameterTypes()[i]; if (TypeVariable.class.isInstance(genericType) && declaringClass.isInterface() && !declaringClass.equals(method.getDeclaringClass())) { genericType = getTypeArgument((TypeVariable)genericType, declaringClass, method.getDeclaringClass()); } AccessibleObject target = method; params[i] = ProcessorFactory.createProcessor(declaringClass, parameterName, configuration, type, annotations, genericType, target, defaultConsumes, false); } return params; }
protected ClientInvocation createRequest(Object[] args) { WebTarget target = this.webTarget; for (int i = 0; i < processors.length; i++) { if (processors != null && processors[i] instanceof WebTargetProcessor) { WebTargetProcessor processor = (WebTargetProcessor)processors[i]; target = processor.build(target, args[i]); } } ClientConfiguration parentConfiguration=(ClientConfiguration) target.getConfiguration(); ClientInvocation clientInvocation = new ClientInvocation(this.webTarget.getResteasyClient(), target.getUri(), new ClientRequestHeaders(parentConfiguration), parentConfiguration); clientInvocation.setClientInvoker(this); if (accepts != null) { clientInvocation.getHeaders().accept(accepts); } for (int i = 0; i < processors.length; i++) { if (processors != null && processors[i] instanceof InvocationProcessor) { InvocationProcessor processor = (InvocationProcessor)processors[i]; processor.process(clientInvocation, args[i]); } } clientInvocation.setMethod(httpMethod); return clientInvocation; }
public FormProcessor(final Class clazz, final ClientConfiguration configuration, final String defaultFormName) { this.clazz = clazz; populateMap(clazz, configuration, defaultFormName); }
static void recursivePush(Type t, Class<?> baseInterface, Stack<Type> superinterfaces) { Class<?> currentClass = null; if (t instanceof Class) { currentClass = (Class) t; } else if (t instanceof ParameterizedType) { currentClass = (Class) ((ParameterizedType) t).getRawType(); } if (baseInterface.isAssignableFrom(currentClass)) { superinterfaces.push(t); for (Type otherType : currentClass.getGenericInterfaces()) { recursivePush(otherType, baseInterface, superinterfaces); } } } }
private void processParam(ClientInvocation invocation, Object val, Object proc) { if (proc instanceof InvocationProcessor) { InvocationProcessor processor = (InvocationProcessor) proc; processor.process(invocation, val); } } }
return "[" + getTypeString(cl.getComponentType());
target = apply(target, object); target = apply(target, obj); target = apply(target, object); if (componentType.equals(boolean.class)) for (boolean bool : (boolean[]) object) target = apply(target, bool); for (byte val : (byte[]) object) target = apply(target, val); for (short val : (short[]) object) target = apply(target, val); for (int val : (int[]) object) target = apply(target, val); for (long val : (long[]) object) target = apply(target, val); for (float val : (float[]) object) target = apply(target, val); for (double val : (double[]) object) target = apply(target, val); for (Object obj : objs) target = apply(target, obj); target = apply(target, object);
@Override public void process(ClientInvocation invocation, Object param) { process(new Process() { @Override public Object process(Object target, Object value, Object processor) { processParam((ClientInvocation)target, value, processor); return target; } }, invocation, param); }
private WebTarget build(WebTarget target, Object val, Object proc) { if (proc instanceof WebTargetProcessor) { WebTargetProcessor processor = (WebTargetProcessor) proc; target = processor.build(target, val); } return target; }
this.processors = ProcessorFactory.createProcessors(declaring, method, invokerConfig, config.getDefaultConsumes()); accepts = MediaTypeHelper.getProduces(declaring, method, config.getDefaultProduces()); entityExtractorFactory = new DefaultEntityExtractorFactory();
public FormProcessor(Class clazz, ClientConfiguration configuration) { this.clazz = clazz; populateMap(clazz, configuration); }
Type currentType; Class<?> currentClass = clazz; recursivePush(currentClass, baseInterface, superinterfaces);
@Override public void process(ClientInvocationBuilder invocation, Object param) { process(new Process() { @Override public Object process(Object target, Object value, Object processor) { processParam((ClientInvocationBuilder)target, value, processor); return target; } }, invocation, param); }