openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bergm...@apache.org
Subject svn commit: r986138 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: context/creational/CreationalContextImpl.java decorator/WebBeansDecoratorConfig.java
Date Mon, 16 Aug 2010 22:02:17 GMT
Author: bergmark
Date: Mon Aug 16 22:02:17 2010
New Revision: 986138

URL: http://svn.apache.org/viewvc?rev=986138&view=rev
Log:
[OWB-440] Ensure that Decorators get reused if they already exist inside of the DependentCreationalContext.

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java?rev=986138&r1=986137&r2=986138&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
Mon Aug 16 22:02:17 2010
@@ -203,10 +203,10 @@ public class CreationalContextImpl<T> im
      * @param decorator decorator bean
      * @return bean decorator instance
      */
-    public Object getDependentDecorator(Contextual<?> decorator)
+    public Object getDependentDecorator(Object ownerInstance, Contextual<?> decorator)
     {
         Asserts.assertNotNull(decorator, "Decorator parameter can not be null");
-        List<DependentCreationalContext<?>> dcs = getDependentDecorators();
+        List<DependentCreationalContext<?>> dcs = getDependentDecorators(ownerInstance);
         for(DependentCreationalContext<?> dc : dcs)
         {
             if(dc.getContextual().equals(decorator))
@@ -250,19 +250,23 @@ public class CreationalContextImpl<T> im
      * Gets list of dependent decorators context.
      * @return list of dependent decorators context
      */
-    private List<DependentCreationalContext<?>> getDependentDecorators()
+    private List<DependentCreationalContext<?>> getDependentDecorators(Object
ownerInstance)
     {
         List<DependentCreationalContext<?>> list = new ArrayList<DependentCreationalContext<?>>();
-        List<DependentCreationalContext<?>> values = new ArrayList<DependentCreationalContext<?>>();
-        if(values != null && values.size() > 0)
+
+        if (ownerInstance != null)
         {
-            Iterator<DependentCreationalContext<?>> it = values.iterator();
-            while(it.hasNext())
+            List<DependentCreationalContext<?>> values = this.dependentObjects.get(ownerInstance);
+            if (values != null && values.size() > 0)
             {
-                DependentCreationalContext<?> dc = it.next();
-                if(dc.getDependentType().equals(DependentType.DECORATOR))
+                Iterator<DependentCreationalContext<?>> it = values.iterator();
+                while (it.hasNext())
                 {
-                    list.add(dc);
+                    DependentCreationalContext<?> dc = it.next();
+                    if (dc.getDependentType().equals(DependentType.DECORATOR))
+                    {
+                        list.add(dc);
+                    }
                 }
             }
         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java?rev=986138&r1=986137&r2=986138&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
Mon Aug 16 22:02:17 2010
@@ -123,7 +123,7 @@ public final class WebBeansDecoratorConf
             Object decoratorInstance = null;
             @SuppressWarnings("unchecked")
             WebBeansDecorator<Object> decorator = (WebBeansDecorator<Object>)
itList.next();            
-            decoratorInstance = ownerCreationalContext.getDependentDecorator(decorator);
+            decoratorInstance = ownerCreationalContext.getDependentDecorator(instance, decorator);
             if(decoratorInstance == null)
             {
                 CreationalContext<Object> creationalContext = manager.createCreationalContext(decorator);
@@ -137,6 +137,11 @@ public final class WebBeansDecoratorConf
                     ownerCreationalContext.addDependent(instance, decorator, decoratorInstance);
                 }                
             }
+            //We found an existing decorator instance, update the delegate
+            else
+            {
+                decorator.setDelegate(decoratorInstance, delegate);
+            }
             
             decoratorStack.add(decoratorInstance);
         }



Mime
View raw message