Return-Path: X-Original-To: apmail-openwebbeans-commits-archive@www.apache.org Delivered-To: apmail-openwebbeans-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9FB5FF93C for ; Sat, 6 Apr 2013 19:55:43 +0000 (UTC) Received: (qmail 16448 invoked by uid 500); 6 Apr 2013 19:55:43 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 16420 invoked by uid 500); 6 Apr 2013 19:55:43 -0000 Mailing-List: contact commits-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwebbeans.apache.org Delivered-To: mailing list commits@openwebbeans.apache.org Received: (qmail 16412 invoked by uid 99); 6 Apr 2013 19:55:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Apr 2013 19:55:43 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Apr 2013 19:55:41 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C88EA23889BB; Sat, 6 Apr 2013 19:55:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1465293 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: container/ context/creational/ event/ inject/ portable/ Date: Sat, 06 Apr 2013 19:55:21 -0000 To: commits@openwebbeans.apache.org From: arne@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130406195521.C88EA23889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: arne Date: Sat Apr 6 19:55:20 2013 New Revision: 1465293 URL: http://svn.apache.org/r1465293 Log: OWB-766: Removed public static ThreadLocal Modified: 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 openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventProducer.java 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=1465293&r1=1465292&r2=1465293&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 Sat Apr 6 19:55:20 2013 @@ -543,7 +543,7 @@ public class BeanManagerImpl implements /** * {@inheritDoc} */ - public CreationalContext createCreationalContext(Contextual contextual) + public CreationalContextImpl createCreationalContext(Contextual contextual) { if (contextual instanceof SerializableBean) { 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=1465293&r1=1465292&r2=1465293&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 Sat Apr 6 19:55:20 2013 @@ -49,7 +49,7 @@ public final class CreationalContextFact * @param contextual contextual instance * @return new creational context for given contextual */ - public CreationalContext getCreationalContext(Contextual contextual) + public CreationalContextImpl getCreationalContext(Contextual contextual) { return new CreationalContextImpl(contextual, webBeansContext); } 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=1465293&r1=1465292&r2=1465293&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 Sat Apr 6 19:55:20 2013 @@ -24,10 +24,12 @@ import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import java.util.Stack; import javax.enterprise.context.spi.Contextual; import javax.enterprise.context.spi.CreationalContext; import javax.enterprise.inject.spi.Bean; +import javax.enterprise.inject.spi.InjectionPoint; import org.apache.webbeans.config.WebBeansContext; import org.apache.webbeans.exception.WebBeansException; @@ -44,6 +46,11 @@ public class CreationalContextImpl im * The delegate object to be injected into delegate injection points */ private transient T delegate; + + /** + * The injection point object to be injected into injection points of type InjectionPoint + */ + private transient Stack injectionPoints; /** * Contextual bean dependent instances @@ -92,6 +99,33 @@ public class CreationalContextImpl im return oldValue; } + public InjectionPoint getInjectionPoint() + { + if (injectionPoints == null || injectionPoints.isEmpty()) + { + return null; + } + return injectionPoints.peek(); + } + + public void putInjectionPoint(InjectionPoint injectionPoint) + { + if (injectionPoints == null) + { + injectionPoints = new Stack(); + } + injectionPoints.push(injectionPoint); + } + + public InjectionPoint removeInjectionPoint() + { + if (injectionPoints == null || injectionPoints.isEmpty()) + { + return null; + } + return injectionPoints.pop(); + } + /** * Save this incomplete instance. * @@ -200,7 +234,6 @@ public class CreationalContextImpl im return contextual; } - /** * Write Object. */ Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java?rev=1465293&r1=1465292&r2=1465293&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java Sat Apr 6 19:55:20 2013 @@ -53,11 +53,11 @@ import org.apache.webbeans.component.Web 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.WebBeansException; import org.apache.webbeans.inject.impl.InjectionPointFactory; import org.apache.webbeans.logger.WebBeansLoggerFacade; import org.apache.webbeans.portable.AnnotatedElementFactory; -import org.apache.webbeans.portable.EventProducer; import org.apache.webbeans.portable.InjectionPointProducer; import org.apache.webbeans.proxy.OwbNormalScopeProxy; import org.apache.webbeans.util.AnnotationUtil; @@ -404,12 +404,11 @@ public class ObserverMethodImpl imple } } + CreationalContextImpl creational = manager.createCreationalContext(injectedBean); if (isEventProviderInjection(point)) { - EventProducer.local.set(point); + creational.putInjectionPoint(point); } - - CreationalContext creational = manager.createCreationalContext(injectedBean); Object instance = manager.getReference(injectedBean, null, creational); if (injectionPointBeanLocalSetOnStack) { @@ -476,12 +475,12 @@ public class ObserverMethodImpl imple } } + + CreationalContextImpl creational = manager.createCreationalContext(injectedBean); if (isEventProviderInjection(point)) { - EventProducer.local.set(point); + creational.putInjectionPoint(point); } - - CreationalContext creational = manager.createCreationalContext(injectedBean); Object instance = manager.getReference(injectedBean, null, creational); if (injectionPointBeanLocalSetOnStack) Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java?rev=1465293&r1=1465292&r2=1465293&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java Sat Apr 6 19:55:20 2013 @@ -39,7 +39,6 @@ import org.apache.webbeans.config.WebBea import org.apache.webbeans.container.BeanManagerImpl; import org.apache.webbeans.container.InjectionResolver; import org.apache.webbeans.context.creational.CreationalContextImpl; -import org.apache.webbeans.portable.EventProducer; import org.apache.webbeans.portable.InjectionPointProducer; import org.apache.webbeans.portable.InstanceProducer; import org.apache.webbeans.util.ClassUtil; @@ -90,7 +89,7 @@ public abstract class AbstractInjectable else if(isEventProviderInjection(injectionPoint)) { - EventProducer.local.set(injectionPoint); + creationalContext.putInjectionPoint(injectionPoint); } boolean injectionPointBeanLocalSetOnStack = false; Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventProducer.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventProducer.java?rev=1465293&r1=1465292&r2=1465293&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventProducer.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventProducer.java Sat Apr 6 19:55:20 2013 @@ -27,14 +27,13 @@ import javax.enterprise.event.Event; import javax.enterprise.inject.spi.InjectionPoint; import org.apache.webbeans.config.WebBeansContext; +import org.apache.webbeans.context.creational.CreationalContextImpl; import org.apache.webbeans.event.EventImpl; import org.apache.webbeans.exception.WebBeansException; public class EventProducer extends AbstractProducer> { - //X TODO refactor. public static variables are utterly ugly - public static ThreadLocal local = new ThreadLocal(); private WebBeansContext webBeansContext; public EventProducer(WebBeansContext webBeansContext) @@ -49,8 +48,13 @@ public class EventProducer extends Ab public Event produce(CreationalContext> creationalContext) { Event instance = null; + InjectionPoint injectionPoint = null; + //TODO What should we do here if creationalContext is not instanceof CreationalContextImpl? + if (creationalContext instanceof CreationalContextImpl) + { + injectionPoint = ((CreationalContextImpl>)creationalContext).getInjectionPoint(); + } - InjectionPoint injectionPoint = local.get(); Type eventType; if(injectionPoint != null) @@ -79,8 +83,10 @@ public class EventProducer extends Ab } finally { - local.set(null); - local.remove(); + if (creationalContext instanceof CreationalContextImpl) + { + ((CreationalContextImpl>)creationalContext).removeInjectionPoint(); + } } }