3 Replies Latest reply on Apr 12, 2010 10:26 AM by Ales Justin

    How can I disable bean lifecycles per entire descriptor?

    Zemian Deng Apprentice

      Hi,

       

      I have many pojos that contain a create method and I don't want MC  to call it during deployment. I understand we can use ignore attribute per bean to disable this lifecycle call like

       

      <create method="create" ignored="true"/>

       

      but would it possible to ignored all beans under an entire descriptor deployment instead of individual bean?

       

      Thanks,

      /Z

        • 1. Re: How can I disable bean lifecycles per entire descriptor?
          Ales Justin Master
          but would it possible to ignored all beans under an entire descriptor deployment instead of individual bean?

          Unfortunately no.

           

          But you can easily write your own xml element for either bean or group of beans,

          which would then take existing BeanMetaData instance(s) and add this ignore rule.

           

          e.g.

           

          <deployment xmlns="urn:jboss:bean-deployer:2.0">

           

             <my-group xmlns="urn:foo:bar:1.0">

           

                 ... plain MC beans

           

             </my-group>

           

             <!-- OR custom bean -->

           

             <my-bean xmlns="urn:foo:bar:1.0" name="tralala" class="..." />

           

          </deployment>

           

          where then metadata class mapping to those new elements must implement BeanMetaDataFactory.

           

          Perhaps check DML's ThreadMetaData project on how this is done:

          * http://anonsvn.jboss.org/repos/jbossas/projects/jboss-threads/trunk/jboss-threads-metadata/

          • 2. Re: How can I disable bean lifecycles per entire descriptor?
            Zemian Deng Apprentice

            Ales,

             

            Thanks for the providing the project link as ref. I think I understand what you're saying about using the BeanMetaDataFactory for grouping of beans method. I tried look into the jboss-threads-metadata, but I didn't see a sample  of descriptor using the ThreadsMetaData yet.

             

            So I am still not clear as how would you apply the ignore rule to the entire group of beans. Would I need to programmatically disable this inside the BeanMetaDataFactory instance's implementation (like in ThreadsMetatData.java), or simply adding the <create method="create" ignore="true"> under the <my-group xmlns="urn:foo:bar:1.0"> in descriptor XML file would work?

             

            Thanks,

            /Z

            • 3. Re: How can I disable bean lifecycles per entire descriptor?
              Ales Justin Master
              Would I need to programmatically disable this inside the BeanMetaDataFactory instance's implementation (like in ThreadsMetatData.java),

              Yes, programmatically. But this would/should be trivial.

               

              e.g. if you take the grouping approach, your impl would already be provided with BeanMetaData instances.

              All you would need to do is wrap it with such code:

               

              BeanMetaData bmd = ...;
              BeanMetaDataBuilder builder = BeanMetaDataBuilder.create(bmd);
              builder.ignoreCreate(); // or which ever lifecycle state you wann ignore