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

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Mon Dec 8 05:24:07 EST 2008


Author: nickarls
Date: 2008-12-08 05:24:07 -0500 (Mon, 08 Dec 2008)
New Revision: 469

Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/InstanceImpl.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/EventBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/FacadeBean.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/InstanceBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ManagerBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.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/event/EventImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
Log:
docs + toStrings

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-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/InstanceImpl.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -59,6 +59,9 @@
       return buffer.toString();
    }
 
+   /**
+    * @see org.jboss.webbeans.FacadeImpl#getFilteredAnnotations
+    */
    @Override
    protected Set<Class<? extends Annotation>> getFilteredAnnotations()
    {

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-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractBean.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -101,7 +101,7 @@
    protected Set<AnnotatedItem<?, ?>> injectionPoints;
 
    private boolean primitive;
-   
+
    protected ManagerImpl manager;
 
    // Cached values
@@ -169,7 +169,6 @@
    /**
     * Initializes the deployment types
     */
-   @SuppressWarnings("null")
    protected void initDeploymentType()
    {
       Set<Annotation> deploymentTypes = getAnnotatedItem().getMetaAnnotations(DeploymentType.class);
@@ -196,7 +195,7 @@
       log.trace("Using default @Production deployment type");
       return;
    }
-   
+
    protected abstract Class<? extends Annotation> getDefaultDeploymentType();
 
    /**
@@ -265,7 +264,6 @@
    /**
     * Initializes the scope type
     */
-   @SuppressWarnings("null")
    protected void initScopeType()
    {
       if (getAnnotatedItem().getMetaAnnotations(ScopeType.class).size() > 1)
@@ -539,9 +537,19 @@
       return false;
    }
 
+   /**
+    * Returns a string representation
+    * 
+    * @return The string representation
+    */
    @Override
    public String toString()
    {
+      return "AbstractBean " + getName();
+   }
+
+   public String toDetailedString()
+   {
       StringBuilder buffer = new StringBuilder();
       buffer.append("AbstractBean:\n");
       buffer.append("Name: " + name + "\n");

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-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -112,7 +112,7 @@
    {
       return getAnnotatedItem().getAnnotatedFields(Produces.class);
    }
-   
+
    public Set<AnnotatedMethod<Object>> getObserverMethods()
    {
       return getAnnotatedItem().getMethodsWithAnnotatedParameters(Observes.class);
@@ -128,19 +128,19 @@
       injectableFields = new HashSet<AnnotatedField<Object>>();
       for (AnnotatedField<Object> annotatedField : annotatedItem.getMetaAnnotatedFields(BindingType.class))
       {
-         if ( !annotatedField.isAnnotationPresent(Produces.class) )
+         if (!annotatedField.isAnnotationPresent(Produces.class))
          {
-         if (annotatedField.isStatic())
-         {
-            throw new DefinitionException("Don't place binding annotations on static fields " + annotatedField);
+            if (annotatedField.isStatic())
+            {
+               throw new DefinitionException("Don't place binding annotations on static fields " + annotatedField);
+            }
+            if (annotatedField.isFinal())
+            {
+               throw new DefinitionException("Don't place binding annotations on final fields " + annotatedField);
+            }
+            injectableFields.add(annotatedField);
+            super.injectionPoints.add(annotatedField);
          }
-         if (annotatedField.isFinal())
-         {
-            throw new DefinitionException("Don't place binding annotations on final fields " + annotatedField);
-         }
-         injectableFields.add(annotatedField);
-         super.injectionPoints.add(annotatedField);
-         }
       }
    }
 
@@ -265,9 +265,19 @@
       return initializerMethods;
    }
 
+   /**
+    * Returns a string representation
+    * 
+    * @return The string representation
+    */
    @Override
    public String toString()
    {
+      return "AbstractClassBean " + getName();
+   }
+
+   public String toDetailedString()
+   {
       StringBuilder buffer = new StringBuilder();
       buffer.append("AbstractClassBean:\n");
       buffer.append(super.toString() + "\n");
@@ -277,7 +287,7 @@
       buffer.append(Strings.collectionToString("Producer methods: ", getProducerMethods()));
       return buffer.toString();
    }
-   
+
    @Override
    protected Class<? extends Annotation> getDefaultDeploymentType()
    {

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-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -23,6 +23,7 @@
 import org.jboss.webbeans.ManagerImpl;
 import org.jboss.webbeans.event.EventImpl;
 import org.jboss.webbeans.introspector.AnnotatedItem;
+import org.jboss.webbeans.util.Names;
 
 /**
  * An event bean representation
@@ -39,17 +40,38 @@
     * 
     * @param field The underlying field abstraction
     */
-   @SuppressWarnings("unchecked")
    public EventBean(AnnotatedItem<Event<T>, S> field, ManagerImpl manager)
    {
       super(field, manager);
    }
 
-   @SuppressWarnings("unchecked")
    @Override
    public Event<T> create()
    {
       return new EventImpl<T>(manager, getTypeParameter(), getBindingTypesArray());
    }
+   
+   /**
+    * Returns a string representation
+    * 
+    * @return The string representation
+    */
+   @Override
+   public String toString()
+   {
+      StringBuilder buffer = new StringBuilder();
+      buffer.append("Annotated " + Names.scopeTypeToString(getScopeType()));
+      if (getName() == null)
+      {
+         buffer.append(" unnamed event bean");
+      }
+      else
+      {
+         buffer.append(" enterprise bean '" + getName() + "'");
+      }
+      buffer.append(" [" + getType().getName() + "]\n");
+      buffer.append("   API types " + getTypes() + ", binding types " + getBindingTypes() + "\n");
+      return buffer.toString();
+   } 
 
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/FacadeBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/FacadeBean.java	2008-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/FacadeBean.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -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;
@@ -11,6 +28,15 @@
 import org.jboss.webbeans.ManagerImpl;
 import org.jboss.webbeans.introspector.AnnotatedItem;
 
+/**
+ * Facade bean for implicit beans
+ * 
+ * @author Gavin King
+ *
+ * @param <T>
+ * @param <S>
+ * @param <P>
+ */
 public abstract class FacadeBean<T, S, P> extends AbstractBean<T, S> {
 
    protected AnnotatedItem<T, S> annotatedItem;
@@ -50,6 +76,7 @@
       return annotatedItem.getBindingTypesAsArray();
    }
 
+   @SuppressWarnings("unchecked")
    protected Class<P> getTypeParameter() {
       return (Class<P>) annotatedItem.getType().getTypeParameters()[0].getClass();
    }
@@ -94,5 +121,16 @@
    protected Class<? extends Annotation> getDefaultDeploymentType() {
       return Production.class;
    }
+   
+   /**
+    * Returns a string representation
+    * 
+    * @return The string representation
+    */
+   @Override
+   public String toString()
+   {
+      return "FacadeBean " + getName();
+   }   
 
 }
\ No newline at end of file

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-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ForwardingBean.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -93,12 +93,6 @@
    }
    
    @Override
-   public String toString()
-   {
-      return delegate().toString();
-   }
-   
-   @Override
    public int hashCode()
    {
       return delegate().hashCode();
@@ -111,5 +105,16 @@
    }
    
    protected abstract Bean<T> delegate();
+
+   /**
+    * Returns a string representation
+    * 
+    * @return The string representation
+    */
+   @Override
+   public String toString()
+   {
+      return "ForwardingBean " + getName();
+   }   
    
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InstanceBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InstanceBean.java	2008-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/InstanceBean.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -25,11 +25,12 @@
 import org.jboss.webbeans.introspector.AnnotatedItem;
 
 /**
- * An event bean representation
+ * Helper bean for accessing instances
  * 
- * @author David Allen
- * 
+ * @author Gavin King
+ *
  * @param <T>
+ * @param <S>
  */
 public class InstanceBean<T, S> extends FacadeBean<Instance<T>, S, T>
 {
@@ -37,15 +38,19 @@
    /**
     * Constructor
     * 
-    * @param field The underlying field abstraction
+    * @param field The underlying fields
+    * @param manager The Web Beans manager
     */
-   @SuppressWarnings("unchecked")
    public InstanceBean(AnnotatedItem<Instance<T>, S> field, ManagerImpl manager)
    {
       super(field, manager);
    }
 
-   @SuppressWarnings("unchecked")
+   /**
+    * Creates the implementing bean
+    * 
+    * @return The implementation
+    */
    @Override
    public Instance<T> create()
    {

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ManagerBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ManagerBean.java	2008-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ManagerBean.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -1,6 +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;
@@ -16,6 +30,12 @@
 import org.jboss.webbeans.bindings.CurrentAnnotationLiteral;
 import org.jboss.webbeans.util.Reflections;
 
+/**
+ * Helper bean for accessing the Manager
+ * 
+ * @author Gavin King
+ *
+ */
 public class ManagerBean extends Bean<Manager>
 {
    

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerBean.java	2008-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerBean.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -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;
@@ -11,6 +28,13 @@
 import org.jboss.webbeans.ManagerImpl;
 import org.jboss.webbeans.util.Names;
 
+/**
+ * 
+ * @author Gavin King
+ *
+ * @param <T>
+ * @param <S>
+ */
 public abstract class ProducerBean<T, S> extends AbstractBean<T, S> {
 
    protected AbstractClassBean<?> declaringBean;

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java	2008-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -25,7 +25,7 @@
 import org.jboss.webbeans.util.Names;
 
 /**
- * Represents a producer method bean
+ * Represents a producer field bean
  * 
  * @author Pete Muir
  *
@@ -39,7 +39,7 @@
    /**
     * Constructor
     * 
-    * @param method The producer method
+    * @param method The producer field
     * @param declaringBean The declaring bean instance
     */
    public ProducerFieldBean(Field field, AbstractClassBean<?> declaringBean, ManagerImpl manager)
@@ -50,7 +50,7 @@
    /**
     * Constructor
     * 
-    * @param method The producer method abstraction
+    * @param method The producer field abstraction
     * @param declaringBean The declaring bean
     */
    public ProducerFieldBean(AnnotatedField<T> field, AbstractClassBean<?> declaringBean, ManagerImpl manager)
@@ -74,7 +74,7 @@
    }
 
    /**
-    * Gets the annotated item representing the method
+    * Gets the annotated item representing the field
     * 
     * @return The annotated item
     */

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-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyMethodHandler.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -84,9 +84,8 @@
    public String toString()
    {
       StringBuilder buffer = new StringBuilder();
-      buffer.append("Proxy method handler\n");
-      buffer.append("Bean " + (bean == null ? "null" : bean.toString()) + "\n");
-      buffer.append("Bean index: " + beanIndex + "\n");
+      String beanInfo = bean == null ? "null bean" : bean.toString();
+      buffer.append("Proxy method handler for " + beanInfo + " with index " + beanIndex);
       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-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -165,10 +165,7 @@
    @Override
    public String toString()
    {
-      StringBuilder buffer = new StringBuilder();
-      buffer.append("Proxy pool\n");
-      buffer.append(pool.toString() + "\n");
-      return buffer.toString();
+      return "Proxy pool with " + pool.size() + " proxies";
    }
 
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java	2008-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -42,7 +42,7 @@
 {
    @SuppressWarnings("unchecked")
    private static final Set<Class<? extends Annotation>> FILTERED_ANNOTATIONS = new HashSet<Class<? extends Annotation>>(Arrays.asList(Observable.class));
-   
+
    /**
     * Constructor
     * 
@@ -80,11 +80,14 @@
    {
       StringBuilder buffer = new StringBuilder();
       buffer.append("Observable Event:\n");
-      buffer.append("  Event Type: " + type.getName() +"\n");
+      buffer.append("  Event Type: " + type.getName() + "\n");
       buffer.append(Strings.collectionToString("  Event Bindings: ", bindingTypes));
       return buffer.toString();
    }
 
+   /**
+    * @see org.jboss.webbeans.FacadeImpl#getFilteredAnnotations
+    */
    @Override
    protected Set<Class<? extends Annotation>> getFilteredAnnotations()
    {

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java	2008-12-08 10:01:58 UTC (rev 468)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/ObserverImpl.java	2008-12-08 10:24:07 UTC (rev 469)
@@ -59,7 +59,7 @@
  */
 public class ObserverImpl<T> implements Observer<T>
 {
-   private Bean<?> observerBean;
+   private Bean<?> eventBean;
    private final AnnotatedMethod<Object> observerMethod;
    private TransactionObservationPhase transactionObservationPhase;
    private boolean conditional;
@@ -81,7 +81,7 @@
    public ObserverImpl(final AnnotatedMethod<Object> observer, final Bean<?> observerBean, final ManagerImpl manager)
    {
       this.manager = manager;
-      this.observerBean = observerBean;
+      this.eventBean = observerBean;
       this.observerMethod = observer;
       validateObserverMethod();
       initTransactionObservationPhase();
@@ -187,7 +187,7 @@
    protected Object getInstance(boolean conditional)
    {
       // Return the most specialized instance of the component
-      return manager.getMostSpecializedInstance(observerBean, conditional);
+      return manager.getMostSpecializedInstance(eventBean, conditional);
    }
 
    /**
@@ -226,7 +226,7 @@
    {
       StringBuilder builder = new StringBuilder();
       builder.append("Observer Implentation: \n");
-      builder.append("  Observer (Declaring) bean: " + observerBean);
+      builder.append("  Observer (Declaring) bean: " + eventBean);
       builder.append("  Observer method: " + observerMethod);
       return builder.toString();
    }




More information about the weld-commits mailing list