Package org.nutz.ioc.impl

Examples of org.nutz.ioc.impl.NutIoc


import org.nutz.mvc.NutConfig;

public class XmlIocProvider implements IocProvider {

  public Ioc create(NutConfig config, String[] args) {
    return new NutIoc(new XmlIocLoader(args), new ScopeContext("app"), "app");
  }
View Full Code Here


import org.nutz.mvc.NutConfig;

public class AnnotationIocProvider implements IocProvider {

  public Ioc create(NutConfig config, String[] args) {
    return new NutIoc(new AnnotationIocLoader(args), new ScopeContext("app"), "app");
  }
View Full Code Here

import org.nutz.mvc.NutConfig;

public class JsonIocProvider implements IocProvider {

  public Ioc create(NutConfig config, String[] args) {
    return new NutIoc(new JsonLoader(args), new ScopeContext("app"), "app");
  }
View Full Code Here

public class JsonAopConfigrationTest {

  @Test
  public void test_jsonAop(){
    Ioc ioc = new NutIoc(new JsonLoader("org/nutz/ioc/aop/config/impl/jsonfile-aop.js"));
    Assert.assertTrue(ioc.getNames().length > 0);
    for (String name : ioc.getNames()) {
      ioc.get(null, name);
    }
    MyMI mi = ioc.get(MyMI.class, "myMI");
    assertTrue(mi.getTime() == 0);
    Pet2 pet2 = ioc.get(Pet2.class,"pet2");
    pet2.sing();
    assertTrue(mi.getTime() == 1);
    pet2.sing();
    assertTrue(mi.getTime() == 2);
  }
View Full Code Here

public class AopJsonIocTest {

    @Test
    public void test_simple() {
        IocLoader il = new JsonLoader("org/nutz/ioc/json/aop.js");
        Ioc ioc = new NutIoc(il);
        StringBuilder sb = ioc.get(StringBuilder.class, "sb");
        Mammal fox = ioc.get(Mammal.class, "fox");

        assertEquals("Fox", fox.getName());
        assertEquals("B:getName0;A:getName0;", sb.toString());
        sb.delete(0, sb.length());
        fox.getName();
View Full Code Here

public class PojoTest {

  public static void main(String[] args) {
    IocLoader loader = new JsonLoader("ioc.js");
    Ioc ioc = new NutIoc(loader);
    Pet pet = ioc.get(Pet.class, "pet");
    System.out.println(pet.getName());
  }
View Full Code Here

import org.nutz.mvc.NutConfig;

public class AnnotationIocProvider implements IocProvider {

    public Ioc create(NutConfig config, String[] args) {
        return new NutIoc(new AnnotationIocLoader(args), new ScopeContext("app"), "app");
    }
View Full Code Here

public class SimpleIocTest {

    @Test(expected=IocException.class)
    public void test_error_bean() {
        Ioc ioc = new NutIoc(new AnnotationIocLoader(DogMaster.class.getPackage().getName()));
        try {
            ioc.get(DogMaster.class);
            fail("Never Success");
        }
        catch (IocException e) {}
        ioc.get(DogMaster.class);
    }
View Full Code Here

    static Ioc2 I(String... ss) {
        String json = "{";
        json += Lang.concat(',', ss);
        json += "}";
        return new NutIoc(new MapLoader(json));
    }
View Full Code Here

   
    @Test
    public void test_no_singleton_depose() {
      Issue399Service.CreateCount = 0;
      Issue399Service.DeposeCount = 0;
      Ioc ioc = new NutIoc(new AnnotationIocLoader(Issue399Service.class.getPackage().getName()));
      for (int i = 0; i < 100; i++) {
      ioc.get(Issue399Service.class);
    }
      ioc.depose();
      System.gc();
      assertEquals(100, Issue399Service.CreateCount);
      assertEquals(0, Issue399Service.DeposeCount);
     
    }
View Full Code Here

TOP

Related Classes of org.nutz.ioc.impl.NutIoc

Copyright © 2018 www.massapicom. 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.