[webbeans-commits] Webbeans SVN: r508 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Dec 9 17:00:33 EST 2008


Author: nickarls
Date: 2008-12-09 17:00:33 -0500 (Tue, 09 Dec 2008)
New Revision: 508

Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/FacadeImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/InstanceImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java
Log:
javadoc/comment/toString

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/FacadeImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/FacadeImpl.java	2008-12-09 21:03:47 UTC (rev 507)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/FacadeImpl.java	2008-12-09 22:00:33 UTC (rev 508)
@@ -59,7 +59,7 @@
    /**
     * Merges and validates the current and new bindings
     * 
-    * Checkes with an abstract method for annotations to exclude
+    * Checks with an abstract method for annotations to exclude
     * 
     * @param currentBindings Existing bindings
     * @param newBindings New bindings

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/InstanceImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/InstanceImpl.java	2008-12-09 21:03:47 UTC (rev 507)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/InstanceImpl.java	2008-12-09 22:00:33 UTC (rev 508)
@@ -24,22 +24,20 @@
 import javax.webbeans.Instance;
 import javax.webbeans.manager.Manager;
 
-import org.jboss.webbeans.util.Strings;
-
 /**
- * Implementation of the Event interface
+ * Helper implementation for Instance for getting instances
  * 
- * @author David Allen
+ * @author Gavin King
  * 
  * @param <T>
- * @see javax.webbeans.Event
+ * @see javax.webbeans.Instace
  */
 public class InstanceImpl<T> extends FacadeImpl<T> implements Instance<T>
 {
    /**
     * Constructor
     * 
-    * @param type The event type
+    * @param type The obtainable type
     * @param manager The Web Beans manager
     * @param bindingTypes The binding types
     */
@@ -48,6 +46,15 @@
       super(type, manager, bindingTypes);
    }
 
+   /**
+    * Gets an instance with the matching binding types
+    * 
+    * @param bindingTypes The binding types
+    * @return The instance
+    * 
+    * @see javax.webbeans.Instance#get(Annotation...)
+    * @see javax.webbeans.manager.Manager#getInstanceByType(Class, Annotation...)
+    */
    public T get(Annotation... bindingTypes) 
    {
       return manager.getInstanceByType(type, mergeBindings(bindingTypes));
@@ -56,13 +63,16 @@
    @Override
    public String toString()
    {
-      StringBuilder buffer = new StringBuilder();
-      buffer.append("Obtainable Instance:\n");
-      buffer.append(Strings.collectionToString("  Bindings: ", bindingTypes));
-      return buffer.toString();
+      return "Obtainable instance for type " + type + " and binding types " + bindingTypes;
    }
 
    /**
+    * Filters annotations from the binding type or parameter lists
+    * 
+    * This implementation filters no annotations
+    * 
+    * @return A set of annotations to filter
+    * 
     * @see org.jboss.webbeans.FacadeImpl#getFilteredAnnotations
     */
    @Override

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-12-09 21:03:47 UTC (rev 507)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java	2008-12-09 22:00:33 UTC (rev 508)
@@ -72,17 +72,29 @@
  */
 public class ManagerImpl implements Manager
 {
+   // The JNDI key to place the manager under
    public static final String JNDI_KEY = "java:comp/Manager";
 
+   // The enabled deployment types from web-beans.xml
    private List<Class<? extends Annotation>> enabledDeploymentTypes;
+   // The Web Beans manager
    private EventManager eventManager;
+   // The bean resolver
    private Resolver resolver;
+   // The registered contexts
    private ContextMap contextMap;
+   // The client proxy pool
    private ProxyPool proxyPool;
+   // The registered beans
    private List<Bean<?>> beans;
+   // The registered decorators
    private Set<Decorator> decorators;
+   // The registered interceptors
    private Set<Interceptor> interceptors;
 
+   /**
+    * Constructor
+    */
    @SuppressWarnings("unchecked")
    public ManagerImpl()
    {
@@ -109,7 +121,7 @@
 
    /**
     * Set up the enabled deployment types, if none are specified by the user,
-    * the default @Production and @Standard are used
+    * the default @Production and @Standard are used. For internal use.
     * 
     * @param enabledDeploymentTypes The enabled deployment types from
     *           web-beans.xml
@@ -155,7 +167,7 @@
    }
 
    /**
-    * Resolve the disposal method for the given producer method
+    * Resolve the disposal method for the given producer method. For internal use.
     * 
     * @param apiType The API type to match
     * @param bindingTypes The binding types to match
@@ -182,7 +194,7 @@
    }
 
    /**
-    * A strongly ordered list of enabled deployment types
+    * A strongly ordered, unmodifyable list of enabled deployment types
     * 
     * @return The ordered enabled deployment types known to the manager
     */
@@ -223,7 +235,7 @@
 
    /**
     * Check the resolution request is valid, and then ask the resolver to
-    * perform the resolution
+    * perform the resolution. For internal use.
     * 
     * @param element The item to resolve
     * @param bindingTypes The binding types to match
@@ -259,7 +271,7 @@
    /**
     * Wraps a collection of beans into a thread safe list. Since this overwrites
     * any existing list of beans in the manager, this should only be done on
-    * startup and other controlled situations.
+    * startup and other controlled situations. For internal use.
     * 
     * @param beans The set of beans to add
     * @return A reference to the manager
@@ -276,7 +288,7 @@
    }
 
    /**
-    * The beans registered with the Web Bean manager
+    * The beans registered with the Web Bean manager. For internal use
     * 
     * @return The list of known beans
     */
@@ -286,7 +298,7 @@
    }
 
    /**
-    * Adds a context
+    * Registers a context with the manager
     * 
     * @param context The context to add
     * @return A reference to the manager
@@ -300,9 +312,9 @@
    }
 
    /**
-    * Adds a decorator
+    * Registers a decorator with the manager
     * 
-    * @param decorator The decorator to add
+    * @param decorator The decorator to register
     * @return A reference to the manager
     * 
     * @see javax.webbeans.manager.Manager#addDecorator(javax.webbeans.manager.Decorator)
@@ -314,9 +326,9 @@
    }
 
    /**
-    * Adds an interceptor
+    * Registers an interceptor with the manager
     * 
-    * @param interceptor The interceptor to add
+    * @param interceptor The interceptor to register
     * @return A reference to the manager
     * 
     * @see javax.webbeans.manager.Manager#addInterceptor(javax.webbeans.manager.Interceptor)
@@ -328,9 +340,9 @@
    }
 
    /**
-    * Adds an observer for a given event type and binding types
+    * Registers an observer for a given event type and binding types
     * 
-    * @param observer The observer to add
+    * @param observer The observer to register
     * @param eventType The event type to match
     * @param bindings The bindings to match
     * @return A reference to the manager
@@ -345,9 +357,9 @@
    }
 
    /**
-    * Adds an observer for a given event type literal and binding types
+    * Registers an observer for a given event type literal and binding types
     * 
-    * @param observer The observer to add
+    * @param observer The observer to register
     * @param eventType The event type literal to match
     * @param bindings The bindings to match
     * @return A reference to the manager
@@ -358,7 +370,7 @@
    @SuppressWarnings("unchecked")
    public <T> Manager addObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings)
    {
-      this.eventManager.addObserver(observer, (Class<T>) eventType.getType(), bindings);
+      eventManager.addObserver(observer, (Class<T>) eventType.getType(), bindings);
       return this;
    }
 
@@ -391,8 +403,8 @@
       // Get the observers for this event. Although resolveObservers is
       // parameterized, this method is not, so we have to use
       // Observer<Object> for observers.
-      Set<Observer<Object>> observers = this.resolveObservers(event, bindings);
-      this.eventManager.notifyObservers(observers, event);
+      Set<Observer<Object>> observers = resolveObservers(event, bindings);
+      eventManager.notifyObservers(observers, event);
    }
 
    /**
@@ -431,10 +443,10 @@
    }
 
    /**
-    * Direct access to build in contexts for internal use
+    * Direct access to built in contexts. For internal use.
     * 
-    * @param scopeType
-    * @return
+    * @param scopeType The scope type of the context
+    * @return The context
     */
    public Context getBuiltInContext(Class<? extends Annotation> scopeType)
    {
@@ -636,7 +648,7 @@
    }
 
    /**
-    * Get the web bean resolver
+    * Get the web bean resolver. For internal use
     * 
     * @return The resolver
     */
@@ -646,7 +658,18 @@
    }
 
    @Override
-   public String toString()
+   public String toString() {
+      StringBuilder buffer = new StringBuilder();
+      buffer.append("Manager\n");
+      buffer.append("Enabled deployment types: " + getEnabledDeploymentTypes() + "\n");
+      buffer.append("Registered contexts: " + contextMap.keySet() + "\n");
+      buffer.append("Registered beans: " + getBeans().size() + "\n");
+      buffer.append("Registered decorators: " + decorators.size() + "\n");
+      buffer.append("Registered interceptors: " + interceptors.size() + "\n");
+      return buffer.toString();
+   }
+   
+   public String toDetailedString()
    {
       StringBuilder buffer = new StringBuilder();
       buffer.append(Strings.collectionToString("Enabled deployment types: ", getEnabledDeploymentTypes()));

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java	2008-12-09 21:03:47 UTC (rev 507)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java	2008-12-09 22:00:33 UTC (rev 508)
@@ -27,29 +27,50 @@
 import org.jboss.webbeans.util.ConcurrentCache;
 import org.jboss.webbeans.util.Strings;
 
+/**
+ * Metadata singleton for holding EJB metadata, scope models etc.
+ * 
+ * @author Pete Muir
+ * 
+ */
 public class MetaDataCache
 {
+   // The singleton instance
+   private static MetaDataCache instance;
 
-   private static MetaDataCache instance;
-   
+   /**
+    * Gets the singleton
+    * 
+    * @return The instance
+    */
    public static MetaDataCache instance()
    {
       return instance;
    }
-   
+
    static
    {
       instance = new MetaDataCache();
    }
-   
+
+   // The stereotype models
    private ConcurrentCache<Class<? extends Annotation>, StereotypeModel<?>> stereotypes = new ConcurrentCache<Class<? extends Annotation>, StereotypeModel<?>>();
-
+   // The scope models
    private ConcurrentCache<Class<? extends Annotation>, ScopeModel<?>> scopes = new ConcurrentCache<Class<? extends Annotation>, ScopeModel<?>>();
-
+   // The binding type models
    private ConcurrentCache<Class<? extends Annotation>, BindingTypeModel<?>> bindingTypes = new ConcurrentCache<Class<? extends Annotation>, BindingTypeModel<?>>();
-
+   // EJB metadata
    private ConcurrentCache<Class<?>, EjbMetaData<?>> ejbMetaDataMap = new ConcurrentCache<Class<?>, EjbMetaData<?>>();
 
+   /**
+    * Gets a stereotype model
+    * 
+    * Adds the model if it is not present.
+    * 
+    * @param <T> The type
+    * @param stereotype The stereotype
+    * @return The stereotype model
+    */
    public <T extends Annotation> StereotypeModel<T> getStereotype(final Class<T> stereotype)
    {
       return stereotypes.putIfAbsent(stereotype, new Callable<StereotypeModel<T>>()
@@ -62,6 +83,15 @@
       });
    }
 
+   /**
+    * Gets a scope model
+    * 
+    * Adds the model if it is not present.
+    * 
+    * @param <T> The type
+    * @param scopeType The scope type
+    * @return The scope type model
+    */
    public <T extends Annotation> ScopeModel<T> getScopeModel(final Class<T> scopeType)
    {
       return scopes.putIfAbsent(scopeType, new Callable<ScopeModel<T>>()
@@ -75,6 +105,15 @@
       });
    }
 
+   /**
+    * Gets a binding type model.
+    * 
+    * Adds the model if it is not present.
+    * 
+    * @param <T> The type
+    * @param bindingType The binding type
+    * @return The binding type model
+    */
    public <T extends Annotation> BindingTypeModel<T> getBindingTypeModel(final Class<T> bindingType)
    {
       return bindingTypes.putIfAbsent(bindingType, new Callable<BindingTypeModel<T>>()
@@ -88,6 +127,15 @@
       });
    }
 
+   /**
+    * Gets metadata for an EJB
+    * 
+    * Adds the model if it is not present
+    * 
+    * @param <T> The type
+    * @param clazz The class of the EJB
+    * @return The EJB metadata
+    */
    public <T> EjbMetaData<T> getEjbMetaData(final Class<T> clazz)
    {
       return ejbMetaDataMap.putIfAbsent(clazz, new Callable<EjbMetaData<T>>()
@@ -105,6 +153,17 @@
    public String toString()
    {
       StringBuilder buffer = new StringBuilder();
+      buffer.append("Metadata cache\n");
+      buffer.append("Registered binding type models: " + bindingTypes.size() + "\n");
+      buffer.append("Registered scope type models: " + scopes.size() + "\n");
+      buffer.append("Registered stereotype models: " + stereotypes.size() + "\n");
+      buffer.append("Registered EJB metadata: " + ejbMetaDataMap.size() + "\n");
+      return buffer.toString();
+   }
+
+   public String toDetailedString()
+   {
+      StringBuilder buffer = new StringBuilder();
       buffer.append("====================\n");
       buffer.append("Metadata cache\n");
       buffer.append("====================\n");

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java	2008-12-09 21:03:47 UTC (rev 507)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/Resolver.java	2008-12-09 22:00:33 UTC (rev 508)
@@ -38,7 +38,6 @@
 import org.jboss.webbeans.model.BindingTypeModel;
 import org.jboss.webbeans.util.ConcurrentCache;
 import org.jboss.webbeans.util.ListComparator;
-import org.jboss.webbeans.util.Strings;
 
 /**
  * Implementation of Web Beans type safe and name based bean resolution
@@ -79,25 +78,29 @@
       @Override
       public String toString()
       {
-         StringBuilder buffer = new StringBuilder();
-         buffer.append("Resolvable annotation item\n");
-         buffer.append(delegate().toString() + "\n");
-         return buffer.toString();
+         return "Resolvable annotated item for " + delegate();
       }
 
    }
 
+   // The resolved injection points
    private ConcurrentCache<ResolvableAnnotatedItem<?, ?>, Set<Bean<?>>> resolvedInjectionPoints;
+   // The registerd injection points
    private Set<AnnotatedItem<?, ?>> injectionPoints;
-
+   // The resolved names
    private ConcurrentCache<String, Set<Bean<?>>> resolvedNames;
-   
+   // The Web Beans manager
    private ManagerImpl manager;
 
+   /**
+    * Constructor
+    * 
+    * @param manager The Web Beans manager
+    */
    public Resolver(ManagerImpl manager)
    {
       this.injectionPoints = new HashSet<AnnotatedItem<?, ?>>();
-      this.resolvedInjectionPoints = new ConcurrentCache<ResolvableAnnotatedItem<?,?>, Set<Bean<?>>>();
+      this.resolvedInjectionPoints = new ConcurrentCache<ResolvableAnnotatedItem<?, ?>, Set<Bean<?>>>();
       this.resolvedNames = new ConcurrentCache<String, Set<Bean<?>>>();
       this.manager = manager;
    }
@@ -105,12 +108,22 @@
    /**
     * Add multiple injection points for later resolving using
     * {@link #registerInjectionPoint(AnnotatedItem)}. Useful during bootstrap.
+    * 
+    * @param elements The injection points to add
     */
    public void addInjectionPoints(Collection<AnnotatedItem<?, ?>> elements)
    {
       injectionPoints.addAll(elements);
    }
 
+   /**
+    * Registers an injection point
+    * 
+    * @param <T>
+    * @param <S>
+    * @param element The injection point to add
+    * @return A set of matching beans for the injection point
+    */
    private <T, S> Set<Bean<T>> registerInjectionPoint(final ResolvableAnnotatedItem<T, S> element)
    {
       Callable<Set<Bean<T>>> callable = new Callable<Set<Bean<T>>>()
@@ -142,7 +155,7 @@
     */
    public void clear()
    {
-      this.resolvedInjectionPoints = new ConcurrentCache<ResolvableAnnotatedItem<?,?>, Set<Bean<?>>>();
+      this.resolvedInjectionPoints = new ConcurrentCache<ResolvableAnnotatedItem<?, ?>, Set<Bean<?>>>();
       resolvedNames = new ConcurrentCache<String, Set<Bean<?>>>();
    }
 
@@ -169,6 +182,9 @@
 
    /**
     * Get the possible beans for the given element
+    * 
+    * @param key The resolving criteria
+    * @return An unmodifiable set of matching beans
     */
    @SuppressWarnings("unchecked")
    public <T, S> Set<Bean<T>> get(final AnnotatedItem<T, S> key)
@@ -200,6 +216,9 @@
 
    /**
     * Get the possible beans for the given name
+    * 
+    * @param name The name to match
+    * @return The set of matching beans
     */
    public Set<Bean<?>> get(final String name)
    {
@@ -223,6 +242,14 @@
       });
    }
 
+   /**
+    * Filters out the beans with the highest enabled deployment type
+    * 
+    * @param <T>
+    * @param beans The beans to filter
+    * @param enabledDeploymentTypes The enabled deployment types
+    * @return The filtered beans
+    */
    private static <T> Set<Bean<T>> retainHighestPrecedenceBeans(Set<Bean<T>> beans, List<Class<? extends Annotation>> enabledDeploymentTypes)
    {
       if (beans.size() > 0)
@@ -254,6 +281,14 @@
       }
    }
 
+   /**
+    * Gets the matching beans for binding criteria from a list of beans
+    * 
+    * @param <T> The type of the beans
+    * @param element The binding criteria
+    * @param beans The beans to filter
+    * @return A set of filtered beans
+    */
    @SuppressWarnings("unchecked")
    private <T> Set<Bean<T>> getMatchingBeans(AnnotatedItem<T, ?> element, List<Bean<?>> beans)
    {
@@ -268,6 +303,13 @@
       return resolvedBeans;
    }
 
+   /**
+    * Checks if binding criteria fulfill all binding types
+    * 
+    * @param element The binding criteria to check
+    * @param bindingTypes The binding types to check
+    * @return True if all matches, false otherwise
+    */
    private boolean containsAllBindingBindingTypes(AnnotatedItem<?, ?> element, Set<Annotation> bindingTypes)
    {
       for (Annotation bindingType : element.getBindingTypes())
@@ -296,12 +338,26 @@
       return true;
    }
 
+   /**
+    * Resolves decorators according to binding criteria
+    * 
+    * @param types The set of API types to match
+    * @param bindingTypes The binding types to match
+    * @return The set of matching decorators
+    */
    public List<Decorator> resolveDecorators(Set<Class<?>> types, Annotation[] bindingTypes)
    {
       // TODO Auto-generated method stub
       return null;
    }
 
+   /**
+    * Resolves interceptors according to binding criteria
+    * 
+    * @param types The set of API types to match
+    * @param bindingTypes The binding types to match
+    * @return The set of matching interceptors
+    */
    public List<Interceptor> resolveInterceptors(InterceptionType type, Annotation[] interceptorBindings)
    {
       // TODO Auto-generated method stub
@@ -313,9 +369,9 @@
    {
       StringBuilder buffer = new StringBuilder();
       buffer.append("Resolver\n");
-      buffer.append(resolvedInjectionPoints.toString() + "\n");
-      buffer.append(Strings.collectionToString("Injection points: ", injectionPoints));
-      buffer.append(Strings.mapToString("Resolved names: ", resolvedNames));
+      buffer.append("Injection points: " + injectionPoints.size() + "\n");
+      buffer.append("Resolved injection points: " + resolvedInjectionPoints.size() + "\n");
+      buffer.append("Resolved names points: " + resolvedNames.size() + "\n");
       return buffer.toString();
    }
 




More information about the weld-commits mailing list