private void validateActionReturnType(Method actionMethod, String className) {
Class<?> returnType = actionMethod.getReturnType();
if (returnType.equals(Void.TYPE)) {
throw new ConfigurationException("action " + actionMethod.getName() + " in controller "
+ className + " must return " + View.class.getName() + " or one of its subtypes, " +
"or an object to be marshalled, but not void");
} else if (!View.class.isAssignableFrom(returnType) &&
actionMethod.getAnnotation(Returns.class) == null) {
throw new ConfigurationException("action " + actionMethod.getName() + " in controller "
+ className + " does not return a " + View.class.getName() + " or one of its subtypes " +
"and does not specify a @" + Returns.class.getName() + " annotation");
} else if (View.class.isAssignableFrom(returnType) &&
actionMethod.getAnnotation(Returns.class) != null) {
throw new ConfigurationException("action " + actionMethod.getName() + " in controller "
+ className + " returns a " + View.class.getName() + " or one of its subtypes " +
"and specifies a @" + Returns.class.getName() + " annotation");
}
}