Package objot.container

Examples of objot.container.Container


          new ModelsCreate(true).create(true, 1);
          return "ok";
        }

      HttpSession hse = context.get(HttpSession.class);
      Container sess = (Container)hse.getAttribute("container");
      if (sess == null)
        synchronized (hse) // double check
        {
          sess = (Container)hse.getAttribute("container");
          if (sess == null)
            hse.setAttribute("container", sess = container.parent().create());
        }
      Container con = container.create(sess);
      Object ser = con.get(inf.cla);
      invoke(inf, ser, req, begin, end1, extraReqs);
      if (sess.get(Session.class).close)
        hse.invalidate();
      if (ser instanceof Do && ((Do)ser).respType != null)
        context.set(String.class, ((Do)ser).respType);
      return con.get(Data.class).result;
    }
    catch (RequestException e)
    {
      if (log.isTraceEnabled())
        log.trace(e);
View Full Code Here


      q = String2.utf(s);
    }
    else if (hq.getQueryString() != null)
      q = URLDecoder.decode(hq.getQueryString(), "UTF-8").toCharArray();

    Container c = con.create();
    c.set(HttpServletRequest.class, hq);
    c.set(HttpServletResponse.class, hp);
    c.set(HttpSession.class, hq.getSession());
    c.set(String.class, "application/octet-stream");
    Object p;
    try
    {
      p = handler.handle(c, inf, q, 0, q.length, extraQs);
    }
    catch (RuntimeException e)
    {
      throw e;
    }
    catch (IOException e)
    {
      throw e;
    }
    catch (Exception e)
    {
      throw new ServletException(e);
    }
    finally
    {
      if ( !String2.empty(up))
        hq.getSession().removeAttribute(up);
    }
    if (p == null)
      throw null;
    if (p instanceof CharSequence)
    {
      if (up != null)
      {
        hp.setContentType("text/html; charset=UTF-8");
        CharSequence r = (CharSequence)p;
        StringBuilder s = new StringBuilder();
        s.append("<pre id=objot>");
        for (int i = 0; i < r.length(); i++)
          if (r.charAt(i) == '&')
            s.append("&amp;");
          else if (r.charAt(i) == '<')
            s.append("&lt;");
          else
            s.append(r.charAt(i));
        p = s.append("</pre>").toString();
      }
      byte[] bs = String2.utf((CharSequence)p);
      hp.setContentLength(bs.length);
      hp.getOutputStream().write(bs);
    }
    else if (p instanceof InputStream)
    {
      hp.setContentType(c.get(String.class));
      Input.readTo((InputStream)p, hp.getOutputStream());
    }
    else
    {
      hp.setContentType(c.get(String.class));
      hp.setContentLength(((byte[])p).length);
      hp.getOutputStream().write((byte[])p);
    }
  }
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
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;
View Full Code Here

TOP

Related Classes of objot.container.Container

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.