[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: How to reliably determine if BeanMetaData contains depen

kabir.khan@jboss.com do-not-reply at jboss.com
Wed Feb 11 09:57:53 EST 2009


That is exactly what I had and which does not work, see my first post...
 
Reorganising the code a bit

  |    private void getDependencies(ArrayList<ValueMetaData> dependencies, MetaDataVisitorNode node)
  |    {
  |       if (node instanceof AbstractDependencyValueMetaData)
  |       {
  |          dependencies.add((AbstractDependencyValueMetaData)node);
  |       }
  | 
  |       Iterator<? extends MetaDataVisitorNode> children = node.getChildren();
  |       
  |       if (children != null)
  |       {
  |          while (children.hasNext())
  |          {
  |             MetaDataVisitorNode child = children.next();
  |             getDependencies(dependencies, child);
  |          }
  |       }
  |    }
  | 

1) getDependencies() gets called with an AbstractBeanMetaData, this finds a child and calls getDependencies()
2) getDependencies() gets called with an AbstractPropertyMetaData (child of 1), this finds a child and calls getDependencies()
3) getDependencies() gets called with an AbstractValueMetaData (child of 2), this finds a child and calls getDepedencies()
4) getDependencies() gets called with a PropertyMap (child of 3), this finds a child and calls getDepedencies()
5) getDependencies() gets called with a PropertyMap$ValueInfo (child of 4), this has no children and the loop returns

Looking at the PropertyMap$ValueInfo, it contains the AbstractInjectionValueMetaData I want, but no way to get hold of it. From my debugger:

  | node	PropertyMap$ValueInfo  (id=113)	
  | 	hashCode	-2147483648	
  | 	log	Logger  (id=118)	
  | 	name	"dependency" (id=120)	
  | 	toString	SoftReference<T>  (id=124)	
  | 	value	AbstractInjectionValueMetaData  (id=126)	
  | 

PropertyMap$ValueInfo seems wrong, replacing

  |       public Iterator<? extends MetaDataVisitorNode> getChildren()
  |       {
  |          return value.getChildren();
  |       }
  | 
with

  |       public Iterator<? extends MetaDataVisitorNode> getChildren()
  |       {
  |          return Collections.singletonList(value).iterator();
  |       }
  | 
I get this for 5) onwards:
5) getDependencies() gets called with a PropertyMap$ValueInfo (child of 4), this finds a child and calls getDepedencies()
6) getDependencies() is called with an AbstractInjectionValueMetaData and the dependency is picked out as expected.

So either PropertyMap$ValueInfo.getChildren() needs to be fixed, or you need to come up with something else if that fix is not valid.







View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4209080#4209080

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4209080



More information about the jboss-dev-forums mailing list