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 2013/01/20 12:24:31 UTC

svn commit: r1435822 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/AbstractOwbBean.java container/BeanManagerImpl.java context/creational/CreationalContextFactory.java context/creational/WrappedCreationalContext.java

Author: struberg
Date: Sun Jan 20 11:24:30 2013
New Revision: 1435822

URL: http://svn.apache.org/viewvc?rev=1435822&view=rev
Log:
OWB-735 re-apply CreationalContextWrapper. Needed by TCK

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/WrappedCreationalContext.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextFactory.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java?rev=1435822&r1=1435821&r2=1435822&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java Sun Jan 20 11:24:30 2013
@@ -40,6 +40,7 @@ import javax.enterprise.inject.spi.Produ
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 
@@ -150,6 +151,11 @@ public abstract class AbstractOwbBean<T>
     {
         try
         {
+            if(!(creationalContext instanceof CreationalContextImpl))
+            {
+                creationalContext = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(creationalContext, this);
+            }
+
             T instance = producer.produce(creationalContext);
             if (producer instanceof InjectionTarget)
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1435822&r1=1435821&r2=1435822&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java Sun Jan 20 11:24:30 2013
@@ -674,7 +674,14 @@ public class BeanManagerImpl implements 
         {
             bean = ((SerializableBean)bean).getBean();
         }
-        
+
+        if(!(creationalContext instanceof CreationalContextImpl))
+        {
+            creationalContext = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(creationalContext, bean);
+        }
+
+
+
         //Check type if bean type is given
         if(beanType != null)
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextFactory.java?rev=1435822&r1=1435821&r2=1435822&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextFactory.java Sun Jan 20 11:24:30 2013
@@ -53,5 +53,10 @@ public final class CreationalContextFact
     {        
         return new CreationalContextImpl<T>(contextual, webBeansContext);
     }        
-
+    
+    public CreationalContext<T> wrappedCreationalContext(CreationalContext<T> creationalContext, Contextual<T> contextual)
+    {
+        return new WrappedCreationalContext<T>(contextual, creationalContext, webBeansContext);
+    }
+    
 }

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/WrappedCreationalContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/WrappedCreationalContext.java?rev=1435822&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/WrappedCreationalContext.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/WrappedCreationalContext.java Sun Jan 20 11:24:30 2013
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.context.creational;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.apache.webbeans.config.WebBeansContext;
+
+class WrappedCreationalContext<T> extends CreationalContextImpl<T> implements CreationalContext<T>
+{
+    private static final long serialVersionUID = 3580925478881669439L;
+    
+    private CreationalContext<T> wrapped = null;    
+
+    WrappedCreationalContext(Contextual<T> contextual, CreationalContext<T> creationalContext,
+                             WebBeansContext webBeansContext)
+    {
+        super(contextual, webBeansContext);
+        wrapped = creationalContext;
+    }
+
+    @Override
+    public void push(T instance)
+    {
+        super.push(instance);
+        wrapped.push(instance);
+    }
+
+    @Override
+    public void release()
+    {
+        super.release();
+        wrapped.release();
+    }
+    
+}