Search in sources :

Example 1 with Result

use of org.eweb4j.mvc.action.annotation.Result in project eweb4j-framework by laiweiwei.

the class ActionAnnotationConfig method handleActionConfigInfo.

/**
	 * 处理Action配置信息
	 * 
	 * @param ru
	 * @param controller
	 * @param method
	 * @param moduleName
	 */
private void handleActionConfigInfo(ReflectUtil ru, Class<?> controller, Method method, String moduleName) {
    //log.debug("now parse the method...... moduleName->" + moduleName);
    // 这一步解析约定好的方法名doXxxAtXxx
    final ActionConfigBean action = parseUriMappingSuffix(moduleName, method);
    //log.debug("parse uri mapping by default rule -> " + action);
    if (action == null)
        return;
    action.setClazz(controller.getName());
    action.setMethod(method.getName());
    /* 解析出验证器错误信息输出类型 */
    //		action.setShowValErrorType(parseShowValErrType(controller, method));
    /* 解析出Http Method */
    String httpMethod = parseHttpMethodByAnnotation(controller, method);
    // 如果方法上的注解不为空则覆盖约定好的
    if (httpMethod != null && httpMethod.trim().length() > 0)
        action.setHttpMethod(httpMethod);
    //log.debug("parse httpMethod -> " + httpMethod);
    /* 解析出最终的uriMapping */
    String uriMapping = parseUriMapping(controller, moduleName, action.getUriMapping());
    //log.debug("parse uriMapping -> " + uriMapping);
    if (uriMapping != null && uriMapping.trim().length() > 0)
        action.setUriMapping(uriMapping);
    // 解析@Result注解
    Result resultAnn = method.getAnnotation(Result.class);
    if (resultAnn != null)
        action.getResult().addAll(ResultAnnUtil.readResultAnn(resultAnn));
    /* 解析@ActionLevel */
    int level = parseActionLevel(controller, method);
    action.setLevel(String.valueOf(level));
    /* 解析@Produces */
    List<String> pcbs = parseProduces(method);
    if (pcbs != null)
        action.getProduces().addAll(pcbs);
    /* 解析@Validator和各种验证器 */
    List<ValidatorConfigBean> vals = parseValidators(ru, method);
    if (vals != null)
        action.getValidator().addAll(vals);
    /* 解析最终的actionKey (包括合并http method、正则等) */
    String actionConfigKey = parseFullUriMapping(controller, method, action.getHttpMethod(), action.getUriMapping());
    //log.debug("parse actionConfigKey -> " + actionConfigKey);
    if (actionConfigKey == null)
        return;
    // 将读取成功的配置信息放入缓存供框架运行期使用
    //log.debug("action cache add key -> "+actionConfigKey + ", action->"  + action);
    ActionConfigBeanCache.add(actionConfigKey, action);
    ActionClassCache.add(action.getClazz(), controller);
}
Also used : ValidatorConfigBean(org.eweb4j.mvc.config.bean.ValidatorConfigBean) ActionConfigBean(org.eweb4j.mvc.config.bean.ActionConfigBean) Result(org.eweb4j.mvc.action.annotation.Result)

Aggregations

Result (org.eweb4j.mvc.action.annotation.Result)1 ActionConfigBean (org.eweb4j.mvc.config.bean.ActionConfigBean)1 ValidatorConfigBean (org.eweb4j.mvc.config.bean.ValidatorConfigBean)1