Author: nickarls
Date: 2008-11-26 02:10:49 -0500 (Wed, 26 Nov 2008)
New Revision: 363
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java
Log:
Forwarding maps AnnotationMap and MetaAnnotationMap
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2008-11-25
19:47:31 UTC (rev 362)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2008-11-26
07:10:49 UTC (rev 363)
@@ -23,7 +23,6 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import javax.webbeans.BindingType;
@@ -44,6 +43,7 @@
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
+import org.jboss.webbeans.introspector.jlr.AbstractAnnotatedItem.AnnotationMap;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.util.Reflections;
@@ -73,7 +73,7 @@
* @param possibleDeploymentTypes The possible deployment types
* @return The deployment type
*/
- public static Class<? extends Annotation> getDeploymentType(List<Class<?
extends Annotation>> enabledDeploymentTypes, Map<Class<? extends
Annotation>, Annotation> possibleDeploymentTypes)
+ public static Class<? extends Annotation> getDeploymentType(List<Class<?
extends Annotation>> enabledDeploymentTypes, AnnotationMap possibleDeploymentTypes)
{
for (int i = (enabledDeploymentTypes.size() - 1); i > 0; i--)
{
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java 2008-11-25
19:47:31 UTC (rev 362)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java 2008-11-26
07:10:49 UTC (rev 363)
@@ -18,13 +18,12 @@
package org.jboss.webbeans.bean;
import java.lang.annotation.Annotation;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.introspector.jlr.AbstractAnnotatedItem.AnnotationMap;
import org.jboss.webbeans.model.StereotypeModel;
/**
@@ -35,7 +34,7 @@
*/
public class MergedStereotypes<T, E>
{
- private Map<Class<? extends Annotation>, Annotation>
possibleDeploymentTypes;
+ private AnnotationMap possibleDeploymentTypes;
private Set<Annotation> possibleScopeTypes;
private boolean beanNameDefaulted;
private Set<Class<?>> requiredTypes;
@@ -49,7 +48,7 @@
*/
public MergedStereotypes(Set<Annotation> stereotypeAnnotations, ManagerImpl
manager)
{
- possibleDeploymentTypes = new HashMap<Class<? extends Annotation>,
Annotation>();
+ possibleDeploymentTypes = new AnnotationMap();
possibleScopeTypes = new HashSet<Annotation>();
requiredTypes = new HashSet<Class<?>>();
supportedScopes = new HashSet<Class<? extends Annotation>>();
@@ -94,7 +93,7 @@
*
* @return The deployment types
*/
- public Map<Class<? extends Annotation>, Annotation>
getPossibleDeploymentTypes()
+ public AnnotationMap getPossibleDeploymentTypes()
{
return possibleDeploymentTypes;
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java 2008-11-25
19:47:31 UTC (rev 362)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedItem.java 2008-11-26
07:10:49 UTC (rev 363)
@@ -30,7 +30,6 @@
*/
public interface AnnotatedItem<T, S>
{
-
/**
* Gets all annotations on the item
*
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-11-25
19:47:31 UTC (rev 362)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2008-11-26
07:10:49 UTC (rev 363)
@@ -21,18 +21,54 @@
import org.jboss.webbeans.util.Reflections;
import org.jboss.webbeans.util.Types;
+import com.google.common.collect.ForwardingMap;
+
public abstract class AbstractAnnotatedItem<T, S> implements AnnotatedItem<T,
S>
{
- private static final Annotation[] DEFAULT_BINDING_ARRAY = {new
CurrentAnnotationLiteral()};
+ public static class AnnotationMap extends ForwardingMap<Class<? extends
Annotation>, Annotation>
+ {
+ private Map<Class<? extends Annotation>, Annotation> delegate;
+
+ public AnnotationMap()
+ {
+ delegate = new HashMap<Class<? extends Annotation>, Annotation>();
+ }
+
+ @Override
+ protected Map<Class<? extends Annotation>, Annotation> delegate()
+ {
+ return delegate;
+ }
+
+ }
+
+ public static class MetaAnnotationMap extends ForwardingMap<Class<? extends
Annotation>, Set<Annotation>>
+ {
+ private Map<Class<? extends Annotation>, Set<Annotation>>
delegate;
+
+ public MetaAnnotationMap()
+ {
+ delegate = new HashMap<Class<? extends Annotation>,
Set<Annotation>>();
+ }
+
+ @Override
+ protected Map<Class<? extends Annotation>, Set<Annotation>>
delegate()
+ {
+ return delegate;
+ }
+
+ }
+
+ private static final Annotation[] DEFAULT_BINDING_ARRAY = { new
CurrentAnnotationLiteral() };
private static final Set<Annotation> DEFAULT_BINDING = new
HashSet<Annotation>(Arrays.asList(DEFAULT_BINDING_ARRAY));
-
- private Map<Class<? extends Annotation>, Annotation> annotationMap;
- private Map<Class<? extends Annotation>, Set<Annotation>>
metaAnnotationMap;
+
+ private AnnotationMap annotationMap;
+ private MetaAnnotationMap metaAnnotationMap;
private Set<Annotation> annotationSet;
private Annotation[] annotationArray;
-
- public AbstractAnnotatedItem(Map<Class<? extends Annotation>, Annotation>
annotationMap)
+
+ public AbstractAnnotatedItem(AnnotationMap annotationMap)
{
if (annotationMap == null)
{
@@ -40,15 +76,15 @@
}
this.annotationMap = annotationMap;
}
-
- protected static Map<Class<? extends Annotation>, Annotation>
buildAnnotationMap(AnnotatedElement element)
+
+ protected static AnnotationMap buildAnnotationMap(AnnotatedElement element)
{
return buildAnnotationMap(element.getAnnotations());
}
-
- protected static Map<Class<? extends Annotation>, Annotation>
buildAnnotationMap(Annotation[] annotations)
+
+ protected static AnnotationMap buildAnnotationMap(Annotation[] annotations)
{
- Map<Class<? extends Annotation>, Annotation> annotationMap = new
HashMap<Class<? extends Annotation>, Annotation>();
+ AnnotationMap annotationMap = new AnnotationMap();
for (Annotation annotation : annotations)
{
annotationMap.put(annotation.annotationType(), annotation);
@@ -56,7 +92,7 @@
return annotationMap;
}
- protected static Set<Annotation> populateAnnotationSet(Set<Annotation>
annotationSet, Map<Class<? extends Annotation>, Annotation> annotationMap)
+ protected static Set<Annotation> populateAnnotationSet(Set<Annotation>
annotationSet, AnnotationMap annotationMap)
{
for (Entry<Class<? extends Annotation>, Annotation> entry :
annotationMap.entrySet())
{
@@ -64,11 +100,11 @@
}
return annotationSet;
}
-
+
protected static Object[]
getParameterValues(List<AnnotatedParameter<Object>> parameters, ManagerImpl
manager)
{
Object[] parameterValues = new Object[parameters.size()];
- Iterator<AnnotatedParameter<Object>> iterator = parameters.iterator();
+ Iterator<AnnotatedParameter<Object>> iterator = parameters.iterator();
for (int i = 0; i < parameterValues.length; i++)
{
parameterValues[i] = iterator.next().getValue(manager);
@@ -76,6 +112,7 @@
return parameterValues;
}
+ @SuppressWarnings("unchecked")
public <A extends Annotation> A getAnnotation(Class<? extends A>
annotationType)
{
return (A) annotationMap.get(annotationType);
@@ -85,12 +122,12 @@
{
if (metaAnnotationMap == null)
{
- metaAnnotationMap = new HashMap<Class<? extends Annotation>,
Set<Annotation>>();
+ metaAnnotationMap = new MetaAnnotationMap();
}
metaAnnotationMap = populateMetaAnnotationMap(metaAnnotationType,
metaAnnotationMap, annotationMap);
return metaAnnotationMap.get(metaAnnotationType);
}
-
+
public Annotation[] getMetaAnnotationsAsArray(Class<? extends Annotation>
metaAnnotationType)
{
if (annotationArray == null)
@@ -115,10 +152,7 @@
return annotationMap.containsKey(annotatedType);
}
- protected static <A extends Annotation> Map<Class<? extends
Annotation>, Set<Annotation>> populateMetaAnnotationMap(
- Class<A> metaAnnotationType, Map<Class<? extends Annotation>,
- Set<Annotation>> metaAnnotationMap,
- Map<Class<? extends Annotation>, Annotation> annotationMap)
+ protected static <A extends Annotation> MetaAnnotationMap
populateMetaAnnotationMap(Class<A> metaAnnotationType, MetaAnnotationMap
metaAnnotationMap, AnnotationMap annotationMap)
{
if (!metaAnnotationMap.containsKey(metaAnnotationType))
{
@@ -135,11 +169,11 @@
return metaAnnotationMap;
}
- protected Map<Class<? extends Annotation>, Annotation> getAnnotationMap()
+ protected AnnotationMap getAnnotationMap()
{
return annotationMap;
}
-
+
@Override
public boolean equals(Object other)
{
@@ -150,12 +184,12 @@
}
return false;
}
-
+
public boolean isAssignableFrom(AnnotatedItem<?, ?> that)
{
return isAssignableFrom(that.getType(), that.getActualTypeArguments());
}
-
+
public boolean isAssignableFrom(Set<Class<?>> types)
{
for (Class<?> type : types)
@@ -167,18 +201,18 @@
}
return false;
}
-
+
private boolean isAssignableFrom(Class<?> type, Type[] actualTypeArguments)
{
return Types.boxedType(getType()).isAssignableFrom(Types.boxedType(type))
&& Arrays.equals(getActualTypeArguments(), actualTypeArguments);
}
-
+
@Override
public int hashCode()
{
return getType().hashCode();
}
-
+
@Override
public String toString()
{
@@ -199,7 +233,7 @@
string += getAnnotations();
return string;
}
-
+
public Set<Annotation> getBindingTypes()
{
if (getMetaAnnotations(BindingType.class).size() > 0)
@@ -211,7 +245,7 @@
return DEFAULT_BINDING;
}
}
-
+
public Annotation[] getBindingTypesAsArray()
{
if (getMetaAnnotationsAsArray(BindingType.class).length > 0)
@@ -223,7 +257,7 @@
return DEFAULT_BINDING_ARRAY;
}
}
-
+
public boolean isProxyable()
{
if (Reflections.getConstructor(getType()) == null)
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2008-11-25
19:47:31 UTC (rev 362)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2008-11-26
07:10:49 UTC (rev 363)
@@ -1,8 +1,6 @@
package org.jboss.webbeans.introspector.jlr;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
-import java.util.Map;
import javax.webbeans.BindingType;
@@ -14,7 +12,7 @@
private String name;
- public AbstractAnnotatedMember(Map<Class<? extends Annotation>,
Annotation> annotationMap)
+ public AbstractAnnotatedMember(AnnotationMap annotationMap)
{
super(annotationMap);
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2008-11-25
19:47:31 UTC (rev 362)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2008-11-26
07:10:49 UTC (rev 363)
@@ -1,8 +1,5 @@
package org.jboss.webbeans.introspector.jlr;
-import java.lang.annotation.Annotation;
-import java.util.Map;
-
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.util.Reflections;
@@ -11,7 +8,7 @@
private AnnotatedClass<Object> superclass;
- public AbstractAnnotatedType(Map<Class<? extends Annotation>, Annotation>
annotationMap)
+ public AbstractAnnotatedType(AnnotationMap annotationMap)
{
super(annotationMap);
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java 2008-11-25
19:47:31 UTC (rev 362)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedItemImpl.java 2008-11-26
07:10:49 UTC (rev 363)
@@ -3,7 +3,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
-import java.util.Map;
import javax.webbeans.TypeLiteral;
@@ -14,18 +13,18 @@
private Class<T> type;
private Annotation[] actualAnnotations;
- private AnnotatedItemImpl(Map<Class<? extends Annotation>, Annotation>
annotationMap)
+ private AnnotatedItemImpl(AnnotationMap annotationMap)
{
super(annotationMap);
}
- private AnnotatedItemImpl(Map<Class<? extends Annotation>, Annotation>
annotationMap, Class<T> type)
+ private AnnotatedItemImpl(AnnotationMap annotationMap, Class<T> type)
{
super(annotationMap);
this.type = type;
}
- private AnnotatedItemImpl(Map<Class<? extends Annotation>, Annotation>
annotationMap, TypeLiteral<T> apiType)
+ private AnnotatedItemImpl(AnnotationMap annotationMap, TypeLiteral<T> apiType)
{
super(annotationMap);
this.type = apiType.getRawType();
@@ -35,7 +34,7 @@
}
}
- private AnnotatedItemImpl(Map<Class<? extends Annotation>, Annotation>
annotationMap, Class<T> type, Type[] actualTypeArguments)
+ private AnnotatedItemImpl(AnnotationMap annotationMap, Class<T> type, Type[]
actualTypeArguments)
{
this(annotationMap, type);
this.actualTypeArguments = actualTypeArguments;