Ejemplo n.º 1
0
  /**
   * 初始化获取配置文件的方法 C方法没有调用N,阻止了无限的递归
   *
   * @param one String
   * @param index
   * @return
   * @throws Exception
   */
  public static String C(String one, String index) {

    // 全部小写
    String key = Common.getKey(one, index);

    // 存在即返回
    if (_System.getConfigs().containsKey(key)) return _System.getConfigs().get(key);

    // 如果不存在,实例化并且获取配置值
    String tmp = null;
    try {
      tmp =
          ((_Config)
                  Common.N(
                      _System.getConfigs().get(Common.getKey("System_Config", "syspath"))
                          + "Config."
                          + one))
              .get(index);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    // 缓存对象
    _System.getConfigs().put(key, tmp);

    return tmp;
  }
Ejemplo n.º 2
0
 /**
  * @param name String 需要实例化的全名
  * @return
  * @access public
  * @static
  */
 public static Object N(String name) {
   try {
     return Common.N(Class.forName(name));
   } catch (ClassNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return null;
 } // end of N()
Ejemplo n.º 3
0
  /**
   * A方法用于实例化controller
   *
   * @param null
   * @return Object(Controller)
   * @throws Exception
   * @access public
   */
  public static _Controller A(String name) throws Exception {

    if (name == null) throw new Exception("no such controller");

    // 没有后缀自适应
    if (!name.endsWith("_Controller")) name = name + "_Controller";
    // 没有前缀自适应
    if (!name.startsWith(C("System_Config", "apppath")))
      name = C("System_Config", "apppath") + "Controller." + name;
    return (_Controller) Common.N(name);
  } // end of _Controller
Ejemplo n.º 4
0
  /**
   * M()用于实例化Model
   *
   * @param name
   * @return
   */
  public static _Model M(String name) {

    if (name == null) return null;

    if (!name.endsWith("_Model")) return null;
    // 组织路径
    String forName = null;
    forName = "MPD.app.Model." + name;

    return (_Model) Common.N(forName);
  }
Ejemplo n.º 5
0
  /**
   * 实例化H方法
   *
   * @param name
   * @return
   */
  public static _Helper H(String name) {
    if (name == null) return null;
    HashMap<String, String> h = Common.parseName(name);

    if (h.get("self") == "" || h.get("parent") == "" || h.get("fullname") == "") return null;

    if (!h.get("parent").equals("Helper")) return null;

    // 组织路径
    String forName = null;
    forName = "MPD.sys." + h.get("fullname");

    return (_Helper) Common.N(forName);
  } // end of H()