Thread.currentThread().setContextClassLoader(appClassLoader); WebBeansContext wbc = WebBeansContext.currentInstance(); NormalScopeProxyFactory proxyFactory = wbc.getNormalScopeProxyFactory();
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); webBeansContext = WebBeansContext.currentInstance(); } }
/** * Initialize a few fields on deserialisation */ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); webBeansContext = WebBeansContext.currentInstance(); threadsUsingIt = new HashSet<>(); } }
@Override public BeanManager call() throws Exception { return WebBeansContext.currentInstance().getBeanManagerImpl(); } });
/** * Used by serialization. */ public FailOverBag() { WebBeansContext webBeansContext = WebBeansContext.currentInstance(); this.failOverService = webBeansContext.getService(FailOverService.class); this.items = new HashMap<String, Object>(); }
public FailOverBag(String sessionId, String jvmId) { WebBeansContext webBeansContext = WebBeansContext.currentInstance(); this.failOverService = webBeansContext.getService(FailOverService.class); this.items = new HashMap<String, Object>(); this.sessionId = sessionId; this.jvmId = jvmId; }
@Override public void stopApplicationScope() throws Exception { logger.log(Level.FINE, "stopping the OWB ApplicationContext"); WebBeansContext webBeansContext = WebBeansContext.currentInstance(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.endContext(ApplicationScoped.class, servletContext); }
@Override public void startRequestScope() throws Exception { logger.log(Level.FINE, "starting the OWB RequestContext"); WebBeansContext webBeansContext = WebBeansContext.currentInstance(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.startContext(RequestScoped.class, null); }
@Override public void startSessionScope() throws Exception { logger.log(Level.FINE, "starting the OWB SessionContext"); WebBeansContext webBeansContext = WebBeansContext.currentInstance(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.startContext(SessionScoped.class, session); }
@Override public void stopSessionScope() throws Exception { logger.log(Level.FINE, "stopping the OWB SessionContext"); WebBeansContext webBeansContext = WebBeansContext.currentInstance(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.endContext(SessionScoped.class, session); }
@Override public void startApplicationScope() throws Exception { logger.log(Level.FINE, "starting the OWB ApplicationContext"); WebBeansContext webBeansContext = WebBeansContext.currentInstance(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.startContext(ApplicationScoped.class, servletContext); }
@Override public void afterEach(final ExtensionContext extensionContext) { ofNullable(extensionContext.getStore(NAMESPACE).get(Holder.class, Holder.class)).map(h -> h.scopes).ifPresent(scopes -> { final ContextsService contextsService = WebBeansContext.currentInstance().getContextsService(); final List<Class<? extends Annotation>> list = new ArrayList<>(asList(scopes)); Collections.reverse(list); list.forEach(s -> contextsService.endContext(s, null)); }); }
public void initScanningExcludes() { if (scanningExcludes == null) { OpenWebBeansConfiguration owbConfiguration = WebBeansContext.currentInstance().getOpenWebBeansConfiguration(); String scanningExcludesProperty = owbConfiguration.getProperty(OpenWebBeansConfiguration.SCAN_EXCLUSION_PATHS); List<String> excludes = owbConfiguration.splitValues(scanningExcludesProperty); scanningExcludes = excludes.toArray(new String[excludes.size()]); } }
@Override public BeanManager call() throws Exception { return new InjectableBeanManager(WebBeansContext.currentInstance().getBeanManagerImpl()); } });
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { webBeansContext = WebBeansContext.currentInstance(); ObjectInputStream inputStream = new OwbCustomObjectInputStream(in, WebBeansUtil.getCurrentClassLoader()); injectionClazz = (Type)inputStream.readObject(); qualifierAnnotations = (Set<Annotation>)inputStream.readObject(); injectionPoint = (InjectionPoint) inputStream.readObject(); parentCreationalContext = webBeansContext.getBeanManagerImpl().createCreationalContext(null); // TODO: check what we can do }
@Override public void init(Object object) { // set per BDA beans.xml flag here because setting it in constructor // occurs before // properties are loaded. String usage = WebBeansContext.currentInstance().getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.USE_BDA_BEANSXML_SCANNER); isBDAScannerEnabled = Boolean.parseBoolean(usage); initScanningExcludes(); }
@Override public void beforeEach(final ExtensionContext extensionContext) { getScopes(extensionContext).ifPresent(scopes -> { final ContextsService contextsService = WebBeansContext.currentInstance().getContextsService(); Stream.of(scopes).forEach(s -> contextsService.startContext(s, null)); extensionContext.getStore(NAMESPACE).put(Holder.class, new Holder(scopes)); }); }
@Override public void stopContexts() throws Exception { logger.log(Level.FINE, "stopping all OWB Contexts"); WebBeansContext webBeansContext = WebBeansContext.currentInstance(); ContextsService contextsService = webBeansContext.getContextsService(); stopSessionScope(); stopConversationScope(); stopRequestScope(); stopApplicationScope(); contextsService.endContext(Singleton.class, null); }
@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(); }