[webbeans-commits] Webbeans SVN: r348 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: bean and 5 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Fri Nov 21 05:16:45 EST 2008


Author: nickarls
Date: 2008-11-21 05:16:45 -0500 (Fri, 21 Nov 2008)
New Revision: 348

Modified:
   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/bean/AbstractBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ForwardingBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlEnterpriseBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlSimpleBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
Log:
Header blocks, javadocs, toString

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-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -669,10 +669,7 @@
          buffer.append("  " + deploymentType.getName() + "\n");
       }
 
-      buffer.append("Event manager:\n");
       buffer.append(eventManager.toString());
-
-      buffer.append("Metadata cache:\n");
       buffer.append(metaDataCache.toString());
 
       buffer.append("Resolver:\n");

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-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/MetaDataCache.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -20,6 +20,7 @@
 import java.lang.annotation.Annotation;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.jboss.webbeans.ejb.EjbMetaData;
 import org.jboss.webbeans.model.AnnotationModel;
@@ -60,7 +61,7 @@
       {
          return delegate;
       }
-
+      
    }
 
    @SuppressWarnings("unchecked")
@@ -97,6 +98,27 @@
          return new BindingTypeModel<S>(type);
       }
 
+      @Override
+      public String toString() {
+         StringBuffer buffer = new StringBuffer();
+         buffer.append("Binding types\n");
+         for (Entry<Class<? extends Annotation>, BindingTypeModel<?>> entry : delegate.entrySet()) {
+            buffer.append(entry.getKey().getName() + ": " + entry.getValue().toString() + "\n");
+         }
+         buffer.append("EJB metadata\n");
+         for (Entry<Class<?>, EjbMetaData<?>> entry : ejbMetaDataMap.entrySet()) {
+            buffer.append(entry.getKey().getName() + ": " + entry.getValue().toString());
+         }
+         buffer.append("Scopes\n");
+         for (Entry<Class<? extends Annotation>, ScopeModel<?>> entry : scopes.entrySet()) {
+            buffer.append(entry.getKey().getName() + ": " + entry.getValue().toString());
+         }
+         buffer.append("Stereotypes\n");
+         for (Entry<Class<? extends Annotation>, StereotypeModel<?>> entry : stereotypes.entrySet()) {
+            buffer.append(entry.getKey().getName() + ": " + entry.getValue().toString());
+         }
+         return buffer.toString();
+      }
    }
 
    private class EjbMetaDataMap extends ForwardingMap<Class<?>, EjbMetaData<?>>
@@ -161,11 +183,20 @@
    {
       return ejbMetaDataMap.putIfAbsent(clazz);
    }
-   
+
    @Override
-   public String toString() {
+   public String toString()
+   {
       StringBuffer buffer = new StringBuffer();
-      buffer.append("FIX ME!\n");
+      buffer.append("Metadata cache\n");
+      buffer.append(bindingTypes.toString());
+      buffer.append(ejbMetaDataMap.toString());
+      buffer.append(scopes.toString());
+      buffer.append("Stereotypes:\n");
+      for (Entry<Class<? extends Annotation>, StereotypeModel<?>> entry : stereotypes.entrySet())
+      {
+         buffer.append(entry.getKey().getName() + ": " + entry.getValue().toString() + "\n");
+      }
       return buffer.toString();
    }
 

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-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -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.bean;
 
 import java.lang.annotation.Annotation;
@@ -31,11 +48,27 @@
 import org.jboss.webbeans.log.Logging;
 import org.jboss.webbeans.util.Reflections;
 
+/**
+ * An abstract bean representation common for all beans
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T>
+ * @param <E>
+ */
 public abstract class AbstractBean<T, E> extends Bean<T>
 {
-   
+
+   @SuppressWarnings("unchecked")
    private static Set<Class<?>> STANDARD_WEB_BEAN_CLASSES = new HashSet<Class<?>>(Arrays.asList(DefaultEnterpriseBeanLookup.class));
-   
+
+   /**
+    * Helper class for getting deployment type
+    * 
+    * @param enabledDeploymentTypes The currently enabled deployment types
+    * @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)
    {
       for (int i = (enabledDeploymentTypes.size() - 1); i > 0; i--)
@@ -47,10 +80,10 @@
       }
       return null;
    }
-   
+
    // Logger
    private LogProvider log = Logging.getLogProvider(AbstractBean.class);
-   
+
    // Reference to WBRI manager
    private ManagerImpl manager;
    private Set<Annotation> bindingTypes;
@@ -62,18 +95,26 @@
    protected AnnotatedMethod<Object> removeMethod;
    protected Set<Class<?>> apiTypes;
    protected Set<AnnotatedItem<?, ?>> injectionPoints;
-   
+
    private boolean primitive;
-   
+
    // Cached values
    private Type declaredBeanType;
-   
+
+   /**
+    * Constructor
+    * 
+    * @param manager The Web Beans manager
+    */
    public AbstractBean(ManagerImpl manager)
    {
       super(manager);
       this.manager = manager;
    }
-   
+
+   /**
+    * Initializes the bean and its metadata
+    */
    protected void init()
    {
       mergedStereotypes = new MergedStereotypes<T, E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class), manager);
@@ -87,15 +128,21 @@
       initScopeType();
       initApiTypes();
    }
-   
+
+   /**
+    * Initializes the API types
+    */
    protected void initApiTypes()
    {
-      apiTypes = getTypeHierachy(getType());
+      apiTypes = Reflections.getTypeHierachy(getType());
    }
-   
+
+   /**
+    * Initializes the binding types
+    */
    protected void initBindingTypes()
    {
-      
+
       this.bindingTypes = new HashSet<Annotation>();
       if (isDefinedInXml())
       {
@@ -134,7 +181,11 @@
          return;
       }
    }
-   
+
+   /**
+    * Initializes the deployment types
+    */
+   @SuppressWarnings("null")
    protected void initDeploymentType()
    {
       if (isDefinedInXml())
@@ -144,7 +195,7 @@
          {
             throw new RuntimeException("At most one deployment type may be specified (" + xmlDeploymentTypes + " are specified)");
          }
-         
+
          if (xmlDeploymentTypes.size() == 1)
          {
             this.deploymentType = xmlDeploymentTypes.iterator().next().annotationType();
@@ -155,7 +206,7 @@
       else
       {
          Set<Annotation> deploymentTypes = getAnnotatedItem().getMetaAnnotations(DeploymentType.class);
-         
+
          if (deploymentTypes.size() > 1)
          {
             throw new DefinitionException("At most one deployment type may be specified (" + deploymentTypes + " are specified) on " + getAnnotatedItem().toString());
@@ -166,7 +217,7 @@
             log.trace("Deployment type " + deploymentType + " specified by annotation");
             return;
          }
-         
+
          if (getMergedStereotypes().getPossibleDeploymentTypes().size() > 0)
          {
             this.deploymentType = getDeploymentType(manager.getEnabledDeploymentTypes(), getMergedStereotypes().getPossibleDeploymentTypes());
@@ -174,12 +225,15 @@
             return;
          }
       }
-      
+
       this.deploymentType = Production.class;
       log.trace("Using default @Production deployment type");
       return;
    }
-   
+
+   /**
+    * Initializes the injection points
+    */
    protected void initInjectionPoints()
    {
       injectionPoints = new HashSet<AnnotatedItem<?, ?>>();
@@ -191,7 +245,10 @@
          }
       }
    }
-   
+
+   /**
+    * Initializes the name
+    */
    protected void initName()
    {
       boolean beanNameDefaulted = false;
@@ -244,22 +301,26 @@
             return;
          }
       }
-      
+
       if (beanNameDefaulted || getMergedStereotypes().isBeanNameDefaulted())
       {
          this.name = getDefaultName();
          return;
       }
    }
-   
+
+   /**
+    * Initializes the primitive flag
+    */
    protected void initPrimitive()
    {
       this.primitive = Reflections.isPrimitive(getType());
    }
-   
+
    /**
-    * Return the scope of the bean
+    * Initializes the scope type
     */
+   @SuppressWarnings("null")
    protected void initScopeType()
    {
       if (isDefinedInXml())
@@ -269,7 +330,7 @@
          {
             throw new DefinitionException("At most one scope may be specified in XML");
          }
-         
+
          if (scopeTypes.size() == 1)
          {
             this.scopeType = scopeTypes.iterator().next();
@@ -283,7 +344,7 @@
          {
             throw new DefinitionException("At most one scope may be specified");
          }
-         
+
          if (getAnnotatedItem().getMetaAnnotations(ScopeType.class).size() == 1)
          {
             this.scopeType = getAnnotatedItem().getMetaAnnotations(ScopeType.class).iterator().next().annotationType();
@@ -291,7 +352,7 @@
             return;
          }
       }
-      
+
       if (getMergedStereotypes().getPossibleScopeTypes().size() == 1)
       {
          this.scopeType = getMergedStereotypes().getPossibleScopeTypes().iterator().next().annotationType();
@@ -305,9 +366,15 @@
       this.scopeType = Dependent.class;
       log.trace("Using default @Dependent scope");
    }
-   
+
+   /**
+    * Initializes the type of the bean
+    */
    protected abstract void initType();
-   
+
+   /**
+    * Validates the deployment type
+    */
    protected void checkDeploymentType()
    {
       if (deploymentType == null)
@@ -319,30 +386,56 @@
          throw new DefinitionException(getAnnotatedItem() + " cannot have deployment type @Standard");
       }
    }
-   
+
+   /**
+    * Destroys a bean instance
+    * 
+    * @param instance The instance to destroy
+    */
    @Override
    public void destroy(T instance)
    {
       // TODO Auto-generated method stub
    }
-   
+
+   /**
+    * Binds the decorators to the proxy
+    */
    protected void bindDecorators()
    {
       // TODO
    }
-   
+
+   /**
+    * Binds the interceptors to the proxy
+    */
    protected void bindInterceptors()
    {
       // TODO
    }
-   
+
+   /**
+    * Returns the annotated time the bean reresents
+    * 
+    * @return The annotated item
+    */
    protected abstract AnnotatedItem<T, E> getAnnotatedItem();
-   
+
+   /**
+    * Returns the binding types
+    * 
+    * @return The set of binding types
+    */
    public Set<Annotation> getBindingTypes()
    {
       return bindingTypes;
    }
-   
+
+   /**
+    * Returns the declared bean type
+    * 
+    * @return The bean type
+    */
    protected Type getDeclaredBeanType()
    {
       if (declaredBeanType == null)
@@ -359,102 +452,202 @@
       }
       return declaredBeanType;
    }
-   
+
+   /**
+    * Returns the default name of the bean
+    * 
+    * @return The default name
+    */
    protected abstract String getDefaultName();
-   
+
+   /**
+    * Returns the deployment type of the bean
+    * 
+    * @return The deployment type
+    */
    public Class<? extends Annotation> getDeploymentType()
    {
       return deploymentType;
    }
-   
+
+   /**
+    * Returns the injection points of the bean
+    * 
+    * @return The set of injection points
+    */
    public Set<AnnotatedItem<?, ?>> getInjectionPoints()
    {
       return injectionPoints;
    }
-   
+
+   /**
+    * Returns the Web Beans manager reference
+    * 
+    * @return The manager
+    */
    @Override
    protected ManagerImpl getManager()
    {
       return manager;
    }
-   
+
+   /**
+    * Returns the merged sterotypes of the bean
+    * 
+    * @return The set of merged stereotypes
+    */
    public MergedStereotypes<T, E> getMergedStereotypes()
    {
       return mergedStereotypes;
    }
-   
+
+   /**
+    * Returns the name of the bean
+    * 
+    * @return The name
+    */
    public String getName()
    {
       return name;
    }
-   
+
+   /**
+    * Returns the remove method of the bean
+    * 
+    * @return The remove method
+    */
    public AnnotatedMethod<?> getRemoveMethod()
    {
       return removeMethod;
    }
-   
+
+   /**
+    * Returns the scope type of the bean
+    * 
+    * @return The scope type
+    */
    public Class<? extends Annotation> getScopeType()
    {
       return scopeType;
    }
-   
+
+   /**
+    * Returns the specializes type of the bean
+    * 
+    * @return The specialized type
+    */
    protected AbstractBean<? extends T, E> getSpecializedType()
    {
       throw new UnsupportedOperationException();
    }
-   
+
+   /**
+    * Returns the type of the bean
+    * 
+    * @return The type
+    */
    public Class<T> getType()
    {
       return type;
    }
-   
-   protected Set<Class<?>> getTypeHierachy(Class<?> clazz)
-   {
-      Set<Class<?>> classes = new HashSet<Class<?>>();
-      if (clazz != null)
-      {
-         classes.add(clazz);
-         classes.addAll(getTypeHierachy(clazz.getSuperclass()));
-         for (Class<?> c : clazz.getInterfaces())
-         {
-            classes.addAll(getTypeHierachy(c));
-         }
-      }
-      return classes;
-   }
-   
+
+   /**
+    * Returns the API types of the bean
+    * 
+    * @return The set of API types
+    */
    @Override
    public Set<Class<?>> getTypes()
    {
       return apiTypes;
    }
-   
+
+   /**
+    * Checks if this beans annotated item is assignable from another annotated
+    * item
+    * 
+    * @param annotatedItem The other annotation to check
+    * @return True if assignable, otherwise false
+    */
    public boolean isAssignableFrom(AnnotatedItem<?, ?> annotatedItem)
    {
       return this.getAnnotatedItem().isAssignableFrom(annotatedItem);
    }
-   
+
+   /**
+    * Indicates if bean was defined in XML
+    * 
+    * @return True if defined in XML, false if defined with annotations
+    */
    protected boolean isDefinedInXml()
    {
       return false;
    }
-   
+
+   /**
+    * Inicates if bean is nullable
+    * 
+    * @return True if nullable, false otherwise
+    */
    @Override
    public boolean isNullable()
    {
       return !isPrimitive();
    }
-   
+
+   /**
+    * Indicates if bean type is a primitive
+    * 
+    * @return True if primitive, false otherwise
+    */
    public boolean isPrimitive()
    {
       return primitive;
    }
-   
+
+   /**
+    * Indicates if bean is serializable
+    * 
+    * @return True if serializable, false otherwise
+    */
    @Override
    public boolean isSerializable()
    {
       // TODO Auto-generated method stub
       return false;
    }
-   
+
+   @Override
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("Name: " + name + "\n");
+      buffer.append("Type: " + type + "\n");
+      buffer.append("Scope type " + scopeType.getName() + "\n");
+      buffer.append("Deployment type: " + deploymentType.getName() + "\n");
+      buffer.append("Primitive : " + primitive + "\n");
+      buffer.append("Declared bean type: " + (declaredBeanType == null ? "null" : declaredBeanType.toString()) + "\n");
+      buffer.append("Remove method: " + (removeMethod == null ? "null" : removeMethod.toString()) + "\n");
+      buffer.append("Binding types: " + bindingTypes.size() + "\n");
+      int i = 0;
+      for (Annotation bindingType : bindingTypes)
+      {
+         buffer.append(++i + " - " + bindingType.toString() + "\n");
+      }
+      buffer.append("API types: " + apiTypes.size() + "\n");
+      i = 0;
+      for (Class<?> apiType : apiTypes)
+      {
+         buffer.append(++i + " - " + apiType.getName() + "\n");
+      }
+      buffer.append("Merged stereotype\n");
+      buffer.append(mergedStereotypes.toString() + "\n");
+      buffer.append("Injection points: " + injectionPoints.size() + "\n");
+      i = 0;
+      for (AnnotatedItem<?, ?> injectionPoint : injectionPoints)
+      {
+         buffer.append(++i + " - " + injectionPoint.toString() + "\n");
+      }
+      return buffer.toString();
+   }
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -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.bean;
 
 import java.util.HashSet;
@@ -21,27 +38,38 @@
 import org.jboss.webbeans.util.Reflections;
 import org.jboss.webbeans.util.Strings;
 
+/**
+ * An abstract bean representation common for class-based beans
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T>
+ * @param <E>
+ */
 public abstract class AbstractClassBean<T> extends AbstractBean<T, Class<T>>
 {
-   
+
    private static final LogProvider log = Logging.getLogProvider(AbstractClassBean.class);
-   
+
    private AnnotatedClass<T> annotatedItem;
    private Set<AnnotatedField<Object>> injectableFields;
    private Set<AnnotatedMethod<Object>> initializerMethods;
-   
+
    /**
     * 
     * @param annotatedItem Annotations read from java classes
     * @param xmlAnnotatedItem Annotations read from XML
-    * @param manager
+    * @param manager The Web Beans manager
     */
    public AbstractClassBean(Class<T> type, ManagerImpl manager)
    {
       super(manager);
       this.annotatedItem = new AnnotatedClassImpl<T>(type);
    }
-   
+
+   /**
+    * Initializes the bean and its metadata
+    */
    @Override
    protected void init()
    {
@@ -52,7 +80,10 @@
       // TODO Interceptors
       initInitializerMethods();
    }
-   
+
+   /**
+    * Initializes the bean type
+    */
    protected void initType()
    {
       if (isDefinedInXml())
@@ -65,12 +96,20 @@
          this.type = getAnnotatedItem().getType();
       }
    }
-   
+
+   /**
+    * Returns the producer methods
+    * 
+    * @return A set of producer methods
+    */
    public Set<AnnotatedMethod<Object>> getProducerMethods()
    {
       return getAnnotatedItem().getAnnotatedMethods(Produces.class);
    }
-   
+
+   /**
+    * Initializes the injection points
+    */
    @Override
    protected void initInjectionPoints()
    {
@@ -90,12 +129,15 @@
          super.injectionPoints.add(annotatedField);
       }
    }
-   
+
+   /**
+    * Initializes the initializer methods
+    */
    protected void initInitializerMethods()
    {
       if (isDefinedInXml())
       {
-        
+
       }
       else
       {
@@ -129,7 +171,10 @@
          }
       }
    }
-   
+
+   /**
+    * Validates that the required types are implemented
+    */
    protected void checkRequiredTypesImplemented()
    {
       for (Class<?> requiredType : getMergedStereotypes().getRequiredTypes())
@@ -141,10 +186,10 @@
          }
       }
    }
-   
+
    /**
-    * Check that the scope type is allowed by the stereotypes on the bean and the bean type
-    * @param type 
+    * Validate that the scope type is allowed by the stereotypes on the bean and
+    * the bean type
     */
    protected void checkScopeAllowed()
    {
@@ -157,7 +202,10 @@
          }
       }
    }
-   
+
+   /**
+    * Validates the bean implementation
+    */
    protected void checkBeanImplementation()
    {
       if (Reflections.isAbstract(getType()))
@@ -165,30 +213,69 @@
          throw new DefinitionException("Web Bean implementation class " + type + " cannot be declared abstract");
       }
    }
-   
+
+   /**
+    * Returns the annotated item
+    * 
+    * @return The annotated item
+    */
    @Override
    protected AnnotatedClass<T> getAnnotatedItem()
    {
       return annotatedItem;
    }
-   
+
+   /**
+    * Returns the default name
+    * 
+    * @return The default name
+    */
    @Override
    protected String getDefaultName()
    {
-      String name = Strings.decapitalize(getType().getSimpleName()); 
-      log.trace("Default name of " + type + " is " + name );
+      String name = Strings.decapitalize(getType().getSimpleName());
+      log.trace("Default name of " + type + " is " + name);
       return name;
    }
-   
+
+   /**
+    * Returns the injectable fields
+    * 
+    * @return The set of injectable fields
+    */
    public Set<AnnotatedField<Object>> getInjectableFields()
    {
       return injectableFields;
    }
-   
+
+   /**
+    * Returns the annotated methods
+    * 
+    * @return The set of annotated methods
+    */
    public Set<AnnotatedMethod<Object>> getInitializerMethods()
    {
       return initializerMethods;
    }
 
-   
+   @Override
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append(super.toString());
+      buffer.append("Annotated item: " + annotatedItem.toString() + "\n");
+      buffer.append("Initializer methods: " + initializerMethods.size() + "\n");
+      int i = 0;
+      for (AnnotatedMethod<?> initializerMethod : initializerMethods)
+      {
+         buffer.append(++i + " - " + initializerMethod.toString());
+      }
+      i = 0;
+      buffer.append("Injectable fields " + injectableFields.size());
+      for (AnnotatedField<?> injectableField : injectableFields)
+      {
+         buffer.append(++i + " - " + injectableField.toString());
+      }
+      return buffer.toString();
+   }
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -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.bean;
 
 import javax.webbeans.ApplicationScoped;
@@ -20,19 +37,35 @@
 import org.jboss.webbeans.introspector.AnnotatedMethod;
 import org.jboss.webbeans.introspector.AnnotatedParameter;
 
+/**
+ * An enterprise bean representation
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T>
+ */
 public class EnterpriseBean<T> extends AbstractClassBean<T>
 {
-   
+
    private String location;
-   
+
    private EjbMetaData<T> ejbMetaData;
-   
-   public EnterpriseBean(Class<T> type, ManagerImpl container)
+
+   /**
+    * Constructor
+    * 
+    * @param type The type of the bean
+    * @param manager The Web Beans manager
+    */
+   public EnterpriseBean(Class<T> type, ManagerImpl manager)
    {
-      super(type, container);
+      super(type, manager);
       init();
    }
-   
+
+   /**
+    * Initializes the bean and its metadata
+    */
    @Override
    protected void init()
    {
@@ -46,7 +79,10 @@
       checkSpecialization();
       checkRemoveMethod();
    }
-   
+
+   /**
+    * Initializes the injection points
+    */
    @Override
    protected void initInjectionPoints()
    {
@@ -59,7 +95,10 @@
          }
       }
    }
-   
+
+   /**
+    * Validates for non-conflicting roles
+    */
    protected void checkConflictingRoles()
    {
       if (getType().isAnnotationPresent(Interceptor.class))
@@ -75,32 +114,22 @@
    /**
     * Check that the scope type is allowed by the stereotypes on the bean and
     * the bean type
-    * 
-    * @param type
     */
    protected void checkEnterpriseScopeAllowed()
    {
-      if (getEjbMetaData().isStateless()
-            && !getScopeType().equals(Dependent.class))
+      if (getEjbMetaData().isStateless() && !getScopeType().equals(Dependent.class))
       {
-         throw new DefinitionException("Scope " + getScopeType()
-               + " is not allowed on stateless enterpise beans for "
-               + getType()
-               + ". Only @Dependent is allowed on stateless enterprise beans");
+         throw new DefinitionException("Scope " + getScopeType() + " is not allowed on stateless enterpise beans for " + getType() + ". Only @Dependent is allowed on stateless enterprise beans");
       }
-      if (getEjbMetaData().isSingleton()
-            && (!(getScopeType().equals(Dependent.class) || getScopeType()
-                  .equals(ApplicationScoped.class))))
+      if (getEjbMetaData().isSingleton() && (!(getScopeType().equals(Dependent.class) || getScopeType().equals(ApplicationScoped.class))))
       {
-         throw new DefinitionException(
-               "Scope "
-                     + getScopeType()
-                     + " is not allowed on singleton enterpise beans for "
-                     + getType()
-                     + ". Only @Dependent or @ApplicationScoped is allowed on singleton enterprise beans");
+         throw new DefinitionException("Scope " + getScopeType() + " is not allowed on singleton enterpise beans for " + getType() + ". Only @Dependent or @ApplicationScoped is allowed on singleton enterprise beans");
       }
    }
-   
+
+   /**
+    * Validates specialization
+    */
    private void checkSpecialization()
    {
       if (!getType().isAnnotationPresent(Specializes.class))
@@ -113,7 +142,7 @@
          {
             throw new DefinitionException("Annotation defined specializing EJB must have EJB superclass");
          }
-      } 
+      }
       else
       {
          if (getManager().getMetaDataCache().getEjbMetaData(getAnnotatedItem().getSuperclass().getType()).isEjb())
@@ -122,8 +151,10 @@
          }
       }
    }
-   
-// TODO logging
+
+   /**
+    * Initializes the remvoe method
+    */
    protected void initRemoveMethod()
    {
       if (!getEjbMetaData().isStateful())
@@ -131,14 +162,13 @@
          // Nothing to do for stateless enterprise beans;
          return;
       }
-      
+
       // >1 @Destructor
       if (getEjbMetaData().getDestructorMethods().size() > 1)
       {
          throw new DefinitionException("Multiple @Destructor methods not allowed on " + getAnnotatedItem());
       }
 
-
       // <1 (0) @Destructors
       if (getEjbMetaData().getNoArgsRemoveMethods().size() == 1)
       {
@@ -152,34 +182,45 @@
       }
 
    }
-   
+
+   /**
+    * Validates the remove method
+    */
    private void checkRemoveMethod()
    {
-      if (removeMethod != null)
+      if (removeMethod == null)
       {
-         if (removeMethod.isAnnotationPresent(Destructor.class) && !removeMethod.isAnnotationPresent(EJB.REMOVE_ANNOTATION)) 
-         {
-            throw new DefinitionException("Methods marked @Destructor must also be marked @Remove on " + removeMethod.getName());
-         }
-         else if (removeMethod.isAnnotationPresent(Initializer.class)) 
-         {
-            throw new DefinitionException("Remove methods cannot be initializers on " + removeMethod.getName());
-         }
-         else if (removeMethod.isAnnotationPresent(Produces.class)) 
-         {
-            throw new DefinitionException("Remove methods cannot be producers on " + removeMethod.getName());
-         }
-         else if (removeMethod.getAnnotatedParameters(Disposes.class).size() > 0) 
-         {
-            throw new DefinitionException("Remove method can't have @Disposes annotated parameters on " + removeMethod.getName());
-         }
-         else if (removeMethod.getAnnotatedParameters(Observes.class).size() > 0) 
-         {
-            throw new DefinitionException("Remove method can't have @Observes annotated parameters on " + removeMethod.getName());
-         }
+         return;
       }
+
+      if (removeMethod.isAnnotationPresent(Destructor.class) && !removeMethod.isAnnotationPresent(EJB.REMOVE_ANNOTATION))
+      {
+         throw new DefinitionException("Methods marked @Destructor must also be marked @Remove on " + removeMethod.getName());
+      }
+      else if (removeMethod.isAnnotationPresent(Initializer.class))
+      {
+         throw new DefinitionException("Remove methods cannot be initializers on " + removeMethod.getName());
+      }
+      else if (removeMethod.isAnnotationPresent(Produces.class))
+      {
+         throw new DefinitionException("Remove methods cannot be producers on " + removeMethod.getName());
+      }
+      else if (removeMethod.getAnnotatedParameters(Disposes.class).size() > 0)
+      {
+         throw new DefinitionException("Remove method can't have @Disposes annotated parameters on " + removeMethod.getName());
+      }
+      else if (removeMethod.getAnnotatedParameters(Observes.class).size() > 0)
+      {
+         throw new DefinitionException("Remove method can't have @Observes annotated parameters on " + removeMethod.getName());
+      }
    }
 
+   /**
+    * Creates an instance of the bean
+    * 
+    * @return The instance
+    */
+   @SuppressWarnings("unchecked")
    @Override
    public T create()
    {
@@ -189,15 +230,25 @@
       injectEjbAndCommonFields();
       injectBoundFields(instance);
       callInitializers(instance);
-      return instance;      
+      return instance;
    }
-   
+
+   /**
+    * Destroys an instance of a bean
+    * 
+    * @param instance The instance
+    */
    @Override
    public void destroy(T instance)
    {
       super.destroy(instance);
    }
 
+   /**
+    * Calls all initializers of the bean
+    * 
+    * @param instance The bean instance
+    */
    protected void callInitializers(T instance)
    {
       for (AnnotatedMethod<Object> initializer : getInitializerMethods())
@@ -205,12 +256,20 @@
          initializer.invoke(getManager(), instance);
       }
    }
-   
+
+   /**
+    * Injects EJBs and common fields
+    */
    protected void injectEjbAndCommonFields()
    {
       // TODO
    }
-   
+
+   /**
+    * Injects bound fields
+    * 
+    * @param instance The bean instance
+    */
    protected void injectBoundFields(T instance)
    {
       for (AnnotatedField<?> field : getInjectableFields())
@@ -219,50 +278,70 @@
       }
    }
 
+   /**
+    * Gets the debugging location info
+    * 
+    * @return The location string
+    */
    public String getLocation()
    {
       if (location == null)
       {
-         location = "type: Enterprise Bean; declaring class: " + getType() +";";
+         location = "type: Enterprise Bean; declaring class: " + getType() + ";";
       }
       return location;
    }
 
+   /**
+    * Returns the specializes type of the bean
+    * 
+    * @return The specialized type
+    */
+   @SuppressWarnings("unchecked")
    @Override
    protected AbstractBean<? extends T, Class<T>> getSpecializedType()
    {
-      //TODO: lots of validation!
+      // TODO: lots of validation!
       Class<?> superclass = getAnnotatedItem().getType().getSuperclass();
-      if ( superclass!=null )
+      if (superclass != null)
       {
          return new EnterpriseBean(superclass, getManager());
       }
-      else {
+      else
+      {
          throw new RuntimeException();
       }
-      
+
    }
 
+   /**
+    * Validates the bean type
+    */
    private void checkEnterpriseBeanTypeAllowed()
    {
       if (getEjbMetaData().isMessageDriven())
       {
-         throw new DefinitionException(
-               "Message Driven Beans can't be Web Beans");
+         throw new DefinitionException("Message Driven Beans can't be Web Beans");
       }
    }
 
+   /**
+    * Returns the EJB metadata
+    * 
+    * @return The metadata
+    */
    protected EjbMetaData<T> getEjbMetaData()
    {
       return ejbMetaData;
    }
-   
+
    @Override
    public String toString()
    {
-      return "EnterpriseBean[" + getType().getName() + "]";
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("EnterpriseBean[" + getType().getName() + "]\n");
+      buffer.append(ejbMetaData.toString() + "\n");
+      return buffer.toString();
    }
 
-   
-   
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -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.bean;
 
 import java.lang.reflect.Field;
@@ -13,11 +30,18 @@
 import org.jboss.webbeans.log.LogProvider;
 import org.jboss.webbeans.log.Logging;
 
+/**
+ * An event bean representation
+ * 
+ * @author David Allen
+ * 
+ * @param <T>
+ */
 public class EventBean<T> extends AbstractBean<EventImpl<T>, Field>
 {
-   
+
    private static LogProvider log = Logging.getLogProvider(EventBean.class);
-   
+
    private String location;
    private AnnotatedField<EventImpl<T>> annotatedItem;
 
@@ -29,26 +53,27 @@
    }
 
    /**
-    * Caches the constructor for this type of bean to avoid future reflections during use.
+    * Caches the constructor for this type of bean to avoid future reflections
+    * during use.
     */
-   @SuppressWarnings("unchecked")
+   @SuppressWarnings("unused")
    private void initConstructor()
    {
       try
       {
-         //constructor = new SimpleConstructor<T>((Constructor<T>) EventImpl.class.getConstructor((Class[])null));
-      } catch (Exception e)
+         // constructor = new SimpleConstructor<T>((Constructor<T>)
+         // EventImpl.class.getConstructor((Class[])null));
+      }
+      catch (Exception e)
       {
          log.warn("Unable to get constructor for build-in Event implementation", e);
       }
    }
 
+   /*
+    * public BeanConstructor<T> getConstructor() { return constructor; }
+    */
 
-   /*public BeanConstructor<T> getConstructor()
-   {
-      return constructor;
-   }*/
-
    public String getLocation()
    {
       if (location == null)
@@ -71,7 +96,7 @@
       this.type = annotatedItem.getType();
    }
 
-    @Override
+   @Override
    protected AnnotatedItem<EventImpl<T>, Field> getAnnotatedItem()
    {
       return annotatedItem;
@@ -96,7 +121,7 @@
    {
       // No - op
    }
-   
+
    @Override
    protected void initName()
    {
@@ -110,12 +135,11 @@
       // This is always @Dependent per 7.4
       this.scopeType = Dependent.class;
    }
-   
+
    @Override
    public EventImpl<T> create()
    {
       return new EventImpl<T>();
    }
 
-   
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ForwardingBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ForwardingBean.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ForwardingBean.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -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.bean;
 
 import java.lang.annotation.Annotation;
@@ -6,6 +23,13 @@
 import javax.webbeans.manager.Bean;
 import javax.webbeans.manager.Manager;
 
+/**
+ * A delegating bean
+ * 
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
 public abstract class ForwardingBean<T> extends Bean<T>
 {
    

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-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/MergedStereotypes.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -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.bean;
 
 import java.lang.annotation.Annotation;
@@ -5,24 +22,31 @@
 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.model.StereotypeModel;
 
 /**
  * Meta model for the merged stereotype for a bean
+ * 
  * @author pmuir
- *
+ * 
  */
 public class MergedStereotypes<T, E>
 {
-
    private Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes;
    private Set<Annotation> possibleScopeTypes;
    private boolean beanNameDefaulted;
    private Set<Class<?>> requiredTypes;
    private Set<Class<? extends Annotation>> supportedScopes;
-   
+
+   /**
+    * Constructor
+    * 
+    * @param stereotypeAnnotations The stereotypes to merge
+    * @param manager The Web Beans manager
+    */
    public MergedStereotypes(Set<Annotation> stereotypeAnnotations, ManagerImpl manager)
    {
       possibleDeploymentTypes = new HashMap<Class<? extends Annotation>, Annotation>();
@@ -31,7 +55,13 @@
       supportedScopes = new HashSet<Class<? extends Annotation>>();
       merge(stereotypeAnnotations, manager);
    }
-   
+
+   /**
+    * Perform the merge
+    * 
+    * @param stereotypeAnnotations The stereotype annotations
+    * @param manager The Web Beans manager
+    */
    protected void merge(Set<Annotation> stereotypeAnnotations, ManagerImpl manager)
    {
       for (Annotation stereotypeAnnotation : stereotypeAnnotations)
@@ -52,41 +82,104 @@
          }
          requiredTypes.addAll(stereotype.getRequiredTypes());
          supportedScopes.addAll(stereotype.getSupportedScopes());
-         if (stereotype.isBeanNameDefaulted()) 
+         if (stereotype.isBeanNameDefaulted())
          {
             beanNameDefaulted = true;
          }
       }
    }
-   
+
+   /**
+    * Returns the possible deployment typess
+    * 
+    * @return The deployment types
+    */
    public Map<Class<? extends Annotation>, Annotation> getPossibleDeploymentTypes()
    {
       return possibleDeploymentTypes;
    }
-   
+
+   /**
+    * Returns the possible scope types
+    * 
+    * @return The scope types
+    */
    public Set<Annotation> getPossibleScopeTypes()
    {
       return possibleScopeTypes;
    }
-   
+
+   /**
+    * Indicates if the name i defaulted
+    * 
+    * @return True if defaulted, false if not
+    */
    public boolean isBeanNameDefaulted()
    {
       return beanNameDefaulted;
    }
-   
+
+   /**
+    * Returns the required types
+    * 
+    * @return The required types
+    */
    public Set<Class<?>> getRequiredTypes()
    {
       return requiredTypes;
    }
-   
+
+   /**
+    * Returns the supported scopes
+    * 
+    * @return The supported scopes
+    */
    public Set<Class<? extends Annotation>> getSupportedScopes()
    {
       return supportedScopes;
    }
-   
+
+   /**
+    * Indicates if the bean was declared in XML
+    * 
+    * @return True if declared in XML, else false
+    */
    public boolean isDeclaredInXml()
    {
       return false;
    }
-   
+
+   @Override
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("Merged stereotype\n");
+      buffer.append("Bean name defaulted: " + beanNameDefaulted);
+      buffer.append("Possible deployment types: " + possibleDeploymentTypes.size());
+      int i = 0;
+      for (Entry<Class<? extends Annotation>, Annotation> entry : possibleDeploymentTypes.entrySet())
+      {
+         buffer.append(++i + " - " + entry.getKey().getName() + ": " + entry.getValue().toString());
+      }
+      buffer.append("Possible scope types: " + possibleScopeTypes.size());
+      i = 0;
+      for (Annotation scopeType : possibleScopeTypes)
+      {
+         buffer.append(++i + " - " + scopeType.toString());
+      }
+      buffer.append("Required types: " + requiredTypes.size());
+      i = 0;
+      for (Class<?> requiredType : requiredTypes)
+      {
+         buffer.append(++i + " - " + requiredType.getName());
+      }
+      buffer.append("Supported scopes: " + supportedScopes.size());
+      i = 0;
+      for (Class<?> supportedScope : supportedScopes)
+      {
+         buffer.append(++i + " - " + supportedScope.getName());
+      }
+      return buffer.toString();
+   }
+
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -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.bean;
 
 import java.lang.annotation.Annotation;
@@ -18,6 +35,13 @@
 import org.jboss.webbeans.introspector.AnnotatedParameter;
 import org.jboss.webbeans.introspector.jlr.AnnotatedMethodImpl;
 
+/**
+ * Represents a producer method bean
+ * 
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
 public class ProducerMethodBean<T> extends AbstractBean<T, Method>
 {
    
@@ -27,11 +51,25 @@
    // Cached values
    private String location;
 
+   /**
+    * Constructor
+    * 
+    * @param method The producer method
+    * @param declaringBean The declaring bean instance
+    * @param manager The Web Beans manager
+    */
    public ProducerMethodBean(Method method, AbstractClassBean<?> declaringBean, ManagerImpl manager)
    {
       this(new AnnotatedMethodImpl<T>(method, declaringBean.getAnnotatedItem()), declaringBean, manager);
    }
    
+   /**
+    * Constructor
+    * 
+    * @param method The producer method abstraction
+    * @param declaringBean The declaring bean
+    * @param manager The Web Beans manager
+    */
    public ProducerMethodBean(AnnotatedMethod<T> method, AbstractClassBean<?> declaringBean, ManagerImpl manager)
    {
       super(manager);
@@ -40,6 +78,11 @@
       init();
    }
 
+   /**
+    * Creates an instance of the bean
+    * 
+    * @returns The instance
+    */
    @Override
    public T create()
    {
@@ -51,6 +94,9 @@
       return instance;
    }
 
+   /**
+    * Initializes the bean and its metadata
+    */
    @Override
    protected void init()
    {
@@ -60,6 +106,9 @@
       initInjectionPoints();
    }
    
+   /**
+    * Initializes the injection points
+    */   
    @Override
    protected void initInjectionPoints()
    {
@@ -77,6 +126,9 @@
       }
    }
    
+   /**
+    * Initializes the deployment type
+    */
    @Override
    protected void initDeploymentType()
    {
@@ -87,6 +139,9 @@
       }
    }
    
+   /**
+    * Validates the producer method
+    */
    protected void checkProducerMethod()
    {
       if (getAnnotatedItem().isStatic())
@@ -117,6 +172,9 @@
       }
    }
    
+   /**
+    * Initializes the remove method
+    */
    protected void initRemoveMethod()
    {
       Set<AnnotatedMethod<Object>> disposalMethods = getManager().resolveDisposalMethods(getType(), getBindingTypes().toArray(new Annotation[0]));
@@ -131,24 +189,32 @@
       }
    }
    
-   @Override
-   public String toString()
-   {
-      return "ProducerMethodBean[" + getType().getName() + "]";
-   }
 
+   /**
+    * Gets the annotated item representing the method
+    * 
+    * @return The annotated item
+    */
    @Override
    protected AnnotatedMethod<T> getAnnotatedItem()
    {
       return method;
    }
 
+   /**
+    * Returns the default name
+    * 
+    * @return The default name
+    */
    @Override
    protected String getDefaultName()
    {
       return method.getPropertyName();
    }
 
+   /**
+    * Initializes the type
+    */
    @Override
    protected void initType()
    {
@@ -165,6 +231,9 @@
       }
    }
    
+   /**
+    * Initializes the API types
+    */
    @Override
    protected void initApiTypes()
    {
@@ -185,8 +254,11 @@
       }
    }
    
-
-   
+   /**
+    * Gets the debugging location info
+    * 
+    * @return The location string
+    */   
    public String getLocation()
    {
       if (location == null)
@@ -196,15 +268,37 @@
       return location;
    }
    
+   /**
+    * Returns the disposal method
+    * 
+    * @return The method representation
+    */
    public AnnotatedMethod<?> getDisposalMethod()
    {
       return removeMethod;
    }
    
+   /**
+    * Returns the declaring bean
+    * 
+    * @return The bean representation
+    */
    public AbstractClassBean<?> getDeclaringBean()
    {
       return declaringBean;
    }
 
+   @Override
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("ProducerMethodBean[" + getType().getName() + "]\n");
+      buffer.append(super.toString() + "\n");
+      buffer.append("Location: " + location + "\n");
+      buffer.append("Declaring bean: " + declaringBean.toString() + "\n");
+      buffer.append("Method: " + method.toString() + "\n");
+      return buffer.toString();      
+   }
+
    
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -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.bean;
 
 import java.util.Collections;
@@ -18,24 +35,42 @@
 import org.jboss.webbeans.log.Logging;
 import org.jboss.webbeans.util.Reflections;
 
+/**
+ * Represents a simple bean
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T>
+ */
 public class SimpleBean<T> extends AbstractClassBean<T>
 {
-   
+
    private static LogProvider log = Logging.getLogProvider(SimpleBean.class);
    private static List<Class<?>> NO_ARGUMENTS = Collections.emptyList();
-   
+
    private AnnotatedConstructor<T> constructor;
    private String location;
-   
+
    private AnnotatedMethod<Object> postConstruct;
    private AnnotatedMethod<Object> preDestroy;
-   
+
+   /**
+    * Constructor
+    * 
+    * @param type The type of the bean
+    * @param manager The Web Beans manager
+    */
    public SimpleBean(Class<T> type, ManagerImpl manager)
    {
       super(type, manager);
       init();
    }
 
+   /**
+    * Creates an instance of the bean
+    * 
+    * @return The instance
+    */
    @Override
    public T create()
    {
@@ -48,45 +83,65 @@
       callPostConstruct(instance);
       return instance;
    }
-   
+
+   /**
+    * Destroys an instance of the bean
+    * 
+    * @param instance The instance
+    */
    @Override
    public void destroy(T instance)
    {
       callPreDestroy(instance);
    }
-   
+
+   /**
+    * Calls the pre-destroy method, if any
+    * 
+    * @param instance The instance to invoke the method on
+    */
    protected void callPreDestroy(T instance)
    {
       AnnotatedMethod<Object> preDestroy = getPreDestroy();
-      if (preDestroy!=null)
+      if (preDestroy != null)
       {
          try
          {
             preDestroy.invoke(instance);
          }
-         catch (Exception e) 
+         catch (Exception e)
          {
             throw new RuntimeException("Unable to invoke " + preDestroy + " on " + instance, e);
          }
-     }
+      }
    }
-   
+
+   /**
+    * Calls the post-construct method, if any
+    * 
+    * @param instance The instance to invoke the method on
+    */
    protected void callPostConstruct(T instance)
    {
       AnnotatedMethod<Object> postConstruct = getPostConstruct();
-      if (postConstruct!=null)
+      if (postConstruct != null)
       {
          try
          {
             postConstruct.invoke(instance);
          }
-         catch (Exception e) 
+         catch (Exception e)
          {
             throw new RuntimeException("Unable to invoke " + postConstruct + " on " + instance, e);
          }
       }
    }
 
+   /**
+    * Calls any initializers
+    * 
+    * @param instance The instance to invoke the initializers on
+    */
    protected void callInitializers(T instance)
    {
       for (AnnotatedMethod<Object> initializer : getInitializerMethods())
@@ -94,12 +149,20 @@
          initializer.invoke(getManager(), instance);
       }
    }
-   
+
+   /**
+    * Injects EJBs and common fields
+    */
    protected void injectEjbAndCommonFields()
    {
       // TODO
    }
-   
+
+   /**
+    * Injects bound fields
+    * 
+    * @param instance The instance to inject into
+    */
    protected void injectBoundFields(T instance)
    {
       for (AnnotatedField<?> injectableField : getInjectableFields())
@@ -107,7 +170,10 @@
          injectableField.inject(instance, getManager());
       }
    }
-   
+
+   /**
+    * Initializes the bean and its metadata
+    */
    @Override
    protected void init()
    {
@@ -119,7 +185,10 @@
       initPreDestroy();
       // TODO Interceptors
    }
-   
+
+   /**
+    * Initializes the injection points
+    */
    @Override
    protected void initInjectionPoints()
    {
@@ -129,7 +198,12 @@
          injectionPoints.add(parameter);
       }
    }
-   
+
+   /**
+    * Validates the type
+    * 
+    * @param type The type to validate
+    */
    public static void checkType(Class<?> type)
    {
       if (Reflections.isNonStaticInnerClass(type))
@@ -141,7 +215,10 @@
          throw new DefinitionException("Simple Web Bean " + type + " cannot be a parameterized type");
       }
    }
-   
+
+   /**
+    * Initializes the constructor
+    */
    protected void initConstructor()
    {
       Set<AnnotatedConstructor<T>> initializerAnnotatedConstructors = getAnnotatedItem().getAnnotatedConstructors(Initializer.class);
@@ -156,84 +233,100 @@
       else if (initializerAnnotatedConstructors.size() == 1)
       {
          this.constructor = initializerAnnotatedConstructors.iterator().next();
-         log.trace("Exactly one constructor (" + constructor +") annotated with @Initializer defined, using it as the bean constructor for " + getType());
+         log.trace("Exactly one constructor (" + constructor + ") annotated with @Initializer defined, using it as the bean constructor for " + getType());
          return;
       }
-         
+
       if (getAnnotatedItem().getConstructor(NO_ARGUMENTS) != null)
       {
-         
-         this.constructor =getAnnotatedItem().getConstructor(NO_ARGUMENTS);
-         log.trace("Exactly one constructor (" + constructor +") defined, using it as the bean constructor for " + getType());
+
+         this.constructor = getAnnotatedItem().getConstructor(NO_ARGUMENTS);
+         log.trace("Exactly one constructor (" + constructor + ") defined, using it as the bean constructor for " + getType());
          return;
       }
-      
+
       throw new DefinitionException("Cannot determine constructor to use for " + getType());
    }
-   
+
+   /**
+    * Initializes the post-construct method
+    */
    protected void initPostConstruct()
    {
       Set<AnnotatedMethod<Object>> postConstructMethods = getAnnotatedItem().getAnnotatedMethods(PostConstruct.class);
       log.trace("Found " + postConstructMethods + " constructors annotated with @Initializer for " + getType());
       if (postConstructMethods.size() > 1)
       {
-         //TODO: actually this is wrong, in EJB you can have @PostConstruct methods on the superclass,
-         //      though the Web Beans spec is silent on the issue
+         // TODO: actually this is wrong, in EJB you can have @PostConstruct
+         // methods on the superclass,
+         // though the Web Beans spec is silent on the issue
          throw new DefinitionException("Cannot have more than one post construct method annotated with @Initializer for " + getType());
       }
       else if (postConstructMethods.size() == 1)
       {
          this.postConstruct = postConstructMethods.iterator().next();
-         log.trace("Exactly one post construct method (" + postConstruct +") for " + getType());
-        return;
+         log.trace("Exactly one post construct method (" + postConstruct + ") for " + getType());
+         return;
       }
    }
 
+   /**
+    * Initializes the pre-destroy method
+    */
    protected void initPreDestroy()
    {
       Set<AnnotatedMethod<Object>> preDestroyMethods = getAnnotatedItem().getAnnotatedMethods(PreDestroy.class);
       log.trace("Found " + preDestroyMethods + " constructors annotated with @Initializer for " + getType());
       if (preDestroyMethods.size() > 1)
       {
-         //TODO: actually this is wrong, in EJB you can have @PreDestroy methods on the superclass,
-         //      though the Web Beans spec is silent on the issue
+         // TODO: actually this is wrong, in EJB you can have @PreDestroy
+         // methods on the superclass,
+         // though the Web Beans spec is silent on the issue
          throw new DefinitionException("Cannot have more than one pre destroy method annotated with @Initializer for " + getType());
       }
       else if (preDestroyMethods.size() == 1)
       {
          this.preDestroy = preDestroyMethods.iterator().next();
-         log.trace("Exactly one post construct method (" + preDestroy +") for " + getType());
-        return;
+         log.trace("Exactly one post construct method (" + preDestroy + ") for " + getType());
+         return;
       }
    }
 
-
+   /**
+    * Returns the constructor
+    * 
+    * @return The constructor
+    */
    public AnnotatedConstructor<T> getConstructor()
    {
       return constructor;
    }
-   
 
-   @Override
-   public String toString()
-   {
-      return "SimpleWebBean[" + getAnnotatedItem().toString() + "]";
-   }
-   
+   /**
+    * Gets the debugging location info
+    * 
+    * @return The location string
+    */
    public String getLocation()
    {
       if (location == null)
       {
-         location = "type: Simple Bean; declaring class: " + getType() +";";
+         location = "type: Simple Bean; declaring class: " + getType() + ";";
       }
       return location;
    }
 
+   /**
+    * Returns the specializes type of the bean
+    * 
+    * @return The specialized type
+    */
+   @SuppressWarnings("unchecked")
    protected AbstractBean<? extends T, Class<T>> getSpecializedType()
    {
-      //TODO: lots of validation!
+      // TODO: lots of validation!
       Class<?> superclass = getAnnotatedItem().getType().getSuperclass();
-      if ( superclass!=null )
+      if (superclass != null)
       {
          return new SimpleBean(superclass, getManager());
       }
@@ -242,15 +335,38 @@
          throw new RuntimeException();
       }
    }
-   
-   public AnnotatedMethod<Object> getPostConstruct() 
+
+   /**
+    * Returns the post-construct method
+    * 
+    * @return The post-construct method
+    */
+   public AnnotatedMethod<Object> getPostConstruct()
    {
       return postConstruct;
    }
-   
-   public AnnotatedMethod<Object> getPreDestroy() 
+
+   /**
+    * Returns the pre-destroy method
+    * 
+    * @return The pre-destroy method
+    */
+   public AnnotatedMethod<Object> getPreDestroy()
    {
       return preDestroy;
    }
-   
+
+   @Override
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("SimpleWebBean[" + getAnnotatedItem().toString() + "]\n");
+      buffer.append(super.toString() + "\n");
+      buffer.append("Location: " + location + "\n");
+      buffer.append("Constructor: " + constructor.toString() + "\n");
+      buffer.append("Post-construct: " + (postConstruct == null ? "null" : postConstruct.toString()) + "\n");
+      buffer.append("Pre-destroy: " + (preDestroy == null ? "null" : preDestroy.toString()) + "\n");
+      return buffer.toString();
+   }
+
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlEnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlEnterpriseBean.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlEnterpriseBean.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -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.bean;
 
 import org.jboss.webbeans.ManagerImpl;
@@ -2,14 +19,39 @@
 
+/**
+ * Represents an XML defined enterprise bean
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T>
+ */
 public class XmlEnterpriseBean<T> extends EnterpriseBean<T>
 {
 
+   /**
+    * Constructor
+    * 
+    * @param type The type of the bean
+    * @param manager The Web Beans manager
+    */
    public XmlEnterpriseBean(Class<T> type, ManagerImpl manager)
    {
       super(type, manager);
    }
-   
+
+   /**
+    * Indicates the bean was defined in XML
+    */
    protected boolean isDefinedInXml()
    {
       return true;
    }
+   
+   @Override
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("XML-defined enterprise bean\n");
+      buffer.append(super.toString());
+      return buffer.toString();
+   }   
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlSimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlSimpleBean.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/XmlSimpleBean.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -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.bean;
 
 import org.jboss.webbeans.ManagerImpl;
@@ -2,14 +19,39 @@
 
+/**
+ * Represents a simple, XML defined bean
+ * 
+ * @author Pete Muir
+ * 
+ * @param <T>
+ */
 public class XmlSimpleBean<T> extends SimpleBean<T>
 {
 
+   /**
+    * Constructor
+    * 
+    * @param type The type of the bean
+    * @param manager The Web Beans manager
+    */
    public XmlSimpleBean(Class<T> type, ManagerImpl manager)
    {
       super(type, manager);
    }
-   
+
+   /**
+    * Indicates the bean was defined in XML
+    */
    protected boolean isDefinedInXml()
    {
       return true;
    }
+
+   @Override
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("XML-defined simple bean\n");
+      buffer.append(super.toString());
+      return buffer.toString();
+   }
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -1,19 +1,19 @@
 /*
-* 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.
-*/
+ * 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.bean.proxy;
 
@@ -29,9 +29,9 @@
 import org.jboss.webbeans.util.Reflections;
 
 /**
- * A Javassist MethodHandler that delegates method calls to a proxied bean.
- * If the transient bean has become null, it is looked up from the manager
- * bean list before the invocation.
+ * A Javassist MethodHandler that delegates method calls to a proxied bean. If
+ * the transient bean has become null, it is looked up from the manager bean
+ * list before the invocation.
  * 
  * @author Nicklas Karlsson
  * 
@@ -62,13 +62,13 @@
    /**
     * The method proxy
     * 
-    * Uses reflection to look up the corresponding method on the proxy and executes 
-    * that method with the same parameters.
+    * Uses reflection to look up the corresponding method on the proxy and
+    * executes that method with the same parameters.
     * 
-    *  @param self A reference to the proxy
-    *  @param method The method to execute
-    *  @param process The next method to proceed to
-    *  @param args The method calling arguments 
+    * @param self A reference to the proxy
+    * @param method The method to execute
+    * @param process The next method to proceed to
+    * @param args The method calling arguments
     */
    public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Throwable
    {
@@ -81,5 +81,15 @@
       Method proxiedMethod = Reflections.lookupMethod(method, proxiedInstance);
       return proxiedMethod.invoke(proxiedInstance, args);
    }
-   
+
+   @Override
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("Proxy method handler\n");
+      buffer.append("Bean " + (bean == null ? "null" : bean.toString()));
+      buffer.append("Bean index: " + beanIndex + "\n");
+      return buffer.toString();
+   }
+
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -1,19 +1,19 @@
 /*
-* 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.
-*/
+ * 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.bean.proxy;
 
@@ -50,46 +50,61 @@
     */
    private class Pool extends ForwardingMap<Bean<?>, Object>
    {
-      
+
       Map<Bean<?>, Object> delegate;
-      
+
       public Pool()
       {
          delegate = new ConcurrentHashMap<Bean<?>, Object>();
       }
 
+      @SuppressWarnings("unchecked")
       public <T> T get(Bean<T> key)
       {
          return (T) super.get(key);
       }
-      
+
       @Override
       protected Map<Bean<?>, Object> delegate()
       {
          return delegate;
       }
-      
+
+      @Override
+      public String toString()
+      {
+         StringBuffer buffer = new StringBuffer();
+         buffer.append("Proxy pool holding " + delegate.size() + " proxies\n");
+         int i = 0;
+         for (Entry<Bean<?>, Object> entry : delegate.entrySet())
+         {
+            buffer.append(i + " - " + entry.getKey().toString() + ": " + entry.getValue().toString());
+         }
+         return buffer.toString();
+      }
+
    }
-   
+
    private ManagerImpl manager;
    private Pool pool;
-   
-   public ProxyPool(ManagerImpl manager) 
+
+   public ProxyPool(ManagerImpl manager)
    {
       this.manager = manager;
       this.pool = new Pool();
    }
-        
+
    /**
     * Type info (interfaces and superclasses) for a class
     * 
     * @author Nicklas Karlsson
     */
-   private class TypeInfo {
+   private class TypeInfo
+   {
       Class<?>[] interfaces;
       Class<?> superclass;
    }
-   
+
    /**
     * Gets the type info for a class
     * 
@@ -100,18 +115,18 @@
     * @param types A set of types (interfaces and superclasses) of a class
     * @return The TypeInfo with categorized information
     */
-   private TypeInfo getTypeInfo(Set<Class<?>> types) 
+   private TypeInfo getTypeInfo(Set<Class<?>> types)
    {
       TypeInfo typeInfo = new TypeInfo();
       List<Class<?>> interfaces = new ArrayList<Class<?>>();
       Class<?> superclass = null;
-      for (Class<?> type : types) 
+      for (Class<?> type : types)
       {
-         if (type.isInterface()) 
+         if (type.isInterface())
          {
             interfaces.add(type);
          }
-         else if (superclass == null || (type != Object.class && superclass.isAssignableFrom(type))) 
+         else if (superclass == null || (type != Object.class && superclass.isAssignableFrom(type)))
          {
             superclass = type;
          }
@@ -121,12 +136,13 @@
       typeInfo.superclass = superclass;
       return typeInfo;
    }
-   
+
    /**
     * Creates a Javassist scope adaptor (client proxy) for a bean
     * 
     * Creates a Javassist proxy factory. Gets the type info. Sets the interfaces
-    * and superclass to the factory. Hooks in the MethodHandler and creates the proxy.
+    * and superclass to the factory. Hooks in the MethodHandler and creates the
+    * proxy.
     * 
     * @param bean The bean to proxy
     * @param beanIndex The index to the bean in the manager bean list
@@ -134,7 +150,8 @@
     * @throws InstantiationException When the proxy couldn't be created
     * @throws IllegalAccessException When the proxy couldn't be created
     */
-   private <T> T createClientProxy(Bean<T> bean, int beanIndex) throws InstantiationException, IllegalAccessException 
+   @SuppressWarnings("unchecked")
+   private <T> T createClientProxy(Bean<T> bean, int beanIndex) throws InstantiationException, IllegalAccessException
    {
       ProxyFactory proxyFactory = new ProxyFactory();
       TypeInfo typeInfo = getTypeInfo(bean.getTypes());
@@ -149,8 +166,9 @@
    /**
     * Gets a client proxy for a bean
     * 
-    * Looks for a proxy in the pool. If not found, one is created and added to the pool
-    *  
+    * Looks for a proxy in the pool. If not found, one is created and added to
+    * the pool
+    * 
     * @param bean
     * @return
     */
@@ -162,8 +180,9 @@
          try
          {
             int beanIndex = manager.getBeans().indexOf(bean);
-            // Implicit add required since it is looked up on activation with then index
-            if (beanIndex < 0) 
+            // Implicit add required since it is looked up on activation with
+            // then index
+            if (beanIndex < 0)
             {
                manager.addBean(bean);
                beanIndex = manager.getBeans().size() - 1;
@@ -179,12 +198,13 @@
       }
       return clientProxy;
    }
-   
+
    @Override
-   public String toString() {
+   public String toString()
+   {
       StringBuffer buffer = new StringBuffer();
-      buffer.append("FIX ME!\n");
+      buffer.append("Proxy pool: " + pool.toString() + "\n");
       return buffer.toString();
-   }   
-   
+   }
+
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbMetaData.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -25,34 +25,30 @@
 
    public enum EjbType
    {
-      STATELESS,
-      STATEFUL,
-      SINGLETON,
-      MESSAGE_DRIVEN;
+      STATELESS, STATEFUL, SINGLETON, MESSAGE_DRIVEN;
    }
-   
+
    private EjbType ejbType;
    private List<AnnotatedMethod<Object>> removeMethods = new ArrayList<AnnotatedMethod<Object>>();
    private List<AnnotatedMethod<Object>> destructorMethods = new ArrayList<AnnotatedMethod<Object>>();
    private List<AnnotatedMethod<Object>> noArgsRemoveMethods = new ArrayList<AnnotatedMethod<Object>>();
-   
+
    // TODO Populate this from web.xml
    private String ejbLinkJndiName;
-   
+
    // TODO Initialize this based on the EJB 3.1 spec
    private String defaultJndiName;
-   
+
    // TODO Initialize the ejb name
    private String ejbName;
-   
+
    private AnnotatedClass<T> type;
-   
 
    public EjbMetaData(Class<T> type)
    {
       this(new AnnotatedClassImpl<T>(type));
    }
-   
+
    public EjbMetaData(AnnotatedClass<T> type)
    {
       // TODO Merge in ejb-jar.xml
@@ -60,7 +56,8 @@
       if (type.isAnnotationPresent(STATELESS_ANNOTATION))
       {
          this.ejbType = STATELESS;
-         // TODO Has to be done here? If they are not parsed, they can't be detected later on (EnterpriseBean remove method init)
+         // TODO Has to be done here? If they are not parsed, they can't be
+         // detected later on (EnterpriseBean remove method init)
          if (type.getAnnotatedMethods(Destructor.class).size() > 0)
          {
             throw new DefinitionException("Stateless enterprise beans cannot have @Destructor methods");
@@ -72,7 +69,8 @@
          for (AnnotatedMethod<Object> removeMethod : type.getAnnotatedMethods(REMOVE_ANNOTATION))
          {
             removeMethods.add(removeMethod);
-            if (removeMethod.getParameters().size() == 0) {
+            if (removeMethod.getParameters().size() == 0)
+            {
                noArgsRemoveMethods.add(removeMethod);
             }
          }
@@ -110,17 +108,17 @@
    {
       return SINGLETON.equals(ejbType);
    }
-   
+
    public boolean isEjb()
    {
       return ejbType != null;
    }
-   
+
    public List<AnnotatedMethod<Object>> getRemoveMethods()
    {
       return removeMethods;
    }
-   
+
    public String getEjbLinkJndiName()
    {
       return ejbLinkJndiName;
@@ -130,12 +128,12 @@
    {
       return defaultJndiName;
    }
-   
+
    public String getEjbName()
    {
       return ejbName;
    }
-   
+
    public Class<T> getType()
    {
       return type.getType();
@@ -151,4 +149,35 @@
       return noArgsRemoveMethods;
    }
 
+   @Override
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("EJB metadata model\n");
+      buffer.append("EJB name: " + ejbName + "\n");
+      buffer.append("EJB type: " + ejbType + "\n");
+      buffer.append("EJB link JNDI name " + ejbLinkJndiName + "\n");
+      buffer.append("Default JNDI name: " + defaultJndiName + "\n");
+      buffer.append("Type: " + type.toString() + "\n");
+      buffer.append("Desctructor methods: " + destructorMethods.size() + "\n");
+      int i = 0;
+      for (AnnotatedMethod<?> method : destructorMethods)
+      {
+         buffer.append(++i + " - " + method.toString());
+      }
+      i = 0;
+      buffer.append("Remove methods: " + removeMethods.size() + "\n");
+      for (AnnotatedMethod<?> method : removeMethods)
+      {
+         buffer.append(++i + " - " + method.toString());
+      }
+      i = 0;
+      buffer.append("No-args remove methods: " + noArgsRemoveMethods.size() + "\n");
+      for (AnnotatedMethod<?> method : noArgsRemoveMethods)
+      {
+         buffer.append(++i + " - " + method.toString());
+      }
+      return buffer.toString();
+   }
+
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -189,6 +189,7 @@
    public String toString()
    {
       StringBuffer buffer = new StringBuffer();
+      buffer.append("Event manager\n");
       buffer.append("Registered observers: " + registeredObservers.size() + "\n");
       for (Entry<Class<?>, CopyOnWriteArrayList<EventObserver<?>>> entry : registeredObservers.entrySet())
       {

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/BindingTypeModel.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -108,4 +108,18 @@
       return false;
    }
    
+   @Override
+   public String toString() {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("Binding type model\n");
+      buffer.append("Hash code : " + hashCode() + "\n");
+      buffer.append("Valid : " + isValid() + "\n");
+      buffer.append("Non-binding types\n");
+      for (AnnotatedMethod<?> method : nonBindingTypes) {
+         method.toString();
+      }
+      buffer.append("Annotated type " + getAnnotatedAnnotation().getName());
+      return buffer.toString();
+   }
+   
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/ScopeModel.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -53,4 +53,13 @@
       return ScopeType.class;
    }
    
+   @Override
+   public String toString() {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("Scope model\n");
+      buffer.append("Valid : " + isValid() + "\n");
+      buffer.append("Annotated type " + getAnnotatedAnnotation().toString());
+      return buffer.toString();
+   }
+   
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java	2008-11-21 07:15:32 UTC (rev 347)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Reflections.java	2008-11-21 10:16:45 UTC (rev 348)
@@ -12,6 +12,7 @@
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -308,6 +309,21 @@
    public static boolean isProxy(Object instance) 
    {
       return instance.getClass().getName().indexOf("_$$_javassist_") > 0;
+   }
+   
+   public static Set<Class<?>> getTypeHierachy(Class<?> clazz)
+   {
+      Set<Class<?>> classes = new HashSet<Class<?>>();
+      if (clazz != null)
+      {
+         classes.add(clazz);
+         classes.addAll(getTypeHierachy(clazz.getSuperclass()));
+         for (Class<?> c : clazz.getInterfaces())
+         {
+            classes.addAll(getTypeHierachy(c));
+         }
+      }
+      return classes;
    }   
    
 }




More information about the weld-commits mailing list