Examples of Ioc


Examples of org.eweb4j.mvc.action.annotation.Ioc

      return;

    for (Field f : fields) {
      Class<?> type = f.getType();

      Ioc ioc = f.getAnnotation(Ioc.class);
      if (ioc == null)
        continue;
      String beanId = "";
      if (ioc.value().trim().length() == 0)
        beanId = type.getSimpleName();
      else
        beanId = StringUtil.parsePropValue(ioc.value());

      Method setter = ru.getSetter(f.getName());
      if (setter == null)
        continue;
View Full Code Here

Examples of org.eweb4j.mvc.action.annotation.Ioc

    if (fields == null)
      return;

    for (Field f : fields) {
      Class<?> type = f.getType();
      Ioc ioc = f.getAnnotation(Ioc.class);
      if (ioc == null)
        continue;
      String beanId = "";
      if (ioc.value().trim().length() == 0)
        beanId = type.getSimpleName();
      else
        beanId = StringUtil.parsePropValue(ioc.value());

      Method setter = ru.getSetter(f.getName());
      if (setter == null)
        continue;
View Full Code Here

Examples of org.nutz.ioc.Ioc

    RequestIocContext reqContext = null;
    try {
      if (null != moduleObj) {
        ac.setModule(moduleObj);
      } else {
        Ioc ioc = ac.getIoc();
        if (null == ioc)
          throw Lang.makeThrow"Moudle with @InjectName('%s') but you not declare a Ioc for this app",
                      injectName);
        Object obj;
        /*
         * 如果 Ioc 容器实现了高级接口,那么会为当前请求设置上下文对象
         */
        if (ioc instanceof Ioc2) {
          reqContext = new RequestIocContext(ac.getRequest());
          SessionIocContext sessionContext = new SessionIocContext(ac.getRequest()
                                        .getSession());
          IocContext myContext = new ComboContext(reqContext, sessionContext);
          obj = ((Ioc2) ioc).get(moduleType, injectName, myContext);
        }
        /*
         * 否则,则仅仅简单的从容器获取
         */
        else
          obj = ioc.get(moduleType, injectName);
        ac.setModule(obj);

      }
      ac.setMethod(method);
      doNext(ac);
View Full Code Here

Examples of org.nutz.ioc.Ioc

  }

  private static Map<String, Ioc> nuts = new HashMap<String, Ioc>();

  public static Ioc getIoc(String key) {
    Ioc nut = nuts.get(key);
    if (null == nut) {
      synchronized (Nutzs.class) {
        nut = nuts.get(key);
        try {
          if (null == nut) {
View Full Code Here

Examples of org.nutz.ioc.Ioc

  static String J(String name, String s) {
    return name + " : {" + s + "}";
  }

  static Animal A(String s) {
    Ioc ioc = I(J("obj", s));
    return ioc.get(Animal.class, "obj");
  }
View Full Code Here

Examples of org.nutz.ioc.Ioc

  public void test_init_with_field() {
    String s = "fields: {name:'Fox'},";
    s = s + "\nevents:{";
    s = s + "\n  create: 'org.nutz.ioc.json.pojo.WhenCreateFox'";
    s = s + "\n}";
    Ioc ioc = I(J("fox", s));

    Animal fox = ioc.get(Animal.class, "fox");
    assertEquals("$Fox", fox.getName());
  }
View Full Code Here

Examples of org.nutz.ioc.Ioc

    s = s + "\nevents:{";
    s = s + "\n  fetch: 'onFetch',";
    s = s + "\n  create: 'onCreate',";
    s = s + "\n  depose: 'onDepose'";
    s = s + "\n}";
    Ioc ioc = I(J("fox", s));

    Animal f = ioc.get(Animal.class, "fox");
    assertEquals(1, f.getCreateTime());
    assertEquals(1, f.getFetchTime());
    assertEquals(0, f.getDeposeTime());

    ioc.get(Animal.class, "fox");

    assertEquals(1, f.getCreateTime());
    assertEquals(2, f.getFetchTime());
    assertEquals(0, f.getDeposeTime());

    ioc.reset();
    assertEquals(1, f.getCreateTime());
    assertEquals(2, f.getFetchTime());
    assertEquals(1, f.getDeposeTime());
  }
View Full Code Here

Examples of org.nutz.ioc.Ioc

    s = s + "\nevents:{";
    s = s + "\n  fetch: 'onFetch',";
    s = s + "\n  create: 'onCreate',";
    s = s + "\n  depose: 'onDepose'";
    s = s + "\n}";
    Ioc ioc = I(J("fox", s));

    Animal f = ioc.get(Animal.class, "fox");
    assertEquals(1, f.getCreateTime());
    assertEquals(1, f.getFetchTime());
    assertEquals(0, f.getDeposeTime());

    ioc.get(Animal.class, "fox");

    assertEquals(1, f.getCreateTime());
    assertEquals(1, f.getFetchTime());
    assertEquals(0, f.getDeposeTime());

    ioc.reset();
    assertEquals(1, f.getCreateTime());
    assertEquals(1, f.getFetchTime());
    assertEquals(0, f.getDeposeTime());
  }
View Full Code Here

Examples of org.nutz.ioc.Ioc

    s = s + "\nevents:{";
    s = s + "\n  fetch: 'org.nutz.ioc.json.pojo.WhenFetchAnimal',";
    s = s + "\n  create: 'org.nutz.ioc.json.pojo.WhenCreateAnimal',";
    s = s + "\n  depose: 'org.nutz.ioc.json.pojo.WhenDeposeAnimal'";
    s = s + "\n}";
    Ioc ioc = I(J("fox", s));

    Animal f = ioc.get(Animal.class, "fox");
    assertEquals(10, f.getCreateTime());
    assertEquals(10, f.getFetchTime());
    assertEquals(0, f.getDeposeTime());

    ioc.get(Animal.class, "fox");

    assertEquals(10, f.getCreateTime());
    assertEquals(20, f.getFetchTime());
    assertEquals(0, f.getDeposeTime());

    ioc.reset();
    assertEquals(10, f.getCreateTime());
    assertEquals(20, f.getFetchTime());
    assertEquals(10, f.getDeposeTime());
  }
View Full Code Here

Examples of org.nutz.ioc.Ioc

    s = s + "\nevents:{";
    s = s + "\n  fetch: 'org.nutz.ioc.json.pojo.WhenFetchAnimal',";
    s = s + "\n  create: 'org.nutz.ioc.json.pojo.WhenCreateAnimal',";
    s = s + "\n  depose: 'org.nutz.ioc.json.pojo.WhenDeposeAnimal'";
    s = s + "\n}";
    Ioc ioc = I(J("fox", s));

    Animal f = ioc.get(Animal.class, "fox");
    assertEquals(10, f.getCreateTime());
    assertEquals(10, f.getFetchTime());
    assertEquals(0, f.getDeposeTime());

    ioc.get(Animal.class, "fox");

    assertEquals(10, f.getCreateTime());
    assertEquals(10, f.getFetchTime());
    assertEquals(0, f.getDeposeTime());

    ioc.reset();
    assertEquals(10, f.getCreateTime());
    assertEquals(10, f.getFetchTime());
    assertEquals(0, f.getDeposeTime());
  }
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.