private OpenEjbContainer(final Map<?, ?> map, final AppContext appContext) { webBeanContext = appContext.getWebBeansContext(); globalJndiContext = new GlobalContext(appContext.getGlobalJndiContext()); final Properties properties = new Properties(); properties.putAll(map); options = new Options(properties); startNetworkServices(); servletContext = new MockServletContext(); session = new MockHttpSession(); try { startContexts(webBeanContext.getContextsService(), servletContext, session); } catch (final Exception e) { logger().warning("can't start all CDI contexts", e); } }
private void stopCurrentContexts() throws Exception { stopContexts(appContext.get().getWebBeansContext().getContextsService(), servletContext.get(), session.get()); }
private OpenEjbContainer(final Map<?, ?> map, final AppContext appContext) { webBeanContext = appContext.getWebBeansContext(); globalJndiContext = new GlobalContext(appContext.getGlobalJndiContext()); final Properties properties = new Properties(); properties.putAll(map); options = new Options(properties); startNetworkServices(); if (webBeanContext != null) { servletContext = new MockServletContext(); session = new MockHttpSession(); try { startContexts(webBeanContext.getContextsService(), servletContext, session); } catch (final Exception e) { logger().warning("can't start all CDI contexts", e); } } }
stopContexts(webBeanContext.getContextsService(), servletContext, session); } catch (final Exception e) { log.warning("can't stop all CDI contexts", e);
private DeploymentInfo quickDeploy(final Archive<?> archive, final TestClass testClass) throws DeploymentException { final String name = archive.getName(); DeploymentInfo info = DEPLOYMENT_INFO.get(name); if (info == null) { try { final AppModule module = OpenEJBArchiveProcessor.createModule(archive, testClass); final AppInfo appInfo = configurationFactory.configureApplication(module); final AppContext appCtx = assembler.createApplication(appInfo, module.getClassLoader()); final ServletContext appServletContext = new MockServletContext(); final HttpSession appSession = new MockHttpSession(); startContexts(appCtx.getWebBeansContext().getContextsService(), appServletContext, appSession); info = new DeploymentInfo(appServletContext, appSession, appInfo, appCtx); if (configuration.isSingleDeploymentByArchiveName(name)) { DEPLOYMENT_INFO.putIfAbsent(name, info); } } catch (final Exception e) { throw new DeploymentException("can't deploy " + name, e); } } return info; }
ScopeHelper.stopContexts(contextsService, servletContext, session); } catch (final Exception e) {
ScopeHelper.startContexts(appContext.getWebBeansContext().getContextsService(), servletContext, session);
public void stopApplication() throws NamingException { if (appContext != null && appContext.getWebBeansContext() != null) { final ContextsService contextsService = appContext.getWebBeansContext().getContextsService(); // No need to stop the ConversationContext manually as it gets stored inside the SessionContext as Bean contextsService.endContext(SessionScoped.class, session); contextsService.endContext(RequestScoped.class, null); } if (appInfo != null) { try { assembler.destroyApplication(appInfo.path); } catch (final Exception e) { // no-op } } final ContainerSystem component = SystemInstance.get().getComponent(ContainerSystem.class); if (null != component) { final Context context = component.getJNDIContext(); for (final String entry : globalJndiEntries) { context.unbind(entry); } } globalJndiEntries.clear(); if (mockCdiContexts() && appContext != null && appContext.getWebBeansContext() != null) { try { ScopeHelper.stopContexts(appContext.getWebBeansContext().getContextsService(), servletContext, session); } catch (final Exception e) { // no-op } } }
startContexts(appCtx.getWebBeansContext().getContextsService(), appServletContext, appSession);
stopContexts(webBeanContext.getContextsService(), servletContext, session); } catch (final Exception e) { logger().warning("can't stop all CDI contexts", e);
ScopeHelper.startContexts(appContext.getWebBeansContext().getContextsService(), servletContext, session);
stopContexts(ctx.getWebBeansContext().getContextsService(), servletContext.get(), session.get());