[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: AOPConstructorJoinpoint::methodHasAnnotations is wrong
alesj
do-not-reply at jboss.com
Tue Apr 1 09:11:49 EDT 2008
"alesj" wrote :
| Looking at Kabir's comment on recent change:
| anonymous wrote :
| | [JBMICROCONT-250] When checking component metadata for a method, only return that we have joinpoint annotations if they exist at instance level or below.
| |
| Looks like a case of wrong impl or wrong conclusion on how MetaData.getScopeMetaData(ScopeLevel) works.
|
| Should we really always check for all levels below and including INSTANCE?
|
I've added this hierarchy check:
| private boolean checkForMetaDataAtSubInstanceLevel(MetaData metaData)
| {
| if (metaData != null)
| {
| List<ScopeLevel> levels = CommonLevelsUtil.getSubLevels(CommonLevels.INSTANCE);
| for (ScopeLevel level : levels)
| {
| boolean hasMetaData = hasMetaDataAtLevel(metaData, level);
| if (hasMetaData)
| return true;
| }
| }
| return false;
| }
|
And I'm ignoring any annotations that are marked with InstanceAnnotation(false):
| protected boolean hasMetaDataAtLevel(MetaData metaData, ScopeLevel level)
| {
| MetaData levelMetaData = metaData.getScopeMetaData(level);
| if (levelMetaData != null && levelMetaData.isEmpty() == false)
| {
| Set<Object> checkSet = new HashSet<Object>();
| Object[] allMetaData = levelMetaData.getMetaData();
| Annotation[] annotations = levelMetaData.getAnnotations();
| // all meta data is not null, since instance metadata is not empty
| checkSet.addAll(Arrays.asList(allMetaData));
| checkSet.removeAll(Arrays.asList(annotations));
|
| // do we have something else than annotations
| if (checkSet.isEmpty() == false)
| return true;
| else
| {
| // do we have an annotation that's not marked with IA
| for (Annotation annotation : annotations)
| {
| InstanceAnnotation ia = annotation.annotationType().getAnnotation(InstanceAnnotation.class);
| if (ia == null || ia.value())
| return true;
| }
| }
| }
| return false;
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4140480#4140480
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4140480
More information about the jboss-dev-forums
mailing list