@Override public void start() { lifecycle = WebBeansContext.currentInstance().getService(ContainerLifecycle.class); lifecycle.startApplication(null); Thread t = new Thread(() -> { while(true) { try { Thread.sleep(Long.MAX_VALUE-1); } catch (InterruptedException e) { } } }); t.setDaemon(false); t.start(); }
@Override public void stop() { lifecycle.stopApplication(null); }
public static void main(final String[] args) { final ContainerLifecycle lifecycle = WebBeansContext.currentInstance() .getService(ContainerLifecycle.class); lifecycle.startApplication(null); final BeanManager beanManager = lifecycle.getBeanManager(); // replace Tester with your start up class final Bean<?> bean = beanManager.getBeans(Tester.class).iterator() .next(); final Tester b = (Tester) lifecycle.getBeanManager().getReference(bean, Tester.class, beanManager.createCreationalContext(bean)); b.doInit(); }
public void start() throws InterruptedException { log.info(OWBLogConst.INFO_0005); long begin = System.currentTimeMillis(); containerLifecycle.startApplication(properties); Runtime.getRuntime().addShutdownHook(new Thread(){ @Override public void run() { latch.countDown(); } }); log.log(Level.INFO, OWBLogConst.INFO_0001, Long.toString(System.currentTimeMillis() - begin)); latch.await(); log.info(OWBLogConst.INFO_0008); containerLifecycle.stopApplication(properties); log.info(OWBLogConst.INFO_0009); }
/** * {@inheritDoc} */ @Override public void sessionDestroyed(HttpSessionEvent event) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Destroying a session with session id : [{0}]", event.getSession().getId()); } this.lifeCycle.getContextService().endContext(SessionScoped.class, event.getSession()); this.lifeCycle.getContextService().endContext(ConversationScoped.class, event.getSession()); } }
@Override public BeanManager getBeanManager() { return lifecycle.getBeanManager(); }
/** * {@inheritDoc} */ @Override public void sessionCreated(HttpSessionEvent event) { try { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Starting a session with session id : [{0}]", event.getSession().getId()); } this.lifeCycle.getContextService().startContext(SessionScoped.class, event.getSession()); } catch (Exception e) { logger.log(Level.SEVERE, WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0020, event.getSession())); WebBeansUtil.throwRuntimeExceptions(e); } }
@Override public BeanManager getBeanManager() { if (lifecycle == null) { return null; } return lifecycle.getBeanManager(); }
protected SeContainer newContainer(final WebBeansContext context) { Object startObj = new Object(); context.getService(ContainerLifecycle.class).startApplication(startObj); return new OWBContainer(context, startObj); }
@Override public void shutdownContainer() throws Exception { if (lifecycle != null) { lifecycle.stopApplication(new ServletContextEvent(servletContext)); } }
@Override public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException { singletonService.initOwb(); webBeansContext = WebBeansContext.getInstance(); LOG.fine("OpenWebBeans Arquillian starting deployment"); ContainerLifecycle lifecycle = webBeansContext.getService(ContainerLifecycle.class); lifecycleProducer.set(lifecycle); OwbArquillianScannerService dummyScannerService = (OwbArquillianScannerService) webBeansContext.getScannerService(); dummyScannerService.setArchive(archive); ClassLoader parentLoader = Thread.currentThread().getContextClassLoader(); originalLoader.set(parentLoader); Thread.currentThread().setContextClassLoader(new OwbSWClassLoader(parentLoader, archive, useOnlyArchiveResources, useOnlyArchiveResourcesExcludes)); lifecycle.startApplication(null); // finally make the BeanManager available to Arquillian, but only if the boot succeeded beanManagerProducer.set(lifecycle.getBeanManager()); return new ProtocolMetaData(); }
/** * {@inheritDoc} */ @Override public void sessionDestroyed(HttpSessionEvent event) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Destroying a session with session id : [{0}]", event.getSession().getId()); } boolean mustDestroy = ensureRequestScope(); this.lifeCycle.getContextService().endContext(SessionScoped.class, event.getSession()); if (mustDestroy) { requestDestroyed(null); } }
@Override public BeanManager getBeanManager() { if (lifecycle == null) { return null; } return lifecycle.getBeanManager(); }
/** * {@inheritDoc} */ public void contextInitialized(ServletContextEvent event) { String webModuleName = (String) event.getServletContext().getAttribute(WebApplicationConstants.WEB_APP_NAME); OpenWebBeansWebAppContext webAppContext = OpenWebBeansWebAppContext.getOpenWebBeansWebAppContext(webModuleName); this.webBeansContext = webAppContext.getWebBeansContext(); this.failoverService = webBeansContext.getService(FailOverService.class); this.lifeCycle = webBeansContext.getService(ContainerLifecycle.class); if (lifeCycle instanceof org.apache.webbeans.web.lifecycle.WebContainerLifecycle) { this.lifeCycle.startApplication(event); } else { this.lifeCycle = null; } }
@Override public void moduleDestoryed(ServletContext servletContext) { if (this.lifeCycle != null) { this.lifeCycle.stopApplication(new ServletContextEvent(servletContext)); this.lifeCycle = null; } if (service != null) { service.shutdownNow(); } this.webBeansContext = null; }
lifecycle.startApplication(null); beanManagerProducer.set(lifecycle.getBeanManager());
/** * {@inheritDoc} */ @Override public void sessionCreated(HttpSessionEvent event) { try { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Starting a session with session id : [{0}]", event.getSession().getId()); } this.lifeCycle.getContextService().startContext(SessionScoped.class, event.getSession()); } catch (Exception e) { logger.log(Level.SEVERE, WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0020, event.getSession())); WebBeansUtil.throwRuntimeExceptions(e); } }
@SuppressWarnings("unchecked") private<T> T getBeanReference(Class<T> clazz) { final BeanManager beanManager = lifecycle.getBeanManager(); final Set<Bean<?>> beans = beanManager.getBeans(clazz); final Bean<?> bean = beanManager.resolve(beans); return (T)beanManager.getReference(bean, clazz, beanManager.createCreationalContext(bean)); }
/** * {@inheritDoc} */ @Override public void contextInitialized(ServletContextEvent event) { this.lifeCycle = webBeansContext.getService(ContainerLifecycle.class); try { this.lifeCycle.startApplication(event); } catch (Exception e) { logger.log(Level.SEVERE, WebBeansLoggerFacade.constructMessage( OWBLogConst.ERROR_0018, ServletCompatibilityUtil.getServletInfo(event.getServletContext()))); WebBeansUtil.throwRuntimeExceptions(e); } }
/** * {@inheritDoc} */ @Override public void contextDestroyed(ServletContextEvent event) { if (lifeCycle != null) { lifeCycle.stopApplication(event); } // just to be sure that we didn't lazily create anything... cleanupRequestThreadLocals(); }