0 Replies Latest reply on May 31, 2006 3:45 AM by dreu zel

    Servlet  EJB   sharing  memory

    dreu zel Novice

      EJB server bean behaves as shared memory

      I'm using Dom to communicate between servlet and my Bean
      i've added som dom structures in my servlet session environment
      An I'm passing that structure between servlet and Bean
      virtualy as shared memory


      Servlet code extract
      --------------------
      Session ses=(Session) session.getAttribute("REQinfSession") ;
      Where ses is a class containing a dom4j structure
      Document ses.dom ;//session Dom Document
      ...

      Ejb request
      -----------
      requests are passed to the service bean with the calls like
      Node nod=ses.dom.selectSingleNode("/root/loadtestmap/@id");
      nod.setText("userInfo");


      DomBean_INTF dombean = (DomBean_INTF) JNDI.Bean("ejb/dommer/local");//connecting to the bean
      if (dombean != null)
      { String status=dommbean.Load(ses,Request);//the dombean gets the session as transport buffer and gets what to do from
      ;// from the Request



      only the pointer to the session class ses is passed to the bean

      Bean code extract
      -----------------
      public String dom(Session ses,String Request)

      ses.dom is manipulated using standard Dom request
      Node nod=ses.dom.selectSingleNode("/root/loadtestmap/@id");//get information from the servlet
      String inf =nod.getText();
      ....
      Node nods=ses.dom.selectSingleNode("/root/dbInfo");//get info from the database ...
      nods.setText("returned info and structures"));//place it in the dom structure

      return status;



      Of coarse there are structures to ensure session and transactional consistency is maintained in the
      in the bean


      actualy the ses session structure is shared memory between Servlet and bean.
      I hope it is not copied arround every time ( interconsistency would be attacked)




      Any suggestions , critics ....