Search in sources :

Example 1 with ELContextStore

use of org.apache.webbeans.el.ELContextStore in project HotswapAgent by HotswapProjects.

the class HAOpenWebBeansTestLifeCycle method beforeStopApplication.

public void beforeStopApplication(Object endObject) {
    WebBeansContext webBeansContext = getWebBeansContext();
    ContextsService contextsService = webBeansContext.getContextsService();
    contextsService.endContext(Singleton.class, null);
    contextsService.endContext(ApplicationScoped.class, null);
    contextsService.endContext(RequestScoped.class, null);
    contextsService.endContext(SessionScoped.class, mockHttpSession);
    ELContextStore elStore = ELContextStore.getInstance(false);
    if (elStore == null) {
        return;
    }
    elStore.destroyELContextStore();
}
Also used : WebContextsService(org.apache.webbeans.web.context.WebContextsService) ContextsService(org.apache.webbeans.spi.ContextsService) WebBeansContext(org.apache.webbeans.config.WebBeansContext) ELContextStore(org.apache.webbeans.el.ELContextStore)

Example 2 with ELContextStore

use of org.apache.webbeans.el.ELContextStore in project tomee by apache.

the class OpenEJBLifecycle method stopApplication.

@Override
public void stopApplication(final Object endObject) {
    logger.debug("OpenWebBeans Container is stopping.");
    try {
        // Fire shut down
        if (WebappBeanManager.class.isInstance(beanManager)) {
            WebappBeanManager.class.cast(beanManager).beforeStop();
        }
        webBeansContext.getContextsService().endContext(RequestScoped.class, endObject);
        webBeansContext.getContextsService().endContext(ConversationScoped.class, endObject);
        webBeansContext.getContextsService().endContext(SessionScoped.class, endObject);
        webBeansContext.getContextsService().endContext(ApplicationScoped.class, endObject);
        webBeansContext.getContextsService().endContext(Singleton.class, endObject);
        // clean up the EL caches after each request
        ELContextStore elStore = ELContextStore.getInstance(false);
        if (elStore != null) {
            elStore.destroyELContextStore();
        }
        this.beanManager.fireEvent(new BeforeShutdownImpl(), true);
        // this will now even destroy the ExtensionBeans and other internal stuff
        this.contextsService.destroy(endObject);
        // Unbind BeanManager
        if (jndiService != null) {
            jndiService.unbind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME);
        }
        // Free all plugin resources
        ((CdiPlugin) webBeansContext.getPluginLoader().getEjbPlugin()).clearProxies();
        webBeansContext.getPluginLoader().shutDown();
        // Clear extensions
        webBeansContext.getExtensionLoader().clear();
        // Delete Resolutions Cache
        beanManager.getInjectionResolver().clearCaches();
        // Delete AnnotateTypeCache
        webBeansContext.getAnnotatedElementFactory().clear();
        // After Stop
        // Clear the resource injection service
        final ResourceInjectionService injectionServices = webBeansContext.getService(ResourceInjectionService.class);
        if (injectionServices != null) {
            injectionServices.clear();
        }
        // Comment out for commit OWB-502
        // ContextFactory.cleanUpContextFactory();
        CdiAppContextsService.class.cast(contextsService).removeThreadLocals();
        WebBeansFinder.clearInstances(WebBeansUtil.getCurrentClassLoader());
        // Clear BeanManager
        this.beanManager.clear();
        // Clear singleton list
        WebBeansFinder.clearInstances(WebBeansUtil.getCurrentClassLoader());
    } catch (final Exception e) {
        logger.error("An error occured while stopping the container.", e);
    }
}
Also used : BeforeShutdownImpl(org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl) ELContextStore(org.apache.webbeans.el.ELContextStore) ResourceInjectionService(org.apache.webbeans.spi.ResourceInjectionService) ObjectStreamException(java.io.ObjectStreamException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException)

Example 3 with ELContextStore

use of org.apache.webbeans.el.ELContextStore in project tomee by apache.

the class BeginWebBeansListener method requestDestroyed.

/**
 * {@inheritDoc}
 */
@Override
public void requestDestroyed(final ServletRequestEvent event) {
    if (webBeansContext == null) {
        return;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Destroying a request : [{0}]", event == null ? "null" : event.getServletRequest().getRemoteAddr());
    }
    final Object oldContext;
    if (event != null) {
        oldContext = event.getServletRequest().getAttribute(contextKey);
    } else {
        oldContext = null;
    }
    try {
        // clean up the EL caches after each request
        final ELContextStore elStore = ELContextStore.getInstance(false);
        if (elStore != null) {
            elStore.destroyELContextStore();
        }
        contextsService.endContext(RequestScoped.class, event);
        if (webBeansContext instanceof WebappWebBeansContext) {
            // end after child
            ((WebappWebBeansContext) webBeansContext).getParent().getContextsService().endContext(RequestScoped.class, event);
        }
    } finally {
        contextsService.removeThreadLocals();
        ThreadSingletonServiceImpl.enter((WebBeansContext) oldContext);
    }
}
Also used : WebappWebBeansContext(org.apache.openejb.cdi.WebappWebBeansContext) ELContextStore(org.apache.webbeans.el.ELContextStore)

Aggregations

ELContextStore (org.apache.webbeans.el.ELContextStore)3 ObjectStreamException (java.io.ObjectStreamException)1 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)1 WebappWebBeansContext (org.apache.openejb.cdi.WebappWebBeansContext)1 WebBeansContext (org.apache.webbeans.config.WebBeansContext)1 BeforeShutdownImpl (org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl)1 ContextsService (org.apache.webbeans.spi.ContextsService)1 ResourceInjectionService (org.apache.webbeans.spi.ResourceInjectionService)1 WebContextsService (org.apache.webbeans.web.context.WebContextsService)1