org.apache.webbeans.config.WebBeansFinder Java Examples
The following examples show how to use
org.apache.webbeans.config.WebBeansFinder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HAAbstractUnitTest.java From HotswapAgent with GNU General Public License v2.0 | 6 votes |
protected void startContainer() { WebBeansFinder.clearInstances(WebBeansUtil.getCurrentClassLoader()); //Creates a new container testLifecycle = new HAOpenWebBeansTestLifeCycle(); webBeansContext = WebBeansContext.getInstance(); //Start application try { testLifecycle.startApplication(null); } catch (Exception e) { throw new WebBeansConfigurationException(e); } }
Example #2
Source File: ClassLoaderLock.java From openwebbeans-meecrowave with Apache License 2.0 | 5 votes |
public static ClassLoader getUsableContainerLoader() { ClassLoader currentCL = Thread.currentThread().getContextClassLoader(); if (currentCL == null) { currentCL = ClassLoaderLock.class.getClassLoader(); } if (Boolean.getBoolean("meecrowave.junit.classloaderlock.off")) { // safeguard for advanced cases return currentCL; } final SingletonService<WebBeansContext> singletonService = WebBeansFinder.getSingletonService(); synchronized (singletonService) { try { if (singletonService instanceof DefaultSingletonService) { synchronized (singletonService) { ((DefaultSingletonService) singletonService).register(currentCL, null); // all fine, it seems we do not have an OWB container for this ClassLoader yet // let's reset it then ; singletonService.clear(currentCL); } return currentCL; } } catch (IllegalArgumentException iae) { // whoops there is already an OWB container registered for this very ClassLoader } return new ClassLoader(currentCL) {}; } }
Example #3
Source File: HammockInitializer.java From hammock with Apache License 2.0 | 5 votes |
@Override protected SeContainer newContainer(WebBeansContext context) { SingletonService<WebBeansContext> singletonService = WebBeansFinder.getSingletonService(); if(singletonService instanceof HolderSingletonService) { ((HolderSingletonService) singletonService).register(context); } else { try { WebBeansFinder.setSingletonService(new HolderSingletonService(context)); } catch (Exception e) { logger.info("Unable to override OWB SingletonService", e); } } return super.newContainer(context); }
Example #4
Source File: CdiBuilder.java From tomee with Apache License 2.0 | 5 votes |
public static synchronized ThreadSingletonService initializeOWB() { logger.info("Created new singletonService " + SINGLETON_SERVICE); SystemInstance.get().addObserver(SINGLETON_SERVICE); SystemInstance.get().setComponent(ThreadSingletonService.class, SINGLETON_SERVICE); try { WebBeansFinder.setSingletonService(SINGLETON_SERVICE); logger.info("Succeeded in installing singleton service"); } catch (final Exception e) { //ignore // not logging the exception since it is nto an error logger.debug("Could not install our singleton service"); } return SINGLETON_SERVICE; }
Example #5
Source File: CdiPlugin.java From tomee with Apache License 2.0 | 5 votes |
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); } }
Example #6
Source File: OpenEJBLifecycle.java From tomee with Apache License 2.0 | 4 votes |
@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); } }