Package objot.container

Examples of objot.container.Factory


      handler = (ServiceHandler)Class.forName(config.getInitParameter("handler")).newInstance();
      config.getServletContext().log(
        "\n\n================################ " + getClass().getName() + " : "
          + handler.getClass().getName() + " %%%%%%%%%%%%%%%%$$$$$$$$$$$$$$$$\n\n");

      con = new Factory(Inject.Set.class).bind(ServletConfig.class,
        ServletContext.class).create(null);
      con = new Factory(Inject.Set.class).bind(HttpServletRequest.class,
        HttpServletResponse.class, HttpSession.class, String.class).create(con);
      con.set(ServletConfig.class, c);
      con.set(ServletContext.class, c.getServletContext());

      handler = handler.init(con.parent());
View Full Code Here


  static Container con0lazy;

  @BeforeClass
  public static void init() throws Exception
  {
    final Container parent = new Factory()
    {
      {
        bind(ParentNew.class);
        bind(ParentSingle.class);
        bind(ParentSet.class);
      }

      @Override
      protected Object forBind(Class<?> c, Bind b) throws Exception
      {
        return c == X.class ? b.cla(ParentSingle.class) : null;
      }
    }.create(null);
    Factory f = new Factory()
    {
      {
        bind(Object.class);
        bind(New2.class);
        bind(Single2.class);
        bind(Set.class);
        bind(ChildSingle.class);
        bind(ParentSingle.class);
      }

      @Override
      protected Object forBind(Class<?> c, Bind b) throws Exception
      {
        return c == Object.class ? b.obj(parent) : b.box == Long.class ? b.obj(9L)
          : b.mode(parent.bound(c) ? Inject.Parent.class : b.mode);
      }

      @Override
      protected Object forBind(Class<?> cc, AccessibleObject fp, Class<?> c,
        Type generic, Bind b) throws Exception
      {
        if (c == int.class)
          return b.obj( -1);
        if (b.box == Long.class)
          return null;
        if (c == String.class && fp.isAnnotationPresent(Deprecated.class))
          return b.obj(Deprecated.class.getName());
        if (c == int[].class)
          return b.obj(null);

        if (cc == Single2.class)
          if (c == Single.class)
            return b.cla(Single2.class);
          else if (((Member)fp).getName().equals("n"))
            return b.cla(New2.class);
        return null;
      }
    };
    con0 = f.create(parent);
    con0lazy = f.create(parent, true);
  }
View Full Code Here

  }

  @Test
  public void singleCircular() throws Exception
  {
    new Factory().bind(SingleCircular.class).create(null, true) //
    .get(SingleCircular.class);
  }
View Full Code Here

  }

  @Test(expected = ClassCircularityError.class)
  public void singleCircularCtor() throws Exception
  {
    new Factory().bind(SingleCircular.class).create(null, true) //
    .get(SingleCircular.Ctor.class);
  }
View Full Code Here

          && Mod2.match(m, Mod2.P.OBJECT, Mod2.PUBLIC_PROTECT, Mod2.FINAL))
          return null;
        return this;
      }
    };
    final Container sess = new Factory()
    {
      {
        for (Class<?> c: Class2.packageClasses(Do.class))
          if (Session.class.isAssignableFrom(c))
            bind(c);
        bind(SessionFactory.class);
      }

      @Override
      protected Object forBind(Class<?> c, Bind b) throws Exception
      {
        return c == SessionFactory.class ? b.obj(hib) : b;
      }
    }.create(null);
    Factory req = new Factory()
    {
      @Override
      protected Object forBind(Class<?> c, Bind b) throws Exception
      {
        if (sess.bound(c))
          return b.mode(Inject.Parent.class);
        if (c == Codec.class)
          return b.obj(codec);
        if (c.isSynthetic())
          return b;
        return b.cla(test ? testW.weave(w.weave(c)) : w.weave(c));
      }
    }.bind(Codec.class);
    for (Class<?> c: Class2.packageClasses(Do.class))
      if (Mod2.match(c, Mod2.PUBLIC, Mod2.ABSTRACT))
        req.bind(c);
    return req.create(sess, true);
  }
View Full Code Here

TOP

Related Classes of objot.container.Factory

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.