use of org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl in project tomee by apache.
the class WebappBeanManagerTest method containerEventsShouldntGoUp.
@Test
public void containerEventsShouldntGoUp() {
final WebappWebBeansContext ctx = new WebappWebBeansContext(Collections.<Class<?>, Object>emptyMap(), new Properties(), new WebBeansContext());
final WebappBeanManager wbm = new WebappBeanManager(ctx) {
@Override
public BeanManagerImpl getParentBm() {
throw new IllegalStateException("shouldn't be called");
}
};
wbm.fireEvent(new GProcessProducer(null, null), true);
wbm.fireEvent(new GProcessProducerField(null, null, null), true);
wbm.fireEvent(new GProcessProducerMethod(null, null, null), true);
wbm.fireEvent(new GProcessInjectionTarget(null, null), true);
wbm.fireEvent(new GProcessBean(null, null), true);
wbm.fireEvent(new GProcessAnnotatedType(null), true);
wbm.fireEvent(new GProcessSessionBean(null, null, null, null), true);
wbm.fireEvent(new AfterBeanDiscoveryImpl(ctx), true);
wbm.fireEvent(new AfterDeploymentValidationImpl(wbm), true);
wbm.fireEvent(new BeforeBeanDiscoveryImpl(ctx), true);
wbm.fireEvent(new BeforeShutdownImpl(), true);
}
use of org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl in project tomee by apache.
the class CdiPlugin method stop.
public void stop() throws OpenEJBException {
final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
try {
// Setting context class loader for cleaning
Thread.currentThread().setContextClassLoader(classLoader);
// Fire shut down
webBeansContext.getBeanManagerImpl().fireEvent(new BeforeShutdownImpl());
// Destroys context
webBeansContext.getContextsService().destroy(null);
// Free all plugin resources
webBeansContext.getPluginLoader().shutDown();
// Clear extensions
webBeansContext.getExtensionLoader().clear();
// Delete Resolutions Cache
webBeansContext.getBeanManagerImpl().getInjectionResolver().clearCaches();
// Delete AnnotateTypeCache
webBeansContext.getAnnotatedElementFactory().clear();
// Clear the resource injection service
final CdiResourceInjectionService injectionServices = (CdiResourceInjectionService) webBeansContext.getService(ResourceInjectionService.class);
injectionServices.clear();
// Clear singleton list
WebBeansFinder.clearInstances(WebBeansUtil.getCurrentClassLoader());
} catch (final Exception e) {
throw new OpenEJBException(e);
} finally {
Thread.currentThread().setContextClassLoader(oldCl);
}
}
use of org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl 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);
}
}
Aggregations