[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: ClassLoader injection Scope issue

adrian@jboss.org do-not-reply at jboss.com
Tue Oct 28 12:33:12 EDT 2008


"alesj" wrote : "alesj" wrote : "adrian at jboss.org" wrote : 
  |   |   | The simplest fix would be in the component visitor
  |   |   | 
  |   | But you're right, yours looks easier. :-)
  | But yours doesn't work, where mine does. :-)
  | 
  | Testing on AnnotatedBeansUnitTestCase.
  | Need to check why is that ... since both look legit.

Neither of them work. See my comment about needing the className -> class HACK
If somebody in a deployer does:


  | unit.getMetaData().getAnnotation(Blah.class);
  | 

The AnnotatedElementMetaDataLoader/ClassMetaDataRetrievalFactory
is going to be very confused when it gets a class name instead of a class. :-)


  |    
  |    public MetaDataRetrieval getMetaDataRetrieval(Scope scope)
  |    {
  |       if (scope == null)
  |          throw new IllegalArgumentException("Null scope");
  |       if (CommonLevels.CLASS.equals(scope.getScopeLevel()) == false)
  |          throw new IllegalArgumentException("Not a class scope: " + scope);
  |       
  |       // Not a class
  |       Object qualifier = scope.getQualifier();
  |       if (qualifier instanceof Class == false)
  |          return null; // OOPS!!!!!!!!!!
  |       
  |       Class<?> clazz = Class.class.cast(qualifier);
  |       return new AnnotatedElementMetaDataLoader(clazz);
  |    }
  | 

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

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



More information about the jboss-dev-forums mailing list