private String sseMethod;
public MethodInfo(Class<?> clazz, ApplicationContext context, String beanName, Method method) {
ExtDirectMethod extDirectMethodAnnotation = AnnotationUtils.findAnnotation(method, ExtDirectMethod.class);
this.type = extDirectMethodAnnotation.value();
if (extDirectMethodAnnotation.jsonView() != ExtDirectMethod.NoJsonView.class) {
this.jsonView = extDirectMethodAnnotation.jsonView();
} else {
this.jsonView = null;
}
if (StringUtils.hasText(extDirectMethodAnnotation.group())) {
this.group = extDirectMethodAnnotation.group().trim();
} else {
this.group = null;
}
this.synchronizeOnSession = extDirectMethodAnnotation.synchronizeOnSession();
this.streamResponse = extDirectMethodAnnotation.streamResponse();
if (type != ExtDirectMethodType.FORM_POST) {
this.method = method;
this.parameters = buildParameterList(clazz, method);
this.collectionType = (extDirectMethodAnnotation.entryClass() == Object.class) ? null
: extDirectMethodAnnotation.entryClass();
if (this.collectionType == null) {
for (ParameterInfo parameter : parameters) {
Class<?> collType = parameter.getCollectionType();
if (collType != null) {
this.collectionType = collType;
break;
}
}
}
} else {
if (method.getReturnType().equals(Void.TYPE)) {
RequestMapping methodAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
RequestMapping classAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);
String path = null;
if (hasValue(classAnnotation)) {
path = classAnnotation.value()[0];
}
if (hasValue(methodAnnotation)) {
String methodPath = methodAnnotation.value()[0];
if (path != null) {
path = path + methodPath;
} else {
path = methodPath;
}
}
if (path != null) {
if (path.charAt(0) == '/' && path.length() > 1) {
path = path.substring(1, path.length());
}
this.forwardPath = "forward:" + path;
}
} else {
this.handlerMethod = new HandlerMethod(beanName, context, method).createWithResolvedBean();
}
}
switch (type) {
case SIMPLE:
int paramLength = 0;
for (ParameterInfo parameter : this.parameters) {
if (!parameter.isSupportedParameter() && !parameter.isHasRequestHeaderAnnotation()) {
paramLength++;
}
}
this.action = new Action(method.getName(), paramLength, null);
break;
case SIMPLE_NAMED:
List<String> parameterNames = new ArrayList<String>();
for (ParameterInfo parameter : this.parameters) {
if (!parameter.isSupportedParameter() && !parameter.isHasRequestHeaderAnnotation()) {
parameterNames.add(parameter.getName());
}
}
this.action = new Action(method.getName(), parameterNames);
break;
case FORM_LOAD:
case STORE_READ:
case STORE_MODIFY:
case TREE_LOAD:
this.action = new Action(method.getName(), 1, null);
break;
case FORM_POST:
this.action = new Action(method.getName(), 0, true);
break;
case FORM_POST_JSON:
this.action = new Action(method.getName(), 1, null);
break;
case POLL:
this.pollingProvider = new PollingProvider(beanName, method.getName(), extDirectMethodAnnotation.event());
break;
case SSE:
this.sseMethod = method.getName();
break;
default:
throw new IllegalStateException("ExtDirectMethodType: " + type + " does not exists");
}
this.action = extractDocumentationAnnotations(extDirectMethodAnnotation.documentation());
}