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); }
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(); }
@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(); }
protected SeContainer newContainer(final WebBeansContext context) { Object startObj = new Object(); context.getService(ContainerLifecycle.class).startApplication(startObj); return new OWBContainer(context, startObj); }
/** * {@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; } }
/** * {@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 init(FilterConfig filterConfig) throws ServletException { this.lifeCycle = webBeansContext.getService(ContainerLifecycle.class); this.servletContext = filterConfig.getServletContext(); String startOwbCfg = filterConfig.getInitParameter("startOwb"); startOwb = startOwbCfg == null || "true".equalsIgnoreCase(startOwbCfg); if (startOwb) { try { this.lifeCycle.startApplication(new ServletContextEvent(this.servletContext)); } catch (Exception e) { logger.log(Level.SEVERE, WebBeansLoggerFacade.constructMessage(OWBLogConst.ERROR_0018, ServletCompatibilityUtil.getServletInfo(servletContext))); WebBeansUtil.throwRuntimeExceptions(e); } } }
@Override public synchronized void boot() { lifecycle = WebBeansContext.currentInstance().getService(ContainerLifecycle.class); Object mockServletContextEvent = null; if (OpenWebBeansContextControl.isServletApiAvailable()) { mockServletContextEvent = OwbHelper.getMockServletContextEvent(); } lifecycle.startApplication(mockServletContextEvent); }
@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(); }
@Override public synchronized void boot() { lifecycle = WebBeansContext.currentInstance().getService(ContainerLifecycle.class); Object mockServletContextEvent = null; if (OpenWebBeansContextControl.isServletApiAvailable()) { mockServletContextEvent = OwbHelper.getMockServletContextEvent(); } lifecycle.startApplication(mockServletContextEvent); }
@Override public void bootContainer() throws Exception { servletContext = new MockServletContext(); session = new MockHttpSession(); lifecycle = WebBeansContext.getInstance().getService(ContainerLifecycle.class); lifecycle.startApplication(new ServletContextEvent(servletContext)); }
setConfiguration(webBeansContext.getOpenWebBeansConfiguration()); try { webBeansContext.getService(ContainerLifecycle.class).startApplication(startupObject); } catch (final Exception e) { throw new OpenEJBRuntimeException("couldn't start owb context", e);
setConfiguration(webBeansContext.getOpenWebBeansConfiguration()); try { webBeansContext.getService(ContainerLifecycle.class).startApplication(startupObject); } catch (final Exception e) { throw new DeploymentException("couldn't start owb context", e);
@Before public void setUp() { event = new ServletContextEvent(mock(ServletContext.class)); lifecycle = WebBeansContext.currentInstance().getService(ContainerLifecycle.class); lifecycle.startApplication(event); bus = getBeanReference(Bus.class); }
@BeforeClass public static void startContainer() { final WebBeansContext webBeansContext = WebBeansContext.currentInstance(); lifecycle = webBeansContext.getService(ContainerLifecycle.class); lifecycle.startApplication(null); bm = webBeansContext.getBeanManagerImpl(); }
@Override public void moduleInitialized(ServletContext servletContext) { String webModuleName = (String) servletContext.getAttribute(WebApplicationConstants.WEB_APP_NAME); OpenWebBeansWebAppContext webAppContext = OpenWebBeansWebAppContext.getOpenWebBeansWebAppContext(webModuleName); // Initialize WebBeansContext in current servlet context this.webBeansContext = webAppContext.getWebBeansContext(); //TODO Seems that only one cleanUp thread is required for the shareable WebBeansContext service = OpenWebBeansWebInitializer.initializeServletContext(webBeansContext, servletContext); //Register the interceptor to Holder instance webAppContext.getHolder().addInterceptor(new OpenWebBeansHolderInterceptor(this.webBeansContext)); this.failoverService = webBeansContext.getService(FailOverService.class); try { this.lifeCycle = webBeansContext.getService(ContainerLifecycle.class); //OpenWebBeansWebModuleListener will only manage the lifecycle if the WebBeansContext is standalone for the current web application //Or the AppInfoGBean will maintain the sharelable WebBeansContext if (lifeCycle instanceof org.apache.webbeans.web.lifecycle.WebContainerLifecycle || !webAppContext.isShareableWebBeansContext()) { this.lifeCycle.startApplication(new ServletContextEvent(servletContext)); } else { this.lifeCycle = null; } } catch (Exception e) { logger.error(OWBLogConst.ERROR_0018, servletContext.getContextPath()); WebBeansUtil.throwRuntimeExceptions(e); } }