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) {}; } }
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) {}; } }
SingletonService<WebBeansContext> singletonInstance = WebBeansFinder.getSingletonService(); DefaultSingletonService.class.cast(singletonInstance).register(loader, context);
@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); } }