3 Replies Latest reply on May 11, 2003 4:42 AM by adrian.brock

    Mbean example/docs available ?

    djharte

      Could someone point me in the direction of any docs/examples of how to register/setup an mbean with JBoss.

      I just want to get a simple example working where it is called during startup.

      Thanks
      David

        • 1. Re: Mbean example/docs available ?

          Look at user-service.xml for example config

          A possible implementation would be

          package my.company;

          public class MyService extends org.jboss.system.ServiceMBeanSupport
          {

          String myAttribute;

          public String getMyAttribute()
          {
          return myAttribute;
          }

          public void setMyAttribute(String myAttribute)
          {
          this.myAttribute = myAttribute;
          }

          protected void startService()
          throws Exception
          {
          log.info("Called at startup");
          log.info("The attribute has already been set " + myAttribute);
          }

          protected void stopService()
          throws Exception
          {
          log.info("Called at shutdown");
          }
          }

          package my.company;

          public interface MyServiceMBean extends org.jboss.system.ServiceMBean
          {

          String getMyAttribute();
          void setMyAttribute(String myAttrbiute);

          }

          NOTE: I haven't tested this code so it probably
          doesn't compile but you get the idea.
          It's fairly trivial.

          For more info just look at the JBoss source
          or buy Juha's book.

          Regards,
          Adrian

          • 2. Re: Mbean example/docs available ?
            djharte

            Thanks a lot Adrian, that did help, I have it working only I haven't got my depends set up correctly. I want to make it start after all my EJBs have been deployed ....

            David

            • 3. Re: Mbean example/docs available ?

              The easiest way to do that is to put
              a dependency on the URLDeployment scanner.

              The hard way is to list every ejb in the depends
              tag.

              You will get a warning saying it is not completly
              deployed (which is true - it hasn't started when
              the scanner finishes starting). But you can
              ignore it.

              Do you really want to depend on every EJB?
              I suspect what you really want to know is
              what ejbs are deployed.

              Regards,
              Adrian