Author: struberg
Date: Sat Apr 14 20:26:59 2018
New Revision: 1829168

URL: http://svn.apache.org/viewvc?rev=1829168&view=rev
Log:
OWB-1218 improve toString of producers

backported from OWB-2.0.x

Modified:
    openwebbeans/branches/owb_1.7.x/   (props changed)
    
openwebbeans/branches/owb_1.7.x/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
    
openwebbeans/branches/owb_1.7.x/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java

Propchange: openwebbeans/branches/owb_1.7.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Apr 14 20:26:59 2018
@@ -1,2 +1,2 @@
 /openwebbeans/branches/owb_1.2.x:1640945,1641609,1641684
-/openwebbeans/trunk:1803385,1805243,1806330
+/openwebbeans/trunk:1803385,1805243,1806330,1813058

Modified: 
openwebbeans/branches/owb_1.7.x/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.7.x/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java?rev=1829168&r1=1829167&r2=1829168&view=diff
==============================================================================
--- 
openwebbeans/branches/owb_1.7.x/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
 (original)
+++ 
openwebbeans/branches/owb_1.7.x/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
 Sat Apr 14 20:26:59 2018
@@ -389,11 +389,22 @@ public abstract class AbstractOwbBean<T>
         }
         
         builder.append("]");
+
+        addToStringInfo(builder);
         
         return builder.toString();
     }
 
     /**
+     * This method can be used to add additional info about the Bean
+     * @param builder
+     */
+    protected void addToStringInfo(StringBuilder builder)
+    {
+        // by default we do nothing
+    }
+
+    /**
      * The Logger should really only be used to log errors!
      */
     protected synchronized Logger getLogger()

Modified: 
openwebbeans/branches/owb_1.7.x/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.7.x/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java?rev=1829168&r1=1829167&r2=1829168&view=diff
==============================================================================
--- 
openwebbeans/branches/owb_1.7.x/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
 (original)
+++ 
openwebbeans/branches/owb_1.7.x/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
 Sat Apr 14 20:26:59 2018
@@ -54,8 +54,8 @@ public class AbstractProducerBean<T> ext
     {
         super(ownerComponent.webBeansContext, webBeansType, beanAttributes, 
ownerComponent.getBeanClass(), !returnType.isPrimitive());
         this.returnType = returnType;
-        producer = producerFactory.createProducer(this);
         this.ownerComponent = ownerComponent;
+        producer = producerFactory.createProducer(this);
     }
 
     @Override
@@ -113,4 +113,15 @@ public class AbstractProducerBean<T> ext
 
         return true;
     }
+
+    /**
+     * For producer beans we add the info about the owner component
+     */
+    @Override
+    protected void addToStringInfo(StringBuilder builder)
+    {
+        Class<?> returnType = ownerComponent.getBeanClass();
+        builder.append(", OwnerBean Class: ")
+            .append(returnType != null ? returnType.getName() : "null");
+    }
 }


Reply via email to