Return-Path: Delivered-To: apmail-openwebbeans-commits-archive@www.apache.org Received: (qmail 4029 invoked from network); 11 Apr 2011 09:45:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Apr 2011 09:45:00 -0000 Received: (qmail 4493 invoked by uid 500); 11 Apr 2011 09:44:59 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 4459 invoked by uid 500); 11 Apr 2011 09:44:58 -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 4450 invoked by uid 99); 11 Apr 2011 09:44:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Apr 2011 09:44:57 +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; Mon, 11 Apr 2011 09:44:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2BDB52388A29; Mon, 11 Apr 2011 09:44:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1090992 - /openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java Date: Mon, 11 Apr 2011 09:44:33 -0000 To: commits@openwebbeans.apache.org From: gpetracek@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110411094433.2BDB52388A29@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gpetracek Date: Mon Apr 11 09:44:32 2011 New Revision: 1090992 URL: http://svn.apache.org/viewvc?rev=1090992&view=rev Log: OWB-564 CdiTestOpenWebBeansContainer - check if a std.-context is active before destroying it Modified: openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java Modified: openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java?rev=1090992&r1=1090991&r2=1090992&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java (original) +++ openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java Mon Apr 11 09:44:32 2011 @@ -21,13 +21,21 @@ package org.apache.webbeans.cditest.owb; import java.lang.annotation.Annotation; import java.util.Set; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.context.ConversationScoped; +import javax.enterprise.context.RequestScoped; +import javax.enterprise.context.SessionScoped; +import javax.enterprise.context.spi.Context; import javax.enterprise.inject.ResolutionException; import javax.enterprise.inject.spi.Bean; import javax.enterprise.inject.spi.BeanManager; +import javax.inject.Singleton; import org.apache.webbeans.cditest.CdiTestContainer; import org.apache.webbeans.config.WebBeansContext; import org.apache.webbeans.context.ContextFactory; +import org.apache.webbeans.context.type.ContextTypes; +import org.apache.webbeans.logger.WebBeansLogger; import org.apache.webbeans.spi.ContainerLifecycle; import static org.apache.webbeans.util.InjectionExceptionUtils.*; @@ -36,6 +44,7 @@ import static org.apache.webbeans.util.I */ public class CdiTestOpenWebBeansContainer implements CdiTestContainer { + private static final WebBeansLogger logger = WebBeansLogger.getLogger(CdiTestOpenWebBeansContainer.class); private ContainerLifecycle lifecycle = null; private MockServletContext servletContext = null; @@ -120,11 +129,23 @@ public class CdiTestOpenWebBeansContaine WebBeansContext webBeansContext = WebBeansContext.getInstance(); ContextFactory contextFactory = webBeansContext.getContextFactory(); - contextFactory.destroyRequestContext(null); - contextFactory.destroyConversationContext(); - contextFactory.destroySessionContext(session); - contextFactory.destroyApplicationContext(servletContext); - contextFactory.destroySingletonContext(servletContext); + stopSessionScope(); + stopConversationScope(); + stopRequestScope(); + stopApplicationScope(); + + Context context = contextFactory.getStandardContext(ContextTypes.SINGLETON); + if(context != null && context.isActive()) + { + contextFactory.destroySingletonContext(servletContext); + } + else + { + if(logger.wblWillLogWarn()) + { + logger.warn("destroy was called for an inactive context (" + Singleton.class.getName() + ")"); + } + } //Comment out for OWB-502 //ContextFactory.cleanUpContextFactory(); @@ -136,7 +157,18 @@ public class CdiTestOpenWebBeansContaine WebBeansContext webBeansContext = WebBeansContext.getInstance(); ContextFactory contextFactory = webBeansContext.getContextFactory(); - contextFactory.destroyApplicationContext(servletContext); + Context context = contextFactory.getStandardContext(ContextTypes.APPLICATION); + if(context != null && context.isActive()) + { + contextFactory.destroyApplicationContext(servletContext); + } + else + { + if(logger.wblWillLogWarn()) + { + logger.warn("destroy was called for an inactive context (" + ApplicationScoped.class.getName() + ")"); + } + } } @Override @@ -145,7 +177,18 @@ public class CdiTestOpenWebBeansContaine WebBeansContext webBeansContext = WebBeansContext.getInstance(); ContextFactory contextFactory = webBeansContext.getContextFactory(); - contextFactory.destroyConversationContext(); + Context context = contextFactory.getStandardContext(ContextTypes.CONVERSATION); + if(context != null && context.isActive()) + { + contextFactory.destroyConversationContext(); + } + else + { + if(logger.wblWillLogWarn()) + { + logger.warn("destroy was called for an inactive context (" + ConversationScoped.class.getName() + ")"); + } + } } @Override @@ -160,7 +203,18 @@ public class CdiTestOpenWebBeansContaine WebBeansContext webBeansContext = WebBeansContext.getInstance(); ContextFactory contextFactory = webBeansContext.getContextFactory(); - contextFactory.destroyRequestContext(null); + Context context = contextFactory.getStandardContext(ContextTypes.REQUEST); + if(context != null && context.isActive()) + { + contextFactory.destroyRequestContext(null); + } + else + { + if(logger.wblWillLogWarn()) + { + logger.warn("destroy was called for an inactive context (" + RequestScoped.class.getName() + ")"); + } + } } @Override @@ -169,7 +223,18 @@ public class CdiTestOpenWebBeansContaine WebBeansContext webBeansContext = WebBeansContext.getInstance(); ContextFactory contextFactory = webBeansContext.getContextFactory(); - contextFactory.destroySessionContext(session); + Context context = contextFactory.getStandardContext(ContextTypes.SESSION); + if(context != null && context.isActive()) + { + contextFactory.destroySessionContext(session); + } + else + { + if(logger.wblWillLogWarn()) + { + logger.warn("destroy was called for an inactive context (" + SessionScoped.class.getName() + ")"); + } + } } public BeanManager getBeanManager()