3 Replies Latest reply on Nov 10, 2003 6:46 PM by Elias Ross

    Object instance in a MBean

    Surga Moin Newbie

      Can i declare an Vector in an MBean and make that Vector accessible to all the calls which invoke that MBean and allow then to update the vector, I am looking for a singleton vector which i can use as an immemory store of certain values which all the session beans can access.

      How to achieve this.

      TIA,
      MOIN.

        • 1. Re: Object instance in a MBean
          Elias Ross Master


          You can do that. When you return an object from an MBean method, the same object instance is passed to the caller. It isn't serialized.

          Aside from concurrency issues, it's legitimate practice.

          It is sometimes better to pass read-only structures or (shallow/deep) copies, so "clients" who use the structure aren't astonished by ConcurrentModifcationException-s.

          • 2. Re: Object instance in a MBean
            Surga Moin Newbie

            Is there any pattern for using singelton in MBeans,
            or some advices which are provided by any jini.
            i would love to go through some of those.
            TIA
            Moin

            • 3. Re: Object instance in a MBean
              Elias Ross Master


              The free documentation shows you how to bind a JMX service to a JNDI name. There's typically no reason to do that because you can easily return objects via the MBeanServer.

              Download and take a look at the JBoss source and take a look at a few MBeans that are provided. Or, buy the documentation and write a few MBeans yourself.