2 Replies Latest reply on Sep 20, 2002 11:27 AM by Juha Lindfors

    can MBean invoke EJB method ?

    yancheng Newbie


      Can I invoke a EJB's method from MBean ?

      I want received some Tibco RV's message, so I don't use the JMS. If I can invoke EJB, then I may use MBean instead of MDB? Is it idea right?

      thank you.

        • 1. Re: can MBean invoke EJB method ?
          Derek Hulley Newbie

          Yes. I was checking it out as well, and the following worked, effectively passing a value from the MBean to the EJB, i.e. as a means of manually calling an EJB method. I have ordered the JMX book, so I might find out that there are more efficient ways of doing this.
          ===========================
          public void setFileName(String fileName) throws Exception {
          try {
          Context ctx = new InitialContext();
          Object obj = ctx
          .lookup("ejb/com.activiti.jmx.ejb.TestReader");
          TestReaderHome testReaderHome = (TestReaderHome) PortableRemoteObject
          .narrow(obj, TestReaderHome.class);
          TestReader testReader = testReaderHome.create();
          testReader.setFileName(fileName);
          } catch (Exception e) {
          cat.error(e);
          throw e;
          }
          }
          ===============================

          Derek

          • 2. Re: can MBean invoke EJB method ?
            Juha Lindfors Master

            i don't think there are more efficient ways to go about this (at the moment anyway) but hope you enjoy the book nevertheless