[webbeans-commits] Webbeans SVN: r383 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: contexts and 2 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Mon Dec 1 02:21:12 EST 2008


Author: nickarls
Date: 2008-12-01 02:21:12 -0500 (Mon, 01 Dec 2008)
New Revision: 383

Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.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/AnnotatedAnnotationImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ListComparator.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/LoggerUtil.java
Log:
Move handling of get/put of elements into (forwarding)maps of type <?, Collection<?>> so that they return empty collections if key is not found and implicitly creates the collection if there is none when putting

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java	2008-11-29 22:34:31 UTC (rev 382)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java	2008-12-01 07:21:12 UTC (rev 383)
@@ -315,13 +315,7 @@
     */
    public Manager addContext(Context context)
    {
-      List<Context> contexts = contextMap.get(context.getScopeType());
-      if (contexts == null)
-      {
-         contexts = new ArrayList<Context>();
-         contextMap.put(context.getScopeType(), contexts);
-      }
-      contexts.add(context);
+      contextMap.add(context);
       return this;
    }
 
@@ -426,7 +420,7 @@
    public Context getContext(Class<? extends Annotation> scopeType)
    {
       List<Context> contexts = contextMap.get(scopeType);
-      if (contexts == null)
+      if (contexts.isEmpty())
       {
          throw new ContextNotActiveException("No active contexts for " + scopeType.getName());
       }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java	2008-11-29 22:34:31 UTC (rev 382)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/ContextMap.java	2008-12-01 07:21:12 UTC (rev 383)
@@ -18,9 +18,11 @@
 package org.jboss.webbeans.contexts;
 
 import java.lang.annotation.Annotation;
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.webbeans.manager.Context;
 
@@ -41,21 +43,10 @@
 
    public ContextMap()
    {
-      delegate = new HashMap<Class<? extends Annotation>, List<Context>>();
+      delegate = new ConcurrentHashMap<Class<? extends Annotation>, List<Context>>();
    }
 
    /**
-    * Gets a list of contexts for a give scope type
-    * 
-    * @param key The scope type class
-    * @return The list of contexts (null if none found)
-    */
-   public List<Context> get(Class<? extends Annotation> key)
-   {
-      return (List<Context>) super.get(key);
-   }
-
-   /**
     * Gets the dependent context
     * 
     * @param scopeType The scope type to get
@@ -81,6 +72,39 @@
    @Override
    public String toString()
    {
-      return Strings.mapToString("ContextMAp (scope type -> context list): ", delegate);
+      return Strings.mapToString("ContextMap (scope type -> context list): ", delegate);
    }
+
+   /**
+    * Adds a context under a scope type
+    * 
+    * Creates the list of contexts if it doesn't exist
+    * 
+    * @param context The new context
+    */
+   public void add(Context context)
+   {
+      List<Context> contexts = super.get(context.getScopeType());
+      if (contexts == null)
+      {
+         contexts = new CopyOnWriteArrayList<Context>();
+         put(context.getScopeType(), contexts);
+      }
+      contexts.add(context);
+   }
+
+   /**
+    * Gets a context list for a scope type
+    * 
+    * @param scopeType The scope type
+    * @return A list of contexts. An empty list is returned if there are no registered scopes of this type
+    */
+   public List<Context> get(Class<? extends Annotation> scopeType)
+   {
+      List<Context> contexts = super.get(scopeType);
+      return contexts != null ? contexts : new ArrayList<Context>();
+   }
+   
+   
+
 }
\ No newline at end of file

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-29 22:34:31 UTC (rev 382)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java	2008-12-01 07:21:12 UTC (rev 383)
@@ -110,24 +110,32 @@
       /**
        * Gets the set of annotations matching the given annotation type
        * 
-       * If the key is not found, an empty set is created and placed in the map
-       * before returned
-       * 
        * @param key The meta-annotation to match
        * @returns The set of matching annotations containing this
        *          meta-annotation
        */
-      @SuppressWarnings("unchecked")
       @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((Class<? extends Annotation>) key, annotations);
+            super.put(key, annotations);
          }
-         return annotations;
+         annotations.add(value);
       }
 
       /**
@@ -201,7 +209,7 @@
             // literals for all?
             // if (MAPPED_METAANNOTATIONS.contains(metaAnnotation))
             // {
-            metaAnnotationMap.get(metaAnnotation.annotationType()).add(annotation);
+            metaAnnotationMap.put(metaAnnotation.annotationType(), annotation);
             // }
          }
       }
@@ -429,15 +437,17 @@
    public String toString()
    {
       StringBuffer buffer = new StringBuffer();
-//      buffer.append("AbstractAnnotatedItem:\n");
-//      buffer.append("Annotations: " + getAnnotations().size() + "\n");
-//      int i = 0;
-//      for (Annotation annotation : getAnnotations())
-//      {
-//         buffer.append(++i + " - " + annotation.toString() + "\n");
-//      }
-//      buffer.append(annotationMap == null ? "" : (annotationMap.toString() + "\n"));
-//      buffer.append(metaAnnotationMap == null ? "" : (metaAnnotationMap.toString()) + "\n");
+      // buffer.append("AbstractAnnotatedItem:\n");
+      // buffer.append("Annotations: " + getAnnotations().size() + "\n");
+      // int i = 0;
+      // for (Annotation annotation : getAnnotations())
+      // {
+      // buffer.append(++i + " - " + annotation.toString() + "\n");
+      // }
+      // buffer.append(annotationMap == null ? "" : (annotationMap.toString() +
+      // "\n"));
+      // buffer.append(metaAnnotationMap == null ? "" :
+      // (metaAnnotationMap.toString()) + "\n");
       return buffer.toString();
    }
 

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-29 22:34:31 UTC (rev 382)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java	2008-12-01 07:21:12 UTC (rev 383)
@@ -19,6 +19,7 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Member;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -60,13 +61,31 @@
          return delegate;
       }
 
+      public void put(Class<? extends Annotation> key, AnnotatedParameter<Object> value)
+      {
+         List<AnnotatedParameter<Object>> parameters = super.get(key);
+         if (parameters == null)
+         {
+            parameters = new ArrayList<AnnotatedParameter<Object>>();
+            super.put(key, parameters);
+         }
+         parameters.add(value);
+      }
+
       @Override
       public String toString()
       {
          return Strings.mapToString("AnnotatedParameterMap (annotation type -> parameter abstraction list): ", delegate);
       }
-   }   
-   
+
+      @Override
+      public List<AnnotatedParameter<Object>> get(Object key)
+      {
+         List<AnnotatedParameter<Object>> parameters = super.get(key);
+         return parameters != null ? parameters : new ArrayList<AnnotatedParameter<Object>>();
+      }
+   }
+
    // The name of the member
    private String name;
 
@@ -139,13 +158,12 @@
    public String toString()
    {
       StringBuffer buffer = new StringBuffer();
-//      buffer.append("AbstractAnnotatedMember:\n");
-//      buffer.append(super.toString() + "\n");
-//      buffer.append("Final: " + isFinal() + "\n");
-//      buffer.append("Static: " + isStatic() + "\n");
-//      buffer.append("Name: " + getName() + "\n");
+      // buffer.append("AbstractAnnotatedMember:\n");
+      // buffer.append(super.toString() + "\n");
+      // buffer.append("Final: " + isFinal() + "\n");
+      // buffer.append("Static: " + isStatic() + "\n");
+      // buffer.append("Name: " + getName() + "\n");
       return buffer.toString();
    }
-   
-   
+
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java	2008-11-29 22:34:31 UTC (rev 382)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java	2008-12-01 07:21:12 UTC (rev 383)
@@ -64,6 +64,24 @@
       {
          return Strings.mapToString("AnnotatedMemberMap (annotation type -> set of member abstractions: ", delegate);
       }
+
+      @Override
+      public Set<AnnotatedMethod<?>> get(Object key)
+      {
+         Set<AnnotatedMethod<?>> methods = super.get(key);
+         return methods != null ? methods : new HashSet<AnnotatedMethod<?>>();
+      }
+
+      public void put(Class<? extends Annotation> key, AnnotatedMethod<?> value)
+      {
+         Set<AnnotatedMethod<?>> members = super.get(key);
+         if (members == null)
+         {
+            members = new HashSet<AnnotatedMethod<?>>();
+            super.put(key, members);
+         }
+         members.add(value);
+      }
    }
 
    // The annotated members map (annotation -> member with annotation)
@@ -170,15 +188,7 @@
       {
          initAnnotatedMembers();
       }
-
-      if (!annotatedMembers.containsKey(annotationType))
-      {
-         return new HashSet<AnnotatedMethod<?>>();
-      }
-      else
-      {
-         return annotatedMembers.get(annotationType);
-      }
+      return annotatedMembers.get(annotationType);
    }
 
    /**
@@ -201,11 +211,7 @@
       {
          for (Annotation annotation : member.getAnnotations())
          {
-            if (!annotatedMembers.containsKey(annotation))
-            {
-               annotatedMembers.put(annotation.annotationType(), new HashSet<AnnotatedMethod<?>>());
-            }
-            annotatedMembers.get(annotation.annotationType()).add(member);
+            annotatedMembers.put(annotation.annotationType(), member);
          }
       }
    }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java	2008-11-29 22:34:31 UTC (rev 382)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java	2008-12-01 07:21:12 UTC (rev 383)
@@ -29,7 +29,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.Map.Entry;
 
 import org.jboss.webbeans.introspector.AnnotatedClass;
 import org.jboss.webbeans.introspector.AnnotatedConstructor;
@@ -50,7 +49,8 @@
 {
 
    /**
-    * A (annotation type -> set of field abstractions with annotation/meta annotation) map
+    * A (annotation type -> set of field abstractions with annotation/meta
+    * annotation) map
     */
    private static class AnnotatedFieldMap extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedField<Object>>>
    {
@@ -73,6 +73,24 @@
          return Strings.mapToString("AnnotatedFieldMap (annotation type -> field abstraction set): ", delegate);
       }
 
+      @Override
+      public Set<AnnotatedField<Object>> get(Object key)
+      {
+         Set<AnnotatedField<Object>> fields = super.get(key);
+         return fields != null ? fields : new HashSet<AnnotatedField<Object>>();
+      }
+
+      public void put(Class<? extends Annotation> key, AnnotatedField<Object> value)
+      {
+         Set<AnnotatedField<Object>> fields = super.get(key);
+         if (fields == null)
+         {
+            fields = new HashSet<AnnotatedField<Object>>();
+            super.put(key, fields);
+         }
+         fields.add(value);
+      }
+
    }
 
    /**
@@ -98,6 +116,24 @@
       {
          return Strings.mapToString("AnnotatedMethodMap (annotation type -> method abstraction set): ", delegate);
       }
+
+      @Override
+      public Set<AnnotatedMethod<Object>> get(Object key)
+      {
+         Set<AnnotatedMethod<Object>> methods = super.get(key);
+         return methods != null ? methods : new HashSet<AnnotatedMethod<Object>>();
+      }
+
+      public void put(Class<? extends Annotation> key, AnnotatedMethod<Object> value)
+      {
+         Set<AnnotatedMethod<Object>> methods = super.get(key);
+         if (methods == null)
+         {
+            methods = new HashSet<AnnotatedMethod<Object>>();
+            super.put(key, methods);
+         }
+         methods.add(value);
+      }
    }
 
    /**
@@ -123,6 +159,24 @@
       {
          return Strings.mapToString("AnnotatedConstructorMap (annotation type -> constructor abstraction set): ", delegate);
       }
+
+      @Override
+      public Set<AnnotatedConstructor<T>> get(Object key)
+      {
+         Set<AnnotatedConstructor<T>> constructors = super.get(key);
+         return constructors != null ? constructors : new HashSet<AnnotatedConstructor<T>>();
+      }
+
+      public void add(Class<? extends Annotation> key, AnnotatedConstructor<T> value)
+      {
+         Set<AnnotatedConstructor<T>> constructors = super.get(key);
+         if (constructors == null)
+         {
+            constructors = new HashSet<AnnotatedConstructor<T>>();
+            super.put(key, constructors);
+         }
+         constructors.add(value);
+      }
    }
 
    /**
@@ -307,45 +361,14 @@
     */
    public Set<AnnotatedField<Object>> getMetaAnnotatedFields(Class<? extends Annotation> metaAnnotationType)
    {
-      if (metaAnnotatedFields == null)
+      if (annotatedFields == null || metaAnnotatedFields == null)
       {
-         metaAnnotatedFields = new AnnotatedFieldMap();
+         initAnnotatedAndMetaAnnotatedFields();
       }
-      if (annotatedFields == null)
-      {
-         initAnnotatedFields();
-      }
-      populateMetaAnnotatedFieldMap(metaAnnotationType, annotatedFields, metaAnnotatedFields);
       return metaAnnotatedFields.get(metaAnnotationType);
    }
 
    /**
-    * Populates the meta annotated fields map for a meta-annotation type
-    * 
-    * @param <T>
-    * @param metaAnnotationType The meta-annotation to examine
-    * @param annotatedFields The annotated fields
-    * @param metaAnnotatedFields The meta-annotated fields
-    * @return The meta-annotated fields map
-    */
-   protected static <T extends Annotation> AnnotatedFieldMap populateMetaAnnotatedFieldMap(Class<T> metaAnnotationType, AnnotatedFieldMap annotatedFields, AnnotatedFieldMap metaAnnotatedFields)
-   {
-      if (!metaAnnotatedFields.containsKey(metaAnnotationType))
-      {
-         Set<AnnotatedField<Object>> fields = new HashSet<AnnotatedField<Object>>();
-         for (Entry<Class<? extends Annotation>, Set<AnnotatedField<Object>>> entry : annotatedFields.entrySet())
-         {
-            if (entry.getKey().isAnnotationPresent(metaAnnotationType))
-            {
-               fields.addAll(entry.getValue());
-            }
-         }
-         metaAnnotatedFields.put(metaAnnotationType, fields);
-      }
-      return metaAnnotatedFields;
-   }
-
-   /**
     * Gets the abstracted field annotated with a specific annotation type
     * 
     * If the fields map is null, initialize it first
@@ -358,34 +381,37 @@
    {
       if (annotatedFields == null)
       {
-         initAnnotatedFields();
+         initAnnotatedAndMetaAnnotatedFields();
       }
       return annotatedFields.get(annotationType);
    }
 
    /**
-    * Initializes the annotated fields map
+    * Initializes the annotated/meta-annotated fields map
     * 
     * If the fields set if empty, populate it first. Iterate through the fields,
     * for each field, iterate over the annotations and map the field abstraction
-    * under the annotation type key.
+    * under the annotation type key. In the inner loop, iterate over the
+    * annotations of the annotations (the meta-annotations) and map the field
+    * under the meta-annotation type key.
     */
-   private void initAnnotatedFields()
+   private void initAnnotatedAndMetaAnnotatedFields()
    {
       if (fields == null)
       {
          initFields();
       }
       annotatedFields = new AnnotatedFieldMap();
+      metaAnnotatedFields = new AnnotatedFieldMap();
       for (AnnotatedField<Object> field : fields)
       {
          for (Annotation annotation : field.getAnnotations())
          {
-            if (!annotatedFields.containsKey(annotation))
+            annotatedFields.get(annotation.annotationType()).add(field);
+            for (Annotation metaAnnotation : annotation.annotationType().getAnnotations())
             {
-               annotatedFields.put(annotation.annotationType(), new HashSet<AnnotatedField<Object>>());
+               metaAnnotatedFields.put(metaAnnotation.annotationType(), field);
             }
-            annotatedFields.get(annotation.annotationType()).add(field);
          }
       }
    }
@@ -452,14 +478,7 @@
          initAnnotatedMethods();
       }
 
-      if (!annotatedMethods.containsKey(annotationType))
-      {
-         return new HashSet<AnnotatedMethod<Object>>();
-      }
-      else
-      {
-         return annotatedMethods.get(annotationType);
-      }
+      return annotatedMethods.get(annotationType);
    }
 
    /**
@@ -530,14 +549,7 @@
          initAnnotatedConstructors();
       }
 
-      if (!annotatedConstructors.containsKey(annotationType))
-      {
-         return new HashSet<AnnotatedConstructor<T>>();
-      }
-      else
-      {
-         return annotatedConstructors.get(annotationType);
-      }
+      return annotatedConstructors.get(annotationType);
    }
 
    /**
@@ -589,38 +601,44 @@
    public String toString()
    {
       StringBuffer buffer = new StringBuffer();
-//      buffer.append("AnnotatedConstructorImpl:\n");
-//      buffer.append(super.toString() + "\n");
-//      buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
-//      int i = 0;
-//      for (Type actualTypeArgument : actualTypeArguments)
-//      {
-//         buffer.append(++i + " - " + actualTypeArgument.toString());
-//      }
-//      buffer.append("Class: " + clazz.toString() + "\n");
-//      buffer.append("Fields: " + getFields().size() + "\n");
-//      i = 0;
-//      for (AnnotatedField<Object> field : getFields())
-//      {
-//         buffer.append(++i + " - " + field.toString());
-//      }
-//      buffer.append("Methods: " + methods.size() + "\n");
-//      i = 0;
-//      for (AnnotatedMethod<Object> method : methods)
-//      {
-//         buffer.append(++i + " - " + method.toString());
-//      }
-//      buffer.append("Constructors: " + methods.size() + "\n");
-//      i = 0;
-//      for (AnnotatedConstructor<T> constructor : getConstructors())
-//      {
-//         buffer.append(++i + " - " + constructor.toString());
-//      }
-//      buffer.append(annotatedConstructors == null ? "" : (annotatedConstructors.toString() + "\n"));
-//      buffer.append(annotatedFields == null ? "" : (annotatedFields.toString() + "\n"));
-//      buffer.append(annotatedMethods == null ? "" : (annotatedMethods.toString() + "\n"));
-//      buffer.append(constructorsByArgumentMap == null ? "" : (constructorsByArgumentMap.toString() + "\n"));
-//      buffer.append(metaAnnotatedFields == null ? "" : (metaAnnotatedFields.toString() + "\n"));
+      // buffer.append("AnnotatedConstructorImpl:\n");
+      // buffer.append(super.toString() + "\n");
+      // buffer.append("Actual type arguments: " + actualTypeArguments.length +
+      // "\n");
+      // int i = 0;
+      // for (Type actualTypeArgument : actualTypeArguments)
+      // {
+      // buffer.append(++i + " - " + actualTypeArgument.toString());
+      // }
+      // buffer.append("Class: " + clazz.toString() + "\n");
+      // buffer.append("Fields: " + getFields().size() + "\n");
+      // i = 0;
+      // for (AnnotatedField<Object> field : getFields())
+      // {
+      // buffer.append(++i + " - " + field.toString());
+      // }
+      // buffer.append("Methods: " + methods.size() + "\n");
+      // i = 0;
+      // for (AnnotatedMethod<Object> method : methods)
+      // {
+      // buffer.append(++i + " - " + method.toString());
+      // }
+      // buffer.append("Constructors: " + methods.size() + "\n");
+      // i = 0;
+      // for (AnnotatedConstructor<T> constructor : getConstructors())
+      // {
+      // buffer.append(++i + " - " + constructor.toString());
+      // }
+      // buffer.append(annotatedConstructors == null ? "" :
+      // (annotatedConstructors.toString() + "\n"));
+      // buffer.append(annotatedFields == null ? "" :
+      // (annotatedFields.toString() + "\n"));
+      // buffer.append(annotatedMethods == null ? "" :
+      // (annotatedMethods.toString() + "\n"));
+      // buffer.append(constructorsByArgumentMap == null ? "" :
+      // (constructorsByArgumentMap.toString() + "\n"));
+      // buffer.append(metaAnnotatedFields == null ? "" :
+      // (metaAnnotatedFields.toString() + "\n"));
       return buffer.toString();
    }
 

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java	2008-11-29 22:34:31 UTC (rev 382)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java	2008-12-01 07:21:12 UTC (rev 383)
@@ -170,15 +170,7 @@
       {
          initAnnotatedParameters();
       }
-
-      if (!annotatedParameters.containsKey(annotationType))
-      {
-         return new ArrayList<AnnotatedParameter<Object>>();
-      }
-      else
-      {
-         return annotatedParameters.get(annotationType);
-      }
+      return annotatedParameters.get(annotationType);
    }
 
    /**
@@ -199,11 +191,7 @@
       {
          for (Annotation annotation : parameter.getAnnotations())
          {
-            if (!annotatedParameters.containsKey(annotation))
-            {
-               annotatedParameters.put(annotation.annotationType(), new ArrayList<AnnotatedParameter<Object>>());
-            }
-            annotatedParameters.get(annotation.annotationType()).add(parameter);
+            annotatedParameters.put(annotation.annotationType(), parameter);
          }
       }
    }
@@ -225,10 +213,6 @@
       {
          initAnnotatedParameters();
       }
-      if (!annotatedParameters.containsKey(annotationType))
-      {
-         return new ArrayList<AnnotatedParameter<Object>>();
-      }
       return annotatedParameters.get(annotationType);
    }
 
@@ -314,25 +298,26 @@
    public String toString()
    {
       StringBuffer buffer = new StringBuffer();
-//      buffer.append("AnnotatedConstructorImpl:\n");
-//      buffer.append(super.toString() + "\n");
-//      buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
-//      int i = 0;
-//      for (Type actualTypeArgument : actualTypeArguments)
-//      {
-//         buffer.append(++i + " - " + actualTypeArgument.toString());
-//      }
-//      buffer.append("Declaring class:\n");
-//      buffer.append(declaringClass.toString() + "\n");
-//      buffer.append("Constructor:\n");
-//      buffer.append(constructor.toString() + "\n");
-//      buffer.append("Parameters: " + getParameters().size() + "\n");
-//      i = 0;
-//      for (AnnotatedParameter<?> parameter : getParameters())
-//      {
-//         buffer.append(++i + " - " + parameter.toString());
-//      }
-//      buffer.append(annotatedParameters.toString() + "\n");
+      // buffer.append("AnnotatedConstructorImpl:\n");
+      // buffer.append(super.toString() + "\n");
+      // buffer.append("Actual type arguments: " + actualTypeArguments.length +
+      // "\n");
+      // int i = 0;
+      // for (Type actualTypeArgument : actualTypeArguments)
+      // {
+      // buffer.append(++i + " - " + actualTypeArgument.toString());
+      // }
+      // buffer.append("Declaring class:\n");
+      // buffer.append(declaringClass.toString() + "\n");
+      // buffer.append("Constructor:\n");
+      // buffer.append(constructor.toString() + "\n");
+      // buffer.append("Parameters: " + getParameters().size() + "\n");
+      // i = 0;
+      // for (AnnotatedParameter<?> parameter : getParameters())
+      // {
+      // buffer.append(++i + " - " + parameter.toString());
+      // }
+      // buffer.append(annotatedParameters.toString() + "\n");
       return buffer.toString();
    }
 

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java	2008-11-29 22:34:31 UTC (rev 382)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java	2008-12-01 07:21:12 UTC (rev 383)
@@ -201,11 +201,7 @@
       {
          for (Annotation annotation : parameter.getAnnotations())
          {
-            if (!annotatedParameters.containsKey(annotation))
-            {
-               annotatedParameters.put(annotation.annotationType(), new ArrayList<AnnotatedParameter<Object>>());
-            }
-            annotatedParameters.get(annotation.annotationType()).add(parameter);
+            annotatedParameters.put(annotation.annotationType(), parameter);
          }
       }
    }
@@ -225,10 +221,6 @@
       {
          initAnnotatedParameters();
       }
-      if (!annotatedParameters.containsKey(annotationType))
-      {
-         return new ArrayList<AnnotatedParameter<Object>>();
-      }
       return annotatedParameters.get(annotationType);
    }
 
@@ -332,26 +324,28 @@
    public String toString()
    {
       StringBuffer buffer = new StringBuffer();
-//      buffer.append("AnnotatedMethodImpl:\n");
-//      buffer.append(super.toString() + "\n");
-//      buffer.append("Actual type arguments: " + actualTypeArguments.length + "\n");
-//      int i = 0;
-//      for (Type actualTypeArgument : actualTypeArguments)
-//      {
-//         buffer.append(++i + " - " + actualTypeArgument.toString());
-//      }
-//      buffer.append(annotatedParameters == null ? "" : (annotatedParameters.toString() + "\n"));
-//      buffer.append("Declaring class:\n");
-//      buffer.append(declaringClass.toString());
-//      buffer.append("Method:\n");
-//      buffer.append(method.toString());
-//      buffer.append("Property name: " + propertyName + "\n");
-//      i = 0;
-//      buffer.append("Parameters: " + getParameters().size() + "\n");
-//      for (AnnotatedParameter<?> parameter : parameters)
-//      {
-//         buffer.append(++i + " - " + parameter.toString() + "\n");
-//      }
+      // buffer.append("AnnotatedMethodImpl:\n");
+      // buffer.append(super.toString() + "\n");
+      // buffer.append("Actual type arguments: " + actualTypeArguments.length +
+      // "\n");
+      // int i = 0;
+      // for (Type actualTypeArgument : actualTypeArguments)
+      // {
+      // buffer.append(++i + " - " + actualTypeArgument.toString());
+      // }
+      // buffer.append(annotatedParameters == null ? "" :
+      // (annotatedParameters.toString() + "\n"));
+      // buffer.append("Declaring class:\n");
+      // buffer.append(declaringClass.toString());
+      // buffer.append("Method:\n");
+      // buffer.append(method.toString());
+      // buffer.append("Property name: " + propertyName + "\n");
+      // i = 0;
+      // buffer.append("Parameters: " + getParameters().size() + "\n");
+      // for (AnnotatedParameter<?> parameter : parameters)
+      // {
+      // buffer.append(++i + " - " + parameter.toString() + "\n");
+      // }
       return buffer.toString();
    }
 

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ListComparator.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ListComparator.java	2008-11-29 22:34:31 UTC (rev 382)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ListComparator.java	2008-12-01 07:21:12 UTC (rev 383)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.util;
 
 import java.util.Comparator;
@@ -3,14 +20,29 @@
 import java.util.List;
 
+/**
+ * List comparator based on element location
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T>
+ */
 public class ListComparator<T> implements Comparator<T>
 {
-   
+   // The source list
    private List<T> list;
-   
+
+   /**
+    * Constructor
+    * 
+    * @param list The source list
+    */
    public ListComparator(List<T> list)
    {
       this.list = list;
    }
 
+   /**
+    * Compares the entries
+    */
    public int compare(T o1, T o2)
    {

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/LoggerUtil.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/LoggerUtil.java	2008-11-29 22:34:31 UTC (rev 382)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/LoggerUtil.java	2008-12-01 07:21:12 UTC (rev 383)
@@ -1,3 +1,20 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.jboss.webbeans.util;
 
 import java.util.logging.Filter;
@@ -7,28 +24,32 @@
 
 public class LoggerUtil
 {
-
+   // The logging filter property
    public static final String FILTER_PROPERTY = "org.jboss.webbeans.logger.filter";
+   // The logging level property
    public static final String LEVEL_PROPERTY = "org.jboss.webbeans.logger.level";
-
+   // The Web Bean logger
    public static final String WEBBEANS_LOGGER = "javax.webbeans.";
-
+   // The current filter
    private static Filter filter;
-   
+   // The current level
    private static Level level;
 
+   /*
+    * Static init block
+    */
    static
    {
       String filterClassName = System.getProperty(FILTER_PROPERTY);
       if (filterClassName != null && !"".equals(filterClassName))
-      try
-      {
-         filter = (Filter) Class.forName(filterClassName).newInstance();
-      }
-      catch (Exception e)
-      {
-         throw new IllegalArgumentException("Unable to instantiate logging filter");
-      }
+         try
+         {
+            filter = (Filter) Class.forName(filterClassName).newInstance();
+         }
+         catch (Exception e)
+         {
+            throw new IllegalArgumentException("Unable to instantiate logging filter");
+         }
       String levelProperty = System.getProperty(LEVEL_PROPERTY);
       if (levelProperty != null && !"".equals(levelProperty))
       {
@@ -42,9 +63,15 @@
             handler.setLevel(level);
          }
       }
-      
+
    }
 
+   /**
+    * Gets a logger
+    * 
+    * @param name The name of the logger
+    * @return A logger implementation
+    */
    public static Logger getLogger(String name)
    {
       name = WEBBEANS_LOGGER + name;




More information about the weld-commits mailing list