Package org.nutz.ioc.loader.map

Examples of org.nutz.ioc.loader.map.MapLoader


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


    s += "b:{type:'org.nutz.ioc.json.RecurReferJsonIocTest$RB',";
    s += "fields:{nm:'B', ra:{refer:'a'}}";
    s += "}";
    s += "}";

    Ioc ioc = new NutIoc(new MapLoader(s));
    RA a = ioc.get(RA.class, "a");
    assertEquals("A", a.nm);
    assertEquals("B", a.rb.nm);

    RB b = ioc.get(RB.class, "b");
View Full Code Here

public class IocCustomizedValueTypeTest {

  @Test
  public void test_simple_customized() {
    String json = "{xb:{name:{cc:'XiaoBai'}}}";
    Ioc2 ioc = new NutIoc(new MapLoader(json));
    ioc.addValueProxyMaker(new ValueProxyMaker() {
      public ValueProxy make(IocMaking ing, IocValue iv) {
        if ("cc".equalsIgnoreCase(iv.getType())) {
          return new StaticValue("CC:" + iv.getValue());
        }
View Full Code Here

  @Test
  public void test_refer_context() {
    IocContext context = new ScopeContext("abc");
    String json = "{obj:{singleton:false,fields:{ic:{refer:'$conText'}}}}";
    Ioc2 ioc = new NutIoc(new MapLoader(json), context, "abc");
    TestReferContext trc = ioc.get(TestReferContext.class);
    assertTrue(context == trc.ic);

    IocContext context2 = new ScopeContext("rrr");
    trc = ioc.get(TestReferContext.class, "obj", context2);
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

        s += "b:{type:'org.nutz.ioc.json.RecurReferJsonIocTest$RB',";
        s += "fields:{nm:'B', ra:{refer:'a'}}";
        s += "}";
        s += "}";

        Ioc ioc = new NutIoc(new MapLoader(s));
        RA a = ioc.get(RA.class, "a");
        assertEquals("A", a.nm);
        assertEquals("B", a.rb.nm);

        RB b = ioc.get(RB.class, "b");
View Full Code Here

        strss[1][0] = "c";
        strss[1][1] = "d";
        objMap.put("args", new Object[]{strss});

        map.put("obj", objMap);
        Ioc ioc = new NutIoc(new MapLoader(map));

        IocTO00 obj = ioc.get(IocTO00.class, "obj");
        assertEquals(2, obj.getStrss().length);
        assertEquals(2, obj.getStrss()[0].length);
        assertEquals("a", obj.getStrss()[0][0]);
View Full Code Here

public class IocCustomizedValueTypeTest {

    @Test
    public void test_simple_customized() {
        String json = "{xb:{name:{cc:'XiaoBai'}}}";
        Ioc2 ioc = new NutIoc(new MapLoader(json));
        ioc.addValueProxyMaker(new ValueProxyMaker() {
            public ValueProxy make(IocMaking ing, IocValue iv) {
                if ("cc".equalsIgnoreCase(iv.getType())) {
                    return new StaticValue("CC:" + iv.getValue());
                }
View Full Code Here

    @Test
    public void test_refer_context() {
        IocContext context = new ScopeContext("abc");
        String json = "{obj:{singleton:false,fields:{ic:{refer:'$conText'}}}}";
        Ioc2 ioc = new NutIoc(new MapLoader(json), context, "abc");
        TestReferContext trc = ioc.get(TestReferContext.class);
        assertTrue(context == trc.ic);

        IocContext context2 = new ScopeContext("rrr");
        trc = ioc.get(TestReferContext.class, "obj", context2);
View Full Code Here

TOP

Related Classes of org.nutz.ioc.loader.map.MapLoader

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.