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 56AAC179C3 for ; Tue, 28 Apr 2015 20:03:18 +0000 (UTC) Received: (qmail 71773 invoked by uid 500); 28 Apr 2015 20:03:18 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 71744 invoked by uid 500); 28 Apr 2015 20:03:18 -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 71733 invoked by uid 99); 28 Apr 2015 20:03:18 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Apr 2015 20:03:18 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 1A4A1AC0623 for ; Tue, 28 Apr 2015 20:03:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1676604 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: corespi/se/DefaultContextsService.java lifecycle/AbstractLifeCycle.java Date: Tue, 28 Apr 2015 20:03:17 -0000 To: commits@openwebbeans.apache.org From: rsandtner@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150428200318.1A4A1AC0623@hades.apache.org> Author: rsandtner Date: Tue Apr 28 20:03:17 2015 New Revision: 1676604 URL: http://svn.apache.org/r1676604 Log: OWB-1061 start applicationContext only once, don't start applicationContext on shutdown Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java?rev=1676604&r1=1676603&r2=1676604&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java Tue Apr 28 20:03:17 2015 @@ -209,20 +209,43 @@ public class DefaultContextsService exte @Override public void destroy(Object destroyObject) { - requestContext.set(null); - sessionContext.set(null); - conversationContext.set(null); + RequestContext requestCtx = requestContext.get(); + if (requestCtx != null) + { + requestCtx.destroy(); + requestContext.set(null); + requestContext.remove(); + } + + SessionContext sessionCtx = sessionContext.get(); + if (sessionCtx != null) + { + sessionCtx.destroy(); + sessionContext.set(null); + sessionContext.remove(); + } + + ConversationContext conversationCtx = conversationContext.get(); + if (conversationCtx != null) + { + conversationCtx.destroy(); + conversationContext.set(null); + conversationContext.remove(); + } + + SingletonContext singletonCtx = singletonContext.get(); + if (singletonCtx != null) + { + singletonCtx.destroy(); + singletonContext.set(null); + singletonContext.remove(); + } + dependentContext.set(null); - singletonContext.set(null); - - requestContext.remove(); - sessionContext.remove(); - conversationContext.remove(); dependentContext.remove(); - singletonContext.remove(); } - - + + private Context getCurrentApplicationContext() { return applicationContext; @@ -266,9 +289,15 @@ public class DefaultContextsService exte private void startApplicationContext(Object instance) { + if (applicationContext != null) + { + // applicationContext is already started + return; + } + ApplicationContext ctx = new ApplicationContext(); ctx.setActive(true); - + applicationContext = ctx; // We do ALSO send the @Initialized(ApplicationScoped.class) at this location but this is WAY to early for userland apps Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java?rev=1676604&r1=1676603&r2=1676604&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java Tue Apr 28 20:03:17 2015 @@ -23,7 +23,6 @@ import java.util.concurrent.atomic.Atomi import java.util.logging.Level; import java.util.logging.Logger; -import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.spi.BeanManager; import org.apache.webbeans.config.BeansDeployer; @@ -158,9 +157,6 @@ public abstract class AbstractLifeCycle //Sub-classes operations beforeStopApplication(endObject); - //Set up the thread local for Application scoped as listeners will be App scoped. - contextsService.startContext(ApplicationScoped.class, endObject); - //Fire shut down beanManager.fireLifecycleEvent(new BeforeShutdownImpl());