Author: pete.muir(a)jboss.org
Date: 2009-04-05 09:14:58 -0400 (Sun, 05 Apr 2009)
New Revision: 2302
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java
Log:
A bit more clean up
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-04-05
13:03:52 UTC (rev 2301)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-04-05
13:14:58 UTC (rev 2302)
@@ -22,6 +22,7 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.annotation.Named;
@@ -42,7 +43,6 @@
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedParameter;
-import org.jboss.webbeans.introspector.AnnotationStore.AnnotationMap;
import org.jboss.webbeans.literal.CurrentLiteral;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -79,7 +79,7 @@
* @param possibleDeploymentTypes The possible deployment types
* @return The deployment type
*/
- public static Class<? extends Annotation> getDeploymentType(List<Class<?
extends Annotation>> enabledDeploymentTypes, AnnotationMap possibleDeploymentTypes)
+ public static Class<? extends Annotation> getDeploymentType(List<Class<?
extends Annotation>> enabledDeploymentTypes, Map<Class<? extends
Annotation>, Annotation> possibleDeploymentTypes)
{
for (int i = (enabledDeploymentTypes.size() - 1); i > 0; i--)
{
@@ -199,7 +199,7 @@
protected void initDeploymentTypeFromStereotype()
{
- AnnotationMap possibleDeploymentTypes =
getMergedStereotypes().getPossibleDeploymentTypes();
+ Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes =
getMergedStereotypes().getPossibleDeploymentTypes();
if (possibleDeploymentTypes.size() > 0)
{
this.deploymentType = getDeploymentType(manager.getEnabledDeploymentTypes(),
possibleDeploymentTypes);
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java 2009-04-05
13:03:52 UTC (rev 2301)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java 2009-04-05
13:14:58 UTC (rev 2302)
@@ -14,8 +14,8 @@
import javax.inject.BindingType;
import org.jboss.webbeans.literal.CurrentLiteral;
-import org.jboss.webbeans.util.Strings;
-import org.jboss.webbeans.util.collections.ForwardingMap;
+import org.jboss.webbeans.util.collections.multi.SetHashMultiMap;
+import org.jboss.webbeans.util.collections.multi.SetMultiMap;
public class AnnotationStore
{
@@ -26,112 +26,16 @@
private static final Set<Annotation> DEFAULT_BINDING = new
HashSet<Annotation>(Arrays.asList(DEFAULT_BINDING_ARRAY));
private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
-
- /**
- * Represents a mapping from a annotation type to an annotation
- * implementation
- */
- public static class AnnotationMap extends ForwardingMap<Class<? extends
Annotation>, Annotation>
- {
- private final 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;
- }
-
- /**
- * Gets a string representation of the map
- *
- * @return A string representation
- */
- @Override
- public String toString()
- {
- return Strings.mapToString("AnnotationMap (annotation type ->
annotation): ", delegate);
- }
-
- }
-
/**
- * Represents a mapping from a annotation (meta-annotation) to a set of
- * annotations
- *
- */
- private static class MetaAnnotationMap extends ForwardingMap<Class<? extends
Annotation>, Set<Annotation>>
- {
- private final 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;
- }
-
- /**
- * Gets the set of annotations matching the given annotation type
- *
- * @param key The meta-annotation to match
- * @returns The set of matching annotations containing this
- * meta-annotation
- */
- @Override
- public Set<Annotation> get(Object key)
- {
- Set<Annotation> annotations = super.get(key);
- return annotations != null ? annotations : new HashSet<Annotation>();
- }
-
- /**
- * Adds an annotation under the meta-annotation type key
- *
- * @param key The meta-annotation type
- * @param value The annotation
- */
- public void put(Class<? extends Annotation> key, Annotation value)
- {
- Set<Annotation> annotations = super.get(key);
- if (annotations == null)
- {
- annotations = new HashSet<Annotation>();
- super.put(key, annotations);
- }
- annotations.add(value);
- }
-
- /**
- * Gets a string representation of the map
- *
- * @return A string representation
- */
- @Override
- public String toString()
- {
- return Strings.mapToString("MetaAnnotationMap (annotation type ->
annotation set: ", delegate);
- }
-
- }
-
- /**
* Builds the annotation map (annotation type -> annotation)
*
* @param annotations The array of annotations to map
* @return The annotation map
*/
- protected static AnnotationMap buildAnnotationMap(Annotation[] annotations)
+ protected static Map<Class<? extends Annotation>, Annotation>
buildAnnotationMap(Annotation[] annotations)
{
- AnnotationMap annotationMap = new AnnotationMap();
+ Map<Class<? extends Annotation>, Annotation> annotationMap = new
HashMap<Class<? extends Annotation>, Annotation>();
for (Annotation annotation : annotations)
{
annotationMap.put(annotation.annotationType(), annotation);
@@ -145,9 +49,9 @@
* @param annotations The array of annotations to map
* @return The annotation map
*/
- protected static AnnotationMap buildAnnotationMap(Iterable<Annotation>
annotations)
+ protected static Map<Class<? extends Annotation>, Annotation>
buildAnnotationMap(Iterable<Annotation> annotations)
{
- AnnotationMap annotationMap = new AnnotationMap();
+ Map<Class<? extends Annotation>, Annotation> annotationMap = new
HashMap<Class<? extends Annotation>, Annotation>();
for (Annotation annotation : annotations)
{
annotationMap.put(annotation.annotationType(), annotation);
@@ -173,11 +77,11 @@
public static AnnotationStore wrap(AnnotationStore annotationStore,
Set<Annotation> annotations, Set<Annotation> declaredAnnotations)
{
- AnnotationMap annotationMap = new AnnotationMap();
+ Map<Class<? extends Annotation>, Annotation> annotationMap = new
HashMap<Class<? extends Annotation>, Annotation>();
annotationMap.putAll(buildAnnotationMap(annotations));
annotationMap.putAll(annotationStore.getAnnotationMap());
- AnnotationMap declaredAnnotationMap = new AnnotationMap();
+ Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap =
new HashMap<Class<? extends Annotation>, Annotation>();
declaredAnnotationMap.putAll(buildAnnotationMap(declaredAnnotations));
declaredAnnotationMap.putAll(annotationStore.getDeclaredAnnotationMap());
@@ -185,18 +89,18 @@
}
// The annotation map (annotation type -> annotation) of the item
- private final AnnotationMap annotationMap;
+ private final Map<Class<? extends Annotation>, Annotation> annotationMap;
// The meta-annotation map (annotation type -> set of annotations containing
// meta-annotation) of the item
- private final MetaAnnotationMap metaAnnotationMap;
+ private final SetMultiMap<Class<? extends Annotation>, Annotation>
metaAnnotationMap;
// The set of all annotations on the item
private final Set<Annotation> annotationSet;
// The annotation map (annotation type -> annotation) of the item
- private final AnnotationMap declaredAnnotationMap;
+ private final Map<Class<? extends Annotation>, Annotation>
declaredAnnotationMap;
// The meta-annotation map (annotation type -> set of annotations containing
// meta-annotation) of the item
- private final MetaAnnotationMap declaredMetaAnnotationMap;
+ private final SetMultiMap<Class<? extends Annotation>, Annotation>
declaredMetaAnnotationMap;
// The set of all annotations on the item
private final Set<Annotation> declaredAnnotationSet;
@@ -209,7 +113,7 @@
* @param annotationMap A map of annotation to register
*
*/
- protected AnnotationStore(AnnotationMap annotationMap, AnnotationMap
declaredAnnotationMap)
+ protected AnnotationStore(Map<Class<? extends Annotation>, Annotation>
annotationMap, Map<Class<? extends Annotation>, Annotation>
declaredAnnotationMap)
{
if (annotationMap == null)
{
@@ -217,7 +121,7 @@
}
this.annotationMap = annotationMap;
this.annotationSet = new HashSet<Annotation>();
- this.metaAnnotationMap = new MetaAnnotationMap();
+ this.metaAnnotationMap = new SetHashMultiMap<Class<? extends Annotation>,
Annotation>();
for (Annotation annotation : annotationMap.values())
{
for (Annotation metaAnnotation : annotation.annotationType().getAnnotations())
@@ -237,7 +141,7 @@
}
this.declaredAnnotationMap = declaredAnnotationMap;
this.declaredAnnotationSet = new HashSet<Annotation>();
- this.declaredMetaAnnotationMap = new MetaAnnotationMap();
+ this.declaredMetaAnnotationMap = new SetHashMultiMap<Class<? extends
Annotation>, Annotation>();
for (Annotation annotation : declaredAnnotationMap.values())
{
for (Annotation metaAnnotation : annotation.annotationType().getAnnotations())
@@ -306,12 +210,12 @@
return declaredAnnotationMap.containsKey(annotationType);
}
- AnnotationMap getAnnotationMap()
+ Map<Class<? extends Annotation>, Annotation> getAnnotationMap()
{
return annotationMap;
}
- AnnotationMap getDeclaredAnnotationMap()
+ Map<Class<? extends Annotation>, Annotation> getDeclaredAnnotationMap()
{
return declaredAnnotationMap;
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java 2009-04-05
13:03:52 UTC (rev 2301)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java 2009-04-05
13:14:58 UTC (rev 2302)
@@ -18,11 +18,12 @@
package org.jboss.webbeans.metadata;
import java.lang.annotation.Annotation;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.introspector.AnnotationStore.AnnotationMap;
/**
* Meta model for the merged stereotype for a bean
@@ -32,7 +33,7 @@
public class MergedStereotypes<T, E>
{
// The possible deployment types
- private final AnnotationMap possibleDeploymentTypes;
+ private final Map<Class<? extends Annotation>, Annotation>
possibleDeploymentTypes;
// The possible scope types
private final Set<Annotation> possibleScopeTypes;
// Is the bean name defaulted?
@@ -51,7 +52,7 @@
*/
public MergedStereotypes(Set<Annotation> stereotypeAnnotations, ManagerImpl
manager)
{
- this.possibleDeploymentTypes = new AnnotationMap();
+ this.possibleDeploymentTypes = new HashMap<Class<? extends Annotation>,
Annotation>();
this.possibleScopeTypes = new HashSet<Annotation>();
this.requiredTypes = new HashSet<Class<?>>();
this.supportedScopes = new HashSet<Class<? extends Annotation>>();
@@ -96,7 +97,7 @@
*
* @return The deployment types
*/
- public AnnotationMap getPossibleDeploymentTypes()
+ public Map<Class<? extends Annotation>, Annotation>
getPossibleDeploymentTypes()
{
return possibleDeploymentTypes;
}