Examples of Ioc


Examples of org.nutz.ioc.Ioc

    assertEquals("__W", wolf.getName());
  }

  @Test
  public void test_parent() {
    Ioc ioc = I(J("fox", "name:'P',age:10"), J("f2", "parent:'fox',fields:{age:5}"));
    Animal fox = ioc.get(Animal.class, "fox");
    assertEquals("P", fox.getName());
    assertEquals(10, fox.getAge());
    Animal f2 = ioc.get(Animal.class, "f2");
    assertEquals("P", f2.getName());
    assertEquals(5, f2.getAge());
  }
View Full Code Here

Examples of org.nutz.ioc.Ioc

    assertEquals(5, f2.getAge());
  }

  @Test
  public void test_muilt_parent() {
    Ioc ioc = I(J("fox", "name:'P',age:10"), J("f2", "parent:'fox'"), J("f3", "parent:'f2'"));
    Animal f3 = ioc.get(Animal.class, "f3");
    assertEquals(10, f3.getAge());
  }
View Full Code Here

Examples of org.nutz.ioc.Ioc

    assertEquals(10, f3.getAge());
  }

  @Test
  public void test_create_by_args() {
    Ioc ioc = I(J("fox", "age:10"), J("xb", "parent:'fox',args:['XiaoBai']"));
    Animal xb = ioc.get(Animal.class, "xb");
    assertEquals("XiaoBai", xb.getName());
  }
View Full Code Here

Examples of org.nutz.ioc.Ioc

    assertEquals("XiaoBai", xb.getName());
  }

  @Test(expected = IocException.class)
  public void test_break_parent() {
    Ioc ioc = I(J("f2", "parent:'f3'"), J("f3", "parent:'f2'"));
    ioc.get(Animal.class, "f3");
  }
View Full Code Here

Examples of org.nutz.ioc.Ioc

    ioc.get(Animal.class, "f3");
  }

  @Test(expected = IocException.class)
  public void test_break_parent2() {
    Ioc ioc = I(J("fox", "name:'P',age:10"), J("f2", "parent:'x'"), J("f3", "parent:'y'"));
    ioc.get(Animal.class, "f3");
  }
View Full Code Here

Examples of org.nutz.ioc.Ioc

    assertTrue(loader.getName().length > 0);
  }

  @Test
  public void test_get_ioc_self() {
    Ioc ioc = I(J("iocV", "type:'org.nutz.ioc.json.pojo.IocSelf',fields:{ioc:{refer : '$iOc'}}"));
    assertEquals(ioc, ioc.get(IocSelf.class, "iocV").getIoc());
  }
View Full Code Here

Examples of org.nutz.ioc.Ioc

    this.name = p.getName();
    this.type = p.getValue();
  }

  public Object get(IocMaking ing) {
    Ioc ioc = ing.getIoc();
    if (ioc instanceof Ioc2)
      return ((Ioc2)ioc).get(type, name,ing.getContext());
    return ioc.get(type, name);
  }
View Full Code Here

Examples of org.nutz.ioc.Ioc

    }
  }

  @Test
  public void test_simple_case() {
    Ioc ioc = new NutIoc(getNew("org/nutz/ioc/loader/xml/conf/simple.xml"));
    Bee c = ioc.get(Bee.class, "C");
    assertEquals("TheC", c.getName());
    assertEquals(15, c.getAge());
    assertEquals("TheQueen", c.getMother().getName());
    assertEquals(3, c.getFriends().size());
    assertEquals("TheA", c.getFriends().get(0).getName());
View Full Code Here

Examples of org.nutz.ioc.Ioc

    IocBy ib = mainModule.getAnnotation(IocBy.class);
    if (null != ib) {
      if (log.isDebugEnabled())
        log.debugf("@IocBy(%s)", ib.type().getName());

      Ioc ioc = Mirror.me(ib.type()).born().create(config, ib.args());
      // 如果是 Ioc2 的实现,增加新的 ValueMaker
      if (ioc instanceof Ioc2) {
        ((Ioc2) ioc).addValueProxyMaker(new ServletValueProxyMaker(config.getServletContext()));
      }
      // 保存 Ioc 对象
View Full Code Here

Examples of org.nutz.ioc.Ioc

    }
    catch (Exception e) {
      throw new LoadingException(e);
    }
    // If the application has Ioc, depose it
    Ioc ioc = config.getIoc();
    if (null != ioc)
      ioc.depose();

    // Done, print info
    sw.stop();
    if (log.isInfoEnabled())
      log.infof("Nutz.Mvc[%s] is down in %sms", config.getAppName(), sw.getDuration());
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.