public static Type getGenericResponseType(Method invoked, Class<?> serviceCls, Object targetObject, Class<?> targetType, Exchange exchange) { if (targetObject == null) { return null; } Type type = null; if (GenericEntity.class.isAssignableFrom(targetObject.getClass())) { type = processGenericTypeIfNeeded(serviceCls, targetType, ((GenericEntity<?>)targetObject).getType()); } else if (invoked == null || !invoked.getReturnType().isAssignableFrom(targetType)) { // when a method has been invoked it is still possible that either an ExceptionMapper // or a ResponseHandler filter overrides a response entity; if it happens then // the Type is the class of the response object, unless this new entity is assignable // to invoked.getReturnType(); same applies to the case when a method returns Response type = targetObject.getClass(); } else { type = processGenericTypeIfNeeded(serviceCls, targetType, invoked.getGenericReturnType()); } return type; } public static Class<?> updateParamClassToTypeIfNeeded(Class<?> paramCls, Type type) {
public static Type getGenericResponseType(Method invoked, Class<?> serviceCls, Object targetObject, Class<?> targetType, Exchange exchange) { if (targetObject == null) { return null; } Type type = null; if (GenericEntity.class.isAssignableFrom(targetObject.getClass())) { type = processGenericTypeIfNeeded(serviceCls, targetType, ((GenericEntity<?>)targetObject).getType()); } else if (invoked == null || !invoked.getReturnType().isAssignableFrom(targetType)) { // when a method has been invoked it is still possible that either an ExceptionMapper // or a ResponseHandler filter overrides a response entity; if it happens then // the Type is the class of the response object, unless this new entity is assignable // to invoked.getReturnType(); same applies to the case when a method returns Response type = targetObject.getClass(); } else { type = processGenericTypeIfNeeded(serviceCls, targetType, invoked.getGenericReturnType()); } return type; } public static Class<?> updateParamClassToTypeIfNeeded(Class<?> paramCls, Type type) {
Type genericParam = InjectionUtils.processGenericTypeIfNeeded( ori.getClassResourceInfo().getServiceClass(), param, genericParameterTypes[i]); param = InjectionUtils.updateParamClassToTypeIfNeeded(param, genericParam);
InjectionUtils.processGenericTypeIfNeeded(serviceCls, returnType, method.getGenericReturnType());
public static Type processGenericTypeIfNeeded(Class<?> serviceCls, Class<?> paramCls, Type type) { if (type instanceof TypeVariable) { type = InjectionUtils.getSuperType(serviceCls, (TypeVariable<?>)type); } else if (type instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)type; if (pt.getActualTypeArguments()[0] instanceof TypeVariable && isSupportedCollectionOrArray(getRawType(pt))) { TypeVariable<?> typeVar = (TypeVariable<?>)pt.getActualTypeArguments()[0]; Type theType = InjectionUtils.getSuperType(serviceCls, typeVar); if (theType instanceof Class) { type = new ParameterizedCollectionType((Class<?>)theType); } else { type = processGenericTypeIfNeeded(serviceCls, paramCls, theType); type = new ParameterizedCollectionType(type); } } } if (type == null || type == Object.class) { type = paramCls; } return type; }
InjectionUtils.processGenericTypeIfNeeded(serviceCls, returnType, method.getGenericReturnType());
InjectionUtils.processGenericTypeIfNeeded(serviceCls, returnType, method.getGenericReturnType());
genericType = bodyType; genericType = InjectionUtils.processGenericTypeIfNeeded( ori.getClassResourceInfo().getServiceClass(), bodyClass, genericType); writeBody(body, outMessage, bodyClass, genericType, anns, os);
genericType = bodyType; genericType = InjectionUtils.processGenericTypeIfNeeded( ori.getClassResourceInfo().getServiceClass(), bodyClass, genericType); bodyClass = InjectionUtils.updateParamClassToTypeIfNeeded(bodyClass, genericType);
genericType = bodyType; genericType = InjectionUtils.processGenericTypeIfNeeded( ori.getClassResourceInfo().getServiceClass(), bodyClass, genericType); bodyClass = InjectionUtils.updateParamClassToTypeIfNeeded(bodyClass, genericType);
Type theType = InjectionUtils.processGenericTypeIfNeeded( ori.getClassResourceInfo().getServiceClass(), Object.class, genericType); theActualType = InjectionUtils.getActualType(theType);
Type theType = InjectionUtils.processGenericTypeIfNeeded( ori.getClassResourceInfo().getServiceClass(), Object.class, genericType); theActualType = InjectionUtils.getActualType(theType);
if (!preferModelParams) { tuple[i].param = parameterTypes[i]; tuple[i].genericParam = InjectionUtils.processGenericTypeIfNeeded( ori.getClassResourceInfo().getServiceClass(), tuple[i].param, genericParameterTypes[i]); tuple[i].param = InjectionUtils.updateParamClassToTypeIfNeeded(tuple[i].param,
Type theType = InjectionUtils.processGenericTypeIfNeeded(serviceClass, Object.class, genericType);