"alesj" wrote : Why would you need this?
| I don't see anything similar in CachingMDC for other retrieveX methods.
|
The problem is that I want to only iterate over everything once, which means I have to
create the annotations item myself, e.g.:
| @SuppressWarnings("unchecked")
| Cache<Class, AnnotationsItem> cached = cachedMetaAnnotations;
| if (cached == null)
| {
| AnnotationsItem item = retrieveAnnotations();
| if (item.getAnnotations().length > 0)
| {
| Map<Class<? extends Annotation>,
List<AnnotationItem<?>>> annotations = new HashMap<Class<? extends
Annotation>, List<AnnotationItem<?>>>();
| for (AnnotationItem<?> annotation : item.getAnnotations())
| {
| for (Annotation current :
annotation.getAnnotation().annotationType().getAnnotations())
| {
| List<AnnotationItem<?>> annotationsForMeta =
annotations.get(current.annotationType());
| if (annotationsForMeta == null)
| {
| annotationsForMeta = new
ArrayList<AnnotationItem<?>>();
| annotations.put(current.annotationType(), annotationsForMeta);
| }
| annotationsForMeta.add(annotation);
| }
| }
|
| cached = factory.createCache(Class.class, AnnotationsItem.class,
getFqn());
| for (Map.Entry<Class<? extends Annotation>,
List<AnnotationItem<?>>> entry : annotations.entrySet())
| {
|
| AnnotationsItem basic = new BasicAnnotationsItem(null,
entry.getValue().toArray(new AnnotationItem<?>[entry.getValue().size()] ));
| cached.put(entry.getKey(), basic);
| }
| }
| cachedMetaAnnotations = cached;
| }
| return cached.get(meta);
|
So, I need to create the annotations item myself. If I don't pass in a loader, the
BasicAnnotationsItem will fail on isCachable() since that calls the loader. This problem
will also occur if when I move the pre-indexing logic into AbstractMetaDataContext.
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4269371#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...