[jboss-user] [JBoss Microcontainer Development] New message: "Re: AnnotatedElementMetaDataLoader component metadata optimization"

Kabir Khan do-not-reply at jboss.com
Thu Feb 18 11:00:15 EST 2010


User development,

A new message was posted in the thread "AnnotatedElementMetaDataLoader component metadata optimization":

http://community.jboss.org/message/527038#527038

Author  : Kabir Khan
Profile : http://community.jboss.org/people/kabir.khan@jboss.com

Message:
--------------------------------------------------------------
I have gone back to making AEMDL.getCMDR() return null if there are no annotations. It is the fastest way, and is the least affected by caching. To preserve backwards compatibility and to not have to change any tests, I have added this fix to make MetaDataRetrievalToMetaDataBridge always return something even if there is no component metadata:
 
   public MetaData getComponentMetaData(Signature signature)
   {
      MetaDataRetrieval component = retrieval.getComponentMetaDataRetrieval(signature);
      if (component == null)
         //return null;
         return NullComponentMetaData.INSTANCE;
      return new MetaDataRetrievalToMetaDataBridge(component);
   }
...
   private static class NullComponentMetaData implements MetaData
   {
      final static NullComponentMetaData INSTANCE = new NullComponentMetaData();
 
      public <T extends Annotation> T getAnnotation(Class<T> annotationType)
      {
         return null;
      }
 
      public Annotation[] getAnnotations()
      {
         return MetaData.NO_ANNOTATIONS;
      }
 
      public Annotation[] getAnnotationsAnnotatedWith(Class<? extends Annotation> meta)
      {
         return MetaData.NO_ANNOTATIONS;
      }
 
      public MetaData getComponentMetaData(Signature signature)
      {
         return null;
      }
 
      public Annotation[] getLocalAnnotations()
      {
         return MetaData.NO_ANNOTATIONS;
      }
 
      public Object[] getLocalMetaData()
      {
         return MetaData.NO_METADATA;
      }
 
      public <T> T getMetaData(Class<T> type)
      {
         return null;
      }
 
      public Object[] getMetaData()
      {
         return MetaData.NO_METADATA;
      }
 
      public Object getMetaData(String name)
      {
         return null;
      }
 
      public <T> T getMetaData(String name, Class<T> type)
      {
         return null;
      }
 
      public MetaData getScopeMetaData(ScopeLevel level)
      {
         return null;
      }
 
      public long getValidTime()
      {
         return 0;
      }
 
      public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
      {
         return false;
      }
 
      public boolean isEmpty()
      {
         return true;
      }
 
      public boolean isMetaDataPresent(Class<?> type)
      {
         return false;
      }
 
      public boolean isMetaDataPresent(String name)
      {
         return false;
      }
 
      public boolean isMetaDataPresent(String name, Class<?> type)
      {
         return false;
      }  
   }

 
 

--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/527038#527038




More information about the jboss-user mailing list