Examples of ActionConfigBean


Examples of org.eweb4j.mvc.config.bean.ActionConfigBean

    for (Iterator<Entry<Object, ActionConfigBean>> it = ACTION_CFG_BEAN
        .entrySet().iterator(); it.hasNext();) {

      Entry<Object, ActionConfigBean> entry = it.next();
      Object beanID = entry.getKey();
      ActionConfigBean mvcBean = entry.getValue();
      if (String.class.isAssignableFrom(beanID.getClass())) {
        // 如果是String
        String regex = String.valueOf(beanID).replace(
            "@" + mvcBean.getReqMethod(), "");
        if (regex.contains("{") || regex.contains("}"))
          continue;

        if (aUri.endsWith("/"))
          uri = aUri.substring(0, aUri.length() - 1);

        if (regex.endsWith("/"))
          regex = regex.substring(0, regex.length() - 1);

        String[] methods = mvcBean.getReqMethod().split("\\|");
        boolean checkMethod = false;
        for (String m : methods) {
          if (m.trim().equalsIgnoreCase(reqMethod)) {
            checkMethod = true;
            break;
          }
        }
        if (regex != null && checkMethod && uri.matches(regex)) {
          LogFactory.getMVCLogger("INFO").write(
              "req uri -> " + uri + " | regex -> " + regex);
          result = new HashMap<String, List<?>>();
          // 1.hello/{name}/test/{id}
          // 2.{"hello/","{name}","/test/{id}"}
          String urlMapping = mvcBean.getName();
          // 如果urlMapping的开头是“/”要去掉
          if (urlMapping.startsWith("/"))
            urlMapping = urlMapping.substring(1);

          String pattern = RegexList.path_var_regexp;
View Full Code Here

Examples of org.eweb4j.mvc.config.bean.ActionConfigBean

      if (!ACTION_CFG_BEAN.containsKey(beanID)) {
        ACTION_CFG_BEAN.put(beanID, o);
        info = "ActionConfigBeanCache:add...finished..." + beanID;
      } else {
        ActionConfigBean actionBean = ACTION_CFG_BEAN.get(beanID);
        if (actionBean != null) {
          String level1 = actionBean.getLevel();
          String level2 = o.getLevel();
          if (level1 == null || level1.trim().length() == 0)
            level1 = "1";

          if (level2 == null || level2.trim().length() == 0)
            level2 = "1";

          int level_1 = 1;
          int level_2 = 1;

          if (level1.matches(RegexList.integer_regexp))
            level_1 = Integer.parseInt(level1);

          if (level2.matches(RegexList.integer_regexp))
            level_2 = Integer.parseInt(level2);

          if (level_2 > level_1) {
            ACTION_CFG_BEAN.remove(beanID);
            ACTION_CFG_BEAN.put(beanID, o);
            info = "ActionConfigBeanCache: "
                + actionBean.getClazz() + "#"
                + actionBean.getMethod() + "#uri-mapping:"
                + beanID + " 的优先级[" + level_1 + "]低于"
                + o.getClazz() + "." + o.getMethod()
                + "#uri-mapping:" + beanID + "的优先级[" + level_2
                + "],因此被替换。";
          } else {
View Full Code Here

Examples of org.eweb4j.mvc.config.bean.ActionConfigBean

      String info = null;
      if (!ACTION_CFG_BEAN.containsKey(clazz)) {
        ACTION_CFG_BEAN.put(clazz, o);
        info = "ActionConfigBeanCache:add...finished..." + clazz;
      } else {
        ActionConfigBean actionBean = ACTION_CFG_BEAN.get(clazz);
        if (actionBean != null) {
          String level1 = actionBean.getLevel();
          String level2 = o.getLevel();
          if (level1 == null || level1.trim().length() == 0)
            level1 = "1";

          if (level2 == null || level2.trim().length() == 0)
View Full Code Here

Examples of org.eweb4j.mvc.config.bean.ActionConfigBean

  }

  public static ActionConfigBean get(String beanID) {
    System.out.println(">>>>>>>>>>>>>>>>>>" + beanID
        + ">>>>>>>>>>>>>>>>>>>>>");
    ActionConfigBean o = null;
    if (beanID != null)
      if (ACTION_CFG_BEAN.containsKey(beanID))
        o = ACTION_CFG_BEAN.get(beanID);

    return o;
View Full Code Here

Examples of org.eweb4j.mvc.config.bean.ActionConfigBean

    return o;
  }

  public static ActionConfigBean get(Class<?> clazz) {
    ActionConfigBean o = null;
    if (clazz != null)
      if (ACTION_CFG_BEAN.containsKey(clazz))
        o = ACTION_CFG_BEAN.get(clazz);

    return o;
View Full Code Here

Examples of org.eweb4j.mvc.config.bean.ActionConfigBean

  private PrintWriter writer;

  public String doHelloWorld() throws Exception {

    // 当前执行Action的配置对象,保存着个跟该Action相关的配置信息
    ActionConfigBean acb = context.getMvcBean();

    // 当前执行Action的Properties读写对象
    // start.xml中<file ID=Action完整类名的所对应的那个配置文件
    ActionProp prop = context.getActionProp();
    prop.read("key");
View Full Code Here

Examples of org.eweb4j.mvc.config.bean.ActionConfigBean

    if (ActionConfigBeanCache.containsKey(this.context.getUri())
        || (map = ActionConfigBeanCache.getByMatches(
            this.context.getUri(), context.getHttpMethod())) != null) {
      // 找到了action 与当前访问的uri映射
      if (map.containsKey("mvcBean")) {
        ActionConfigBean acb = (ActionConfigBean) map.get("mvcBean")
            .get(0);
        this.context.setMvcBean(acb);
        result = true;
      }
View Full Code Here

Examples of org.eweb4j.mvc.config.bean.ActionConfigBean

          error = rebuildXmlFile(configFile,
              ConfigErrCons.CANNOT_READ_CONFIG_INFO);
        } else {
          for (Iterator<ActionConfigBean> it = mvcList.iterator(); it
              .hasNext();) {
            ActionConfigBean mvc = it.next();

            // 检查MVC.Action配置是否有错误
            String error1 = CheckConfigBean.checkMVCAction(mvc,
                filePath);
            if (error1 != null)
              if (error != null)
                error += error1;
              else
                error = error1;

            // 检查MVC.Action中的Result部分配置是否有错误
            String error2 = CheckConfigBean.checkMVCResultPart(
                mvc.getResult(), mvc.getName(), filePath);
            if (error2 != null)
              if (error != null)
                error += error2;
              else
                error = error2;

            // 检查MVC.Action.Validator中的部分配置是否有错误
            String error4 = CheckConfigBean.checkMVCValidator(
                mvc.getValidator(), mvc.getName(), filePath);
            if (error4 != null)
              if (error != null)
                error += error4;
              else
                error = error4;
          }

          // 如果没有任何错误,将Action的配置信息放入缓存,供框架运行期使用
          if (error == null)
            for (Iterator<ActionConfigBean> it = mvcList.iterator(); it
                .hasNext();) {
              ActionConfigBean mvc = it.next();
              if (!"".equals(mvc.getClazz()))
                if (!"".equals(mvc.getName()))
                  ActionConfigBeanCache.add(mvc.getName(),
                      mvc);
            }
        }
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here

Examples of org.eweb4j.mvc.config.bean.ActionConfigBean

          rcb.setType(MVCConfigConstant.FORWARD_TYPE);
          rcb.setLocation(retn);
        }
      }
    }
    ActionConfigBean action = new ActionConfigBean();
    action.setShowValErrorType(showValMess == null ? valErrType
        : showValMess);
    action.setClazz(clazzName);
    action.setMethod(methodName);
    action.setName(actionName);
    action.setReqMethod(reqMethod);

    // 读取@ActionLevel注解
    ActionLevel actionLevel = cls.getAnnotation(ActionLevel.class);
    if (actionLevel == null)
      actionLevel = m.getAnnotation(ActionLevel.class);
    int level = 1;
    if (actionLevel != null)
      level = actionLevel.value();

    action.setLevel(String.valueOf(level));

    // 读取@Produces注解
    Produces producesAnn = m.getAnnotation(Produces.class);
    if (producesAnn != null) {
      String producesStr = StringUtil
          .parsePropValue(producesAnn.value()[0]);
      action.getProduces().add(producesStr);
    }

    // 读取@Result注解
    Result resultAnn = m.getAnnotation(Result.class);
    if (resultAnn != null)
      action.setResult(ResultAnnUtil.readResultAnn(resultAnn));

    if (rcb != null)
      action.getResult().add(rcb);

    // 读取@Validator注解
    Validator validatorAnn = m.getAnnotation(Validator.class);
    if (validatorAnn != null)
      action.setValidator(ValidatorUtil.readValidator(validatorAnn,
          m.getAnnotation(ValField.class),
          m.getAnnotation(ValMess.class),
          m.getAnnotation(ValParamName.class),
          m.getAnnotation(ValParam.class)));

    // 读取Action object 的属性 验证信息
    List<ValidatorConfigBean> vals = ValidatorUtil.readValidator(null, ru,
        null, null);
    if (vals != null)
      action.setValidator(vals);

    // Action全名,框架用,包括对“{xxx}”url参数的正则化,HttpRequestMethod
    String actionFullName = ActionUrlUtil.mathersUrlMapping(m, actionName,
        cls);
    if (actionFullName == null)
View Full Code Here

Examples of org.eweb4j.mvc.config.bean.ActionConfigBean

   
    Map<String, List<?>> map = null;
    if (ActionConfigBeanCache.containsKey(this.context.getUri()) || (map = ActionConfigBeanCache.getByMatches(this.context.getUri(), context.getHttpMethod())) != null) {
      // 找到了action 与当前访问的uri映射
      if (map.containsKey("mvcBean")) {
        ActionConfigBean acb = (ActionConfigBean) map.get("mvcBean").get(0);
        this.context.setActionConfigBean(acb);
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.