[jboss-user] [JBoss Microcontainer Development] New message: "Re: AnnotatedElementMetaDataLoader component metadata optimization"
Kabir Khan
do-not-reply at jboss.com
Tue Feb 16 15:21:09 EST 2010
User development,
A new message was posted in the thread "AnnotatedElementMetaDataLoader component metadata optimization":
http://community.jboss.org/message/526634#526634
Author : Kabir Khan
Profile : http://community.jboss.org/people/kabir.khan@jboss.com
Message:
--------------------------------------------------------------
An alternative to changing the tests (although I think we should agree once and for all what the getComponentMetadataRetrieval() should return) is to return a singleton:
public MetaDataRetrieval getComponentMetaDataRetrieval(Signature signature)
{
if (signature == null)
return null;
if (annotated instanceof Class)
{
Class<?> clazz = Class.class.cast(annotated);
if (signature instanceof ConstructorSignature)
{
ConstructorSignature constructorSignature = (ConstructorSignature) signature;
Constructor<?> constructor = constructorSignature.getConstructor();
if (constructor == null)
constructor = SecurityActions.findConstructor(clazz, signature.getParametersTypes(clazz));
if (constructor == null)
{
if (log.isTraceEnabled())
log.trace("Constructor with signature " + signature + " does not exist on class " + clazz.getName());
return null;
}
if (constructor.getAnnotations().length == 0)
return NullAnnotatedElementMetaDataLoader.INSTANCE;
return new AnnotatedElementMetaDataLoader(constructor);
}
//Same for fields, methods, parameters
}
private static class NullAnnotatedElementMetaDataLoader implements MetaDataRetrieval
{
final static NullAnnotatedElementMetaDataLoader INSTANCE = new NullAnnotatedElementMetaDataLoader();
final static ScopeKey NULL_SCOPE_KEY = new ScopeKey(new Scope(CommonLevels.JOINPOINT, INSTANCE));
final static BasicAnnotationsItem NO_ANNOTATIONS_ITEM = new BasicAnnotationsItem(null, new AnnotationItem[0]);
final static BasicMetaDatasItem NO_METADATAS_ITEM = new BasicMetaDatasItem(null, new MetaDataItem[0]);
public MetaDataRetrieval getComponentMetaDataRetrieval(Signature signature)
{
return INSTANCE;
}
public ScopeKey getScope()
{
return NULL_SCOPE_KEY;
}
public MetaDataRetrieval getScopedRetrieval(ScopeLevel level)
{
return INSTANCE;
}
public ValidTime getValidTime()
{
return null;
}
public boolean isEmpty()
{
return true;
}
public <T extends Annotation> AnnotationItem<T> retrieveAnnotation(Class<T> annotationType)
{
return null;
}
public AnnotationsItem retrieveAnnotations()
{
return NO_ANNOTATIONS_ITEM;
}
public AnnotationsItem retrieveAnnotationsAnnotatedWith(Class<? extends Annotation> meta)
{
return NO_ANNOTATIONS_ITEM;
}
public AnnotationsItem retrieveLocalAnnotations()
{
return NO_ANNOTATIONS_ITEM;
}
public MetaDatasItem retrieveLocalMetaData()
{
return NO_METADATAS_ITEM;
}
public MetaDatasItem retrieveMetaData()
{
return NO_METADATAS_ITEM;
}
public <T> MetaDataItem<T> retrieveMetaData(Class<T> type)
{
return null;
}
public MetaDataItem<?> retrieveMetaData(String name)
{
return null;
}
}
I am not sure about the ValidTime, and the ScopeKey seems to not be used, but all tests in mdr pass.
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/526634#526634
More information about the jboss-user
mailing list