[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
Fri Feb 6 12:10:55 EST 2009


I have had a look at creating my own BeanMetaDataVisitor implementation for use in AspectBeanMetaDataFactory

  |    private boolean hasInjectedBeans(BeanMetaData beanMetaData)
  |    {
  |       DependencyBeanMetaDataVisitor visitor = new DependencyBeanMetaDataVisitor(beanMetaData);
  |       
  |       beanMetaData.describeVisit(visitor);
  |       beanMetaData.initialVisit(visitor);
  |       
  |       return beanMetaData.getHasDependencies();
  |    }
  | 
  | 
  |    private static class DependencyBeanMetaDataVisitor extends AbstractMetaDataVisitor
  |    {
  |       private boolean hasDependencies;
  |       
  |       protected DependencyBeanMetaDataVisitor(BeanMetaData bmd)
  |       {
  |          // FIXME DependencyBeanMetaDataVisitor constructor
  |          super(bmd, new DependencyKernelControllerContext(bmd));
  |       }
  | 
  |       public boolean getHasDependencies()
  |       {
  |          return hasDependencies;
  |       }
  |       
  |       public void addDependency(DependencyItem dependency)
  |       {
  |          hasDependencies = true;
  |       }
  |    }
  | 
But describeVisit() does not work due to the underlying value not being picked up in AbstractInjectionValueMetaData

  |    @SuppressWarnings("deprecation")
  |    public void describeVisit(MetaDataVisitor visitor)
  |    {
  |       // no bean and not by_name
  |       if (getUnderlyingValue() == null)
  |       {
  |           ...
  |       }
  |       super.describeVisit(visitor);
  |    }
  | 
installVisit() gives NPEs since we don't have a KernelControllerContext for the created bean at this stage. I tried mocking one, but so far that does not work since it needs a reference to the kernel etc., but I will try a bit more.

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

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



More information about the jboss-dev-forums mailing list