9 Replies Latest reply on Feb 14, 2012 10:18 PM by jaikiran

    <mbean> optionally <depends> on another <mbean>

    jaabax

      hi

      I have an mbean declared as the following in my jboss-service.xml:

       

      {code:xml}

      <mbean code="com.mbean.MyBootstrap" name="service.server.monitor:service=MyBootstrap">

                <depends>service.server.monitor:service=OPTIONALMBean</depends>

      </mbean>

      {code}

       

      but I want that OPTIONALMBean be optional

      this means that: if OPTIONALMBean is not on the another SAR that I've placed it in, I want that MyBootstrap works normally

      how can I achieve this?

       

      thanks in advance

        • 1. Re: <mbean> optionally <depends> on another <mbean>
          alesj

          This looks like you don't need that depends at all then. :-)

          You just need to make sure MyBootstrap has proper logic.

           

          As this one is hard to impl; e.g. what if OPTBean is actually present, but just happens to be deployed after MyB.

          Is this still OK? Or how can I tell OPTBean is actually gonna be deployed? etc ...

          • 2. Re: <mbean> optionally <depends> on another <mbean>
            jaabax

            you're right ales

            actually, I need that if MyBootstrap is present, it runs first than OPTIONALMBean

             

            I have the following scenarios:

             

            MyBootstrap can be present WITHOUT OPTIONALMBean

            OPTIONALMBean can be present WITHOUT MyBootstrap

            OPTIONALMBean can be present WITH MyBootstrap, BUT, in this case, OPTIONALMBean NEEDs to run first

             

            thanks

            • 3. Re: <mbean> optionally <depends> on another <mbean>
              alesj

              I can only see a solution with diff descriptors for diff configs.

              e.g. the last one having proper <depends>, where other have none

              • 4. Re: <mbean> optionally <depends> on another <mbean>
                jaabax

                I thinks this should be optional

                I can implement this and try a commit, what do you think?.. something like

                 

                <depends optional="true">service.server.monitor:service=OPTIONALMBean</depends>

                • 5. Re: <mbean> optionally <depends> on another <mbean>
                  alesj

                  You could probably add custom Deployers / DUPs,

                  which would register all beans in 1st phase -- collect the names,

                  where it would then add proper deps in 2nd phase, only if the deployment fits your scenario.

                   

                  If the mbeans come from 2 diff deployments (sars), then this gets even harder, if not impossible.

                  • 6. Re: <mbean> optionally <depends> on another <mbean>
                    alesj

                    <depends optional="true">service.server.monitor:service=OPTIONALMBean</depends>

                    This depends on the (random) order of your dep check == making it useless.

                    • 7. Re: <mbean> optionally <depends> on another <mbean>
                      jaabax

                      I didn't got it 100% but i understand a little

                      i'm using the <depends> just to be sure that OPTIONALMBean runs first when it is on the class path

                      i dont know implementation details of how jboss do this mbean dependency management.. but, looking to the big picture, it looks possible

                       

                      changing the question so

                       

                      how can I set the order of the mbeans? just the order : OPTIONALMBean and MyBootstrap afterwards?

                      • 8. Re: <mbean> optionally <depends> on another <mbean>
                        jaabax

                        according to jboss-app_5_0.dtd on https://community.jboss.org/wiki/JBossDTDs

                         

                        "The value of the module-order could be implicit or strict

                        <module-order>strict</module-order>

                                   or

                        <module-order>implicit</module-order>

                        The strict value indicates that the deployments of the modules will

                        be done in the order that would be specified in the application.xml

                        and jboss-app.xml file .

                        The implicit value indicates the deployment would follow the order

                        which would be specified in the DeploymentSorter.

                        The default order will be implicit to support backward compatibility"

                         

                        so, a jboss-app with:

                         

                        <jboss-app>

                          <module-order>strict</module-order>

                          <module>

                            <service>OPTIONALMBean.sar</service>

                          </module>

                          <module>

                            <service>MyBootstrap.sar</service>

                          </module>

                        </jboss-app>

                         

                        guarantees the deploy order of my sars

                         

                         

                        but this is not happening.. sometimes MyBootstrap is still deployed first than OPTIONALMBean

                        • 9. Re: <mbean> optionally <depends> on another <mbean>
                          jaikiran

                          That jboss-app DTD does not apply to AS7. The module ordering elements are ignored in AS7. The jboss-app_7_0.xsd for AS7 will soon be available in JBOSS_HOME/docs/schema folder (it's already in the nightly builds if you are using it).