4 Replies Latest reply on Apr 18, 2005 10:41 PM by Bill Burke

    initializing a GenericBeanFactory

    Bill Burke Master

      Not sure how to do it. Tried this:

       AbstractBeanMetaData metaData1 = new AbstractBeanMetaData("aspect", GenericBeanFactory.class.getName());
       ArrayList constructor1 = new ArrayList();
       constructor1.add(new AbstractParameterMetaData(KernelConfigurator.class.getName(), new AbstractValueMetaData(kernel.getConfigurator())));
       AbstractConstructorMetaData cmd = new AbstractConstructorMetaData();
       metaData1.setConstructor(cmd);
       cmd.setParameters(constructor1);
      
       HashSet attributes1 = new HashSet();
       attributes1.add(new AbstractPropertyMetaData("bean", "org.jboss.test.kernel.SimpleAspect"));
       attributes1.add(new AbstractPropertyMetaData("constructor", new AbstractValueMetaData(new AbstractConstructorMetaData())));
      
      
       AbstractMapMetaData properties = new AbstractMapMetaData();
       properties.put(new AbstractValueMetaData("bean1"), new AbstractValueMetaData(new AbstractDependencyValueMetaData("simple")));
      
       attributes1.add(new AbstractPropertyMetaData("properties", properties));
       metaData1.setProperties(attributes1);
      
      
      


      got this:

      java.lang.ClassCastException: java.util.HashMap$Values
       at org.jboss.kernel.plugins.dependency.basic.BasicKernelController$DependencyMetaDataVisitor.visit(BasicKernelController.java:274)
       at org.jboss.beans.metadata.plugins.AbstractValueMetaData.visit(AbstractValueMetaData.java:81)
       at org.jboss.kernel.plugins.dependency.basic.BasicKernelController$DependencyMetaDataVisitor.visit(BasicKernelController.java:275)
       at org.jboss.beans.metadata.plugins.AbstractFeatureMetaData.visit(AbstractFeatureMetaData.java:85)
       at org.jboss.kernel.plugins.dependency.basic.BasicKernelController$DependencyMetaDataVisitor.visit(BasicKernelController.java:275)
       at org.jboss.beans.metadata.plugins.AbstractFeatureMetaData.visit(AbstractFeatureMetaData.java:85)
       at org.jboss.kernel.plugins.dependency.basic.BasicKernelController$DependencyMetaDataVisitor.visit(BasicKernelController.java:222)
       at org.jboss.kernel.plugins.dependency.basic.BasicKernelController.preprocessMetaData(BasicKernelController.java:85)
       at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.java:210)
       at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.java:102)
       at org.jboss.test.kernel.AspectTestCase.testDependencyCorrectOrder(AspectTestCase.java:61)
      
      


        • 1. Re: initializing a GenericBeanFactory
          Adrian Brock Master

          It is a bug/typo: AbstractMapMetaData:

          I just committed the fix...

          
           public Iterator getChildren()
           {
           ArrayList children = new ArrayList(map.keySet());
          - children.add(map.values());
          + children.addAll(map.values());
           return children.iterator();
           }
          


          I should warn you that I haven't done anything except basic config tests (no injection/dependency tests) on the collections because I was waiting to see
          what Alex could handle in the XML mapping. :-(

          • 2. Re: initializing a GenericBeanFactory
            Adrian Brock Master

             

            "adrian@jboss.org" wrote:

            I should warn you that I haven't done anything except basic config tests (no injection/dependency tests) on the collections because I was waiting to see
            what Alex could handle in the XML mapping. :-(


            The same is true for the GenericBeanFactory, except there I haven't even
            done basic config tests.

            • 3. Re: initializing a GenericBeanFactory
              Bill Burke Master

              I'll dig further, but another problem Seems that controller and such doesn't get set on the AbstractDependency in the Map sent into th

              java.lang.NullPointerException
               at org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData.getValue(AbstractDependencyValueMetaData.java:112)
               at org.jboss.kernel.plugins.config.Configurator.getPropertySetterJoinPoint(Configurator.java:428)
               at org.jboss.kernel.plugins.config.Configurator.getPropertySetterJoinPoint(Configurator.java:405)
               at org.jboss.kernel.plugins.config.AbstractKernelConfigurator.getPropertySetterJoinPoint(AbstractKernelConfigurator.java:106)
               at org.jboss.beans.metadata.plugins.factory.GenericBeanFactory.create(GenericBeanFactory.java:77)
               at org.jboss.test.kernel.AspectTestCase.testDependencyCorrectOrder(AspectTestCase.java:67)
              


              • 4. Re: initializing a GenericBeanFactory
                Bill Burke Master

                Ok, everything is working now. Fixed one thing in AbstractValueMEtaData... in getChildren, actually look to see if value is a valueMetaData, then pass it back.

                Added test to PlainDependencyTestCase