This is an automated email from the ASF dual-hosted git repository. rmannibucau pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openwebbeans.git
The following commit(s) were added to refs/heads/master by this push: new 8c2215c [OWB-1378] enable to bypass application scoped lifecycle events in SE mode if org.apache.webbeans.lifecycle.standalone.fireApplicationScopeEvents=false 8c2215c is described below commit 8c2215c5782449d48ec97e629c610e5475a1a976 Author: Romain Manni-Bucau <rmannibu...@gmail.com> AuthorDate: Mon Mar 15 20:53:33 2021 +0100 [OWB-1378] enable to bypass application scoped lifecycle events in SE mode if org.apache.webbeans.lifecycle.standalone.fireApplicationScopeEvents=false --- .../webbeans/corespi/se/BaseSeContextsService.java | 27 +++++++++++++++++----- .../webbeans/lifecycle/StandaloneLifeCycle.java | 13 +++++++---- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/BaseSeContextsService.java b/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/BaseSeContextsService.java index 9bd65cb..3df8f18 100644 --- a/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/BaseSeContextsService.java +++ b/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/BaseSeContextsService.java @@ -355,26 +355,41 @@ public abstract class BaseSeContextsService extends AbstractContextsService { createSingletonContext(); - webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( - new Object(), InitializedLiteral.INSTANCE_SINGLETON_SCOPED); + if (fireApplicationScopeEvents()) + { + webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( + new Object(), InitializedLiteral.INSTANCE_SINGLETON_SCOPED); + } } private void stopApplicationContext() { if(applicationContext != null && !applicationContext.isDestroyed()) { - webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( - new Object(), BeforeDestroyedLiteral.INSTANCE_APPLICATION_SCOPED); + final boolean fireApplicationScopeEvents = fireApplicationScopeEvents(); + if (fireApplicationScopeEvents) + { + webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( + new Object(), BeforeDestroyedLiteral.INSTANCE_APPLICATION_SCOPED); + } applicationContext.destroy(); // this is needed to get rid of ApplicationScoped beans which are cached inside the proxies... WebBeansContext.currentInstance().getBeanManagerImpl().clearCacheProxies(); - webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( - new Object(), DestroyedLiteral.INSTANCE_APPLICATION_SCOPED); + if (fireApplicationScopeEvents) + { + webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( + new Object(), DestroyedLiteral.INSTANCE_APPLICATION_SCOPED); + } } } + public boolean fireApplicationScopeEvents() + { + return Boolean.parseBoolean(webBeansContext.getOpenWebBeansConfiguration() + .getProperty("org.apache.webbeans.lifecycle.standalone.fireApplicationScopeEvents", "true")); + } private void stopConversationContext() { diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java b/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java index 8d90fbf..cfb6e73 100644 --- a/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java +++ b/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java @@ -28,6 +28,7 @@ import java.util.logging.Logger; import org.apache.webbeans.annotation.InitializedLiteral; import org.apache.webbeans.config.WebBeansFinder; +import org.apache.webbeans.corespi.se.BaseSeContextsService; import org.apache.webbeans.el.ELContextStore; import org.apache.webbeans.logger.WebBeansLoggerFacade; import org.apache.webbeans.util.WebBeansUtil; @@ -58,10 +59,14 @@ public class StandaloneLifeCycle extends AbstractLifeCycle @Override protected void afterStartApplication(Object startupObject) { - // the ApplicationContext is already started, but we fire - // the event again as the userland beans are only available now - webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( - new Object(), InitializedLiteral.INSTANCE_APPLICATION_SCOPED); + if (!BaseSeContextsService.class.isInstance(webBeansContext.getContextsService()) || + BaseSeContextsService.class.cast(webBeansContext.getContextsService()).fireApplicationScopeEvents()) + { + // the ApplicationContext is already started, but we fire + // the event again as the userland beans are only available now + webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( + new Object(), InitializedLiteral.INSTANCE_APPLICATION_SCOPED); + } webBeansContext.getContextsService().startContext(RequestScoped.class, null); webBeansContext.getContextsService().startContext(SessionScoped.class, null);