4 Replies Latest reply on Nov 29, 2004 7:13 AM by Dimitris Andreadis

    Need for SeviceMbean

    Rachna Aggarwal Newbie


      I am using MBeans in our project and I wanted to know the significance of using ServiceMBean provided by JBoss?If anyone can help me out in this as not much documentation on this is provided on net.


        • 1. Re: Need for SeviceMbean
          Dimitris Andreadis Master

          This is a problem with the jboss service mbeans, people use them for all shorts of things and there is a not a single place where this information exists. The jboss documentation describes the basic mbeans, although, there are certainly many others usages not documented.

          Maybe you can do it the other way: describe what you want to do and people may post ideas of what can be re-used.

          • 2. Re: Need for SeviceMbean

            As I have recently learned...

            ServiceMbean and ServiceMBean support are good if you want your "Services" to be notified of JBoss events when starting and restarting services etc...

            • 3. Re: Need for SeviceMbean
              Deepak Nohwal Newbie

              I don't think we need to implement ServiceMBean for receiving notifications....you can make your MBean to implement ListenerServiceMBean interface straight away and it can start receiving the notifications...

              this brings me back to the original question posted by Rachna in this thread....WHAT advantage do we get by implementing the ServiceMBean interface, if any?

              • 4. Re: Need for SeviceMbean
                Dimitris Andreadis Master

                By implementing ServiceMBean (which extends Service) you just get 3 extra attributes Name, State and StateString. The last is useful to have a visual view of the state of the service in the jmx-console.

                Finally there is the method jbossInternalLifecycle() which is used to coordinate your service with the service controller, and start/stop dependent services whenever you start/stop your service.

                ServiceMBean really goes hand-in-hand with ServiceMBeanSupport/ListenerServiceMBeanSupport which implement this interface for you. It handles correctly jbossInternalLifecycle() and also emits AttributeChange events when the State of the service changes, from starting->started->stopping->stopped, or failed.

                So the questions really is whether you extend or not one of the support classes (then you get the MBeanService implementation for free).

                Otherwise you are probably better-off not implementing ServiceMBean, or even Service, and just write a simple POJO class with optional service lifecyle methods (create/start/stop/destroy) and wrap this with an XMBean descriptor.