You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2010/02/06 10:51:04 UTC

svn commit: r907200 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/AbstractBean.java util/WebBeansUtil.java

Author: struberg
Date: Sat Feb  6 09:51:03 2010
New Revision: 907200

URL: http://svn.apache.org/viewvc?rev=907200&view=rev
Log:
OWB-6 don't create uniqueId for Beans with returnType==Object

@Typed() is used often to disable beans, thus those beans would often not be unique.
Also did some JavaDoc and code cleanup.

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java?rev=907200&r1=907199&r2=907200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java Sat Feb  6 09:51:03 2010
@@ -151,7 +151,7 @@
     @SuppressWarnings("unchecked")
     public T create(CreationalContext<T> creationalContext)
     {
-        T instance = null;
+        T instance;
         try
         {  
             if(!(creationalContext instanceof CreationalContextImpl))
@@ -165,17 +165,11 @@
         {
             Throwable throwable = ClassUtil.getRootException(re);
             
-            if(throwable instanceof RuntimeException)
-            {
-                RuntimeException rt = (RuntimeException)throwable;
-                
-                throw rt;
-            }
-            else
+            if(!(throwable instanceof RuntimeException))
             {
                 throw new CreationException(throwable);
             }
-            
+            throw (RuntimeException) throwable;
         }
 
         return instance;
@@ -184,13 +178,15 @@
     /**
      * Creates the instance of the bean that has a specific implementation
      * type. Each subclass must define its own create mechanism.
-     * 
+     *
+     * @param creationalContext the contextual instance shall be created in
      * @return instance of the bean
      */
     protected abstract T createInstance(CreationalContext<T> creationalContext);
 
     /*
      * (non-Javadoc)
+     * @param creationalContext the contextual instance has been created in
      * @see javax.webbeans.bean.Component#destroy(java.lang.Object)
      */
     public void destroy(T instance, CreationalContext<T> creationalContext)
@@ -215,6 +211,7 @@
      * destroy mechanism.
      * 
      * @param instance instance of the bean that is being destroyed
+     * @param creationalContext the contextual instance has been created in
      */
     protected void destroyInstance(T instance, CreationalContext<T> creationalContext)
     {
@@ -222,11 +219,17 @@
     }
     
     /**
+     * TODO there are probably other infos which must get added to make the id unique!
+     * If not, it will crash in {@link BeanManagerImpl#addPassivationCapableBean(javax.enterprise.inject.spi.Bean)}
+     * anyway. 
+     *
      * {@inheritDoc}
      */
     public String getId()
     {
-        if (!isEnabled()) {
+        if (!isEnabled() || returnType.equals(Object.class)) {
+            // if the Bean is disabled, either by rule, or by
+            // annotating it @Typed() as Object, then it is not serializable
             return null;
         }
         
@@ -237,8 +240,6 @@
             sb.append(qualifier.toString()).append(',');
         }
 
-        //X TODO there are most probably other infos which must get added to make the id unique! 
-
         return sb.toString();
     }
     
@@ -571,7 +572,7 @@
     public String toString()
     {
         StringBuilder builder = new StringBuilder();        
-        builder.append("Name:"+ getName() +",WebBeans Type:"+ getWebBeansType());
+        builder.append("Name:").append(getName()).append(",WebBeans Type:").append(getWebBeansType());
         builder.append(",API Types:[");
         
         int size = getTypes().size();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=907200&r1=907199&r2=907200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java Sat Feb  6 09:51:03 2010
@@ -2328,7 +2328,12 @@
             stack.clear();
         }        
     }
-    
+
+    /**
+     *
+     * @param contextual the {@link Bean} to check
+     * @return the uniqueId if it is passivationcapable and enabled
+     */
     public static String isPassivationCapable(Contextual<?> contextual)
     {
         if(contextual instanceof Bean)