this.handlingMethod = handlingMethod == null ? ReflectionHelper
.findOverridingMethodOnClass(handler.getHandlerClass(), definitionMethod) : handlingMethod;
final Class<?> handlerClass = handler.getHandlerClass();
final Class<?> definitionClass = definitionMethod.getDeclaringClass();
final ClassTypePair handlingCtPair = ReflectionHelper.resolveGenericType(
handlerClass,
this.handlingMethod.getDeclaringClass(),
this.handlingMethod.getReturnType(),
this.handlingMethod.getGenericReturnType());
// here we need to find types also for definition method. Definition method is in most
// cases used for parent methods (for example for interface method of resource class). But here we
// consider also situation when resource is a proxy (for example proxy of EJB) and definition
// method is the original method and handling method is method on proxy. So, we try to find generic
// type in the original class using definition method.
final ClassTypePair definitionCtPair = ReflectionHelper.resolveGenericType(
definitionClass,
this.definitionMethod.getDeclaringClass(),
this.definitionMethod.getReturnType(),
this.definitionMethod.getGenericReturnType());
this.rawResponseType = handlingCtPair.rawClass();
final boolean handlerReturnTypeIsParameterized = handlingCtPair.type() instanceof ParameterizedType;
final boolean definitionReturnTypeIsParameterized = definitionCtPair.type() instanceof ParameterizedType;
this.responseType =
(handlingCtPair.rawClass() == definitionCtPair.rawClass()
&& definitionReturnTypeIsParameterized && !handlerReturnTypeIsParameterized)
? definitionCtPair.type() : handlingCtPair.type();
if (routingResponseType == null) {
this.routingResponseType = responseType;
this.rawRoutingResponseType = rawResponseType;
} else {
GenericType routingResponseGenericType = new GenericType(routingResponseType);