3 Replies Latest reply on Feb 23, 2009 5:32 AM by alesj

    start() and stop() methods in a MC bean

    jaikiran

      I have a simple MC bean with a method named start and annotated with @InstallMethod:

      public class MyBean
      {
      
       @InstallMethod
       public void start() throws Exception
       {
       // do something
       }
      
       @UnInstallMethod
       public void stop() throws Exception
       {
       // do something
       }
      }
      
      
      


      When this MC bean is deployed, the start() method gets called twice. From what i can see in the logs, its being called when the bean enters the START stage and the INSTALL stage. The note in this document http://www.jboss.org/file-access/default/members/jbossmc/freezone/docs/2.0.x/userGuide/ch05s04.html states that any method named start() (and stop) are considered as MBean start/stop methods and are called during the START/STOP stage.

      But shouldn't those methods be skipped during start/stop, if they are annotated for something else - as in this example @InstallMethod.

        • 1. Re: start() and stop() methods in a MC bean
          alesj

           

          "jaikiran" wrote:

          But shouldn't those methods be skipped during start/stop, if they are annotated for something else - as in this example @InstallMethod.

          Could be done, but it's just too custom for my taste. :-)
          Since in this case you can simply do @Start(ignored=true).

          • 2. Re: start() and stop() methods in a MC bean
            jaikiran

             

            "alesj" wrote:


            Since in this case you can simply do @Start(ignored=true).


            Yep, i could do that :) Infact i just renamed the methods:

            @InstallMethod
             public void onInstall() throws Exception
             {
             // do something
             }
            
            
            


            The reason why i would except the MC to skip this start is because if someone is annotating it to be an @InstallMethod, then he is treating that as a MC bean and hence no longer a legacy MBean :) Nothing major though, since we know the workarounds.

            • 3. Re: start() and stop() methods in a MC bean
              alesj

               

              "jaikiran" wrote:

              The reason why i would except the MC to skip this start is because if someone is annotating it to be an @InstallMethod, then he is treating that as a MC bean and hence no longer a legacy MBean :)

              Just more (useless) custom details.
              What about if someone actually really wanted to have start called twice, at start and install? ;-)
              @SkipThinkingThisIsPlainPOJOAndDoOldMBeanNotion :-)