4 Replies Latest reply: Mar 19, 2011 10:08 AM by Ales Justin RSS

    How to access MC pojo beans from a RAP app

    Csaba Szucs Newbie

      Hello Guys,

       

      We have a J2EE web app with a JSP/Servlet based UI.

      We would like to reimplement the UI-layer in Eclipse/RAP technology.

       

      So from now on the RAP UI layeer will invoke BU classes such as:

      o EJB classes (session beans, entity beans, message driven beans)

      o JBoss MicroController POJO beans

       

       

      Unfortunately I have trouble to access an MC bean from RAP.

       

       

      To call an MC bean operation from a servlet init() method was easy like:

       

      public void init(ServletConfig config) throws ServletException {

        super.init(config);

        try {

          KernelControllerVDFConnector connector = new KernelControllerVDFConnector(config.getServletContext());

          if (connector.isValid() == false) throw new ServletException("Illegal VDF component, no MC Kernel present.");

          KernelController controller = connector.getUtility();

          ControllerContext ctx = controller.getInstalledContext("AJBossMCBean");

          AJBossMCBeanInterface dummy = (AJBossMCBeanInterface) ctx.getTarget();           

          dummy.someOperation();

          // ...

        } catch(Exception e ) {

          // ...

        }

      }        

       

      Within RAP, I can also provide a ServletContext object, but the KernelControllerCDFConnector.valid() always return a false value.

       

      How can I solve this issue?

       

      Many thanks in advance!

      Csaba

        • 1. How to access MC pojo beans from a RAP app
          Ales Justin Master
          Within RAP, I can also provide a ServletContext object, but the KernelControllerCDFConnector.valid() always return a false value.

           

          How can I solve this issue?

          Hmmm, I'm not familiar with RAP.

          Which ServletContext instance does this provide?

           

          What we're doing in JBossAS is when creating ServletContext inside JBossWeb/AS code,

          we still have access to MC' Kernel and underlying DeploymentUnit,

          hence we simply stick it in as an attribute.

          * see org.jboss.web.tomcat.service.deployers.JBossContextConfig

           

          Or why using ServletContext?

          Can't you push MC layer (aka some MC bean) all the way to RAP layer?

          (guessing as I don't know how RAP works ...)

          • 2. How to access MC pojo beans from a RAP app
            Csaba Szucs Newbie

            Hello Ales,

             

            The runtime type of the ServletContext instance is org.eclipse.equinox.http.servlet.internal.ServletContextAdaptor.

            So that must be the cause the valid() method gives false.

             

            Unfortuntely I don't know how I could put MC beans into RAP, actually that's what I just tried to ask. I also put this message up to RAP user forum, in case they might help me on this.

             

            What I do know is how to access EJBs from RAP.

            So maybe a workaround solution could be to delegate MC bean's logics on to an EJB class, and using that EJB class from RAP.

            The draw-back here is the need to refactor/change existing classes in BU layer just because of RAP UI layer...

             

             

            Thanks, anyway.

            Csaba

            • 3. How to access MC pojo beans from a RAP app
              Ales Justin Master
              The runtime type of the ServletContext instance is org.eclipse.equinox.http.servlet.internal.ServletContextAdaptor.

              So that must be the cause the valid() method gives false.

              Perhaps see if you can then tie this ServletContextAdaptor with MC.

              e.g. putting the same Kernel and DeploymentUnit attributes in

              (or at least Kernel, as that's what you need)

               

              Then your code wouldn't need any change. :-)

              • 4. How to access MC pojo beans from a RAP app
                Ales Justin Master
                What I do know is how to access EJBs from RAP.

                So maybe a workaround solution could be to delegate MC bean's logics on to an EJB class, and using that EJB class from RAP.

                The draw-back here is the need to refactor/change existing classes in BU layer just because of RAP UI layer...

                Afaik, you can inject MC stuff into EJBs.

                So you could simply inject MC's Kernel or Controller into EJB and go from there.

                 

                If you would to abstract the MC lookup logic, behind some interface:

                * from ServletContext

                * from EJB

                then you probably wouldn't have a hard time changing this.