3 Replies Latest reply on Nov 8, 2008 9:25 AM by Scott Stark

    KernelDeploymentManagedObjectCreator doesn't include all BMD

    Ales Justin Master

      Looking at KernelDeploymentManagedObjectCreator impl

       for(BeanMetaDataFactory bmdf : beanFactories)
       {
       if((bmdf instanceof BeanMetaData) == false)
       continue;
      
       BeanMetaData bmd = (BeanMetaData) bmdf;
      


      This defeats the purpose of wildcard matching in KernelDeployment.
      e.g. DML's Thread beans won't be picked up as MOs

      But I guess if I do this
       for(BeanMetaDataFactory bmdf : beanFactories)
       {
       List<BeanMetaData> bmds = bmdf.getBeans();
       if (bmds != null && bmds.isEmpty() == false)
       {
       for (BeanMetaData bmd : bmds)
       {
      

      then I break the MO code:
       CollectionMetaType moType = new CollectionMetaType(BeanMetaDataFactory.class.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
      
       ...
      
       GenericValue[] mos = new GenericValue[tmp.size()];
       tmp.toArray(mos);
       CollectionValueSupport values = new CollectionValueSupport(moType, mos);
       // This bypasses the write through back to the metadata
       beanFactoriesMP.getFields().setField(Fields.VALUE, values);
      

      as this probably expect that all mos are also BMDF instances.

        • 1. Re: KernelDeploymentManagedObjectCreator doesn't include all
          Scott Stark Master

          The beanFactories is the only manged property in the KernelDeployment currently, so that is what I used. If its really the BeanMetaData from their getBeans(), then effectively the managed property is the beans.

          So if its changed to a collection of beans (BeanMetaData) this is equivalent to call the deprecated setBeans() method on the KernelDeployment. Why is it deprecated?

          • 2. Re: KernelDeploymentManagedObjectCreator doesn't include all
            Ales Justin Master

             

            "scott.stark@jboss.org" wrote:

            So if its changed to a collection of beans (BeanMetaData) this is equivalent to call the deprecated setBeans() method on the KernelDeployment. Why is it deprecated?

            I think this is an old leftover.
            It should probably be removed before we did CR. :-(

            But as you can see, both setBeans and setBeanFactories, set the same variable: List beanFactories
             @SuppressWarnings("unchecked")
             public void setBeans(List beans)
             {
             this.beanFactories = beans;
             flushJBossObjectCache();
             }
            
             /**
             * Set the bean factories.
             *
             * @param beanFactories a List<BeanMetaDataFactory>.
             */
             @ManagementProperty(managed=true)
             @XmlElements
             ({
             @XmlElement(name="bean", type=AbstractBeanMetaData.class),
             @XmlElement(name="beanfactory", type=GenericBeanFactoryMetaData.class),
             @XmlElement(name="lazy", type=AbstractLazyMetaData.class)
             })
             @XmlAnyElement
             public void setBeanFactories(List<BeanMetaDataFactory> beanFactories)
             {
             this.beanFactories = beanFactories;
            


            So, setBeans != getBeans, in terms of what they handle.

            Dunno how you can really solve this at the MO level then. :-)
            Probably each BeanMetaDataFactory impl will have to declare its getBeans as MO property?
            Or can this be done on the interface?

            • 3. Re: KernelDeploymentManagedObjectCreator doesn't include all
              Scott Stark Master

              It does not sound like the default behavior of java annotations, even when the annotation is annotated with Inherited.

              Each BeanMetaDataFactory impl will have to declare its properties and have its BeanMetaData impls declared properly as well. We'll have to get some tests in place for this.