public void run() { webBeansContext.getConversationManager().destroyWithRespectToTimout(); } }
@Override public void destroy(Set<ConversationContext> instance, CreationalContext<Set<ConversationContext>> context) { if (instance == null || instance.isEmpty()) { return; } ConversationManager conversationManager = webBeansContext.getConversationManager(); for (ConversationContext conversationContext : instance) { conversationManager.destroyConversationContext(conversationContext); } }
/** * {@inheritDoc} */ public void sessionDestroyed(HttpSessionEvent event) { if (logger.wblWillLogDebug()) { logger.debug("Destroying a session with session id : [{0}]", event.getSession().getId()); } this.webBeansContext.getContextsService().endContext(SessionScoped.class, event.getSession()); ConversationManager conversationManager = webBeansContext.getConversationManager(); conversationManager.destroyConversationContextWithSessionId(event.getSession().getId()); }
/** * {@inheritDoc} */ public void sessionDestroyed(HttpSessionEvent event) { if (logger.wblWillLogDebug()) { logger.debug("Destroying a session with session id : [{0}]", event.getSession().getId()); } this.webBeansContext.getContextsService().endContext(SessionScoped.class, event.getSession()); ConversationManager conversationManager = webBeansContext.getConversationManager(); conversationManager.destroyConversationContextWithSessionId(event.getSession().getId()); }
/** * Creates a new instance. */ public WebContextsService(WebBeansContext webBeansContext) { super(webBeansContext); conversationManager = webBeansContext.getConversationManager(); applicationContext = new ApplicationContext(); applicationContext.setActive(true); requestContexts = new ThreadLocal<>(); sessionContexts = new ThreadLocal<>(); conversationContexts = new ThreadLocal<>(); //Dependent context is always active dependentContext = new DependentContext(); dependentContext.setActive(true); configureEagerSessionInitialisation(webBeansContext); }
/** * Stores the session and conversation contexts in the {@link FailOverBag}. * * @param bag The {@link FailOverBag}. * @param session The current {@link HttpSession}. */ protected void storeBeansInFailOverBag(FailOverBag bag, HttpSession session) { // store the session context SessionContextManager sessionManager = ((WebContextsService) webBeansContext.getContextsService()).getSessionContextManager(); SessionContext sessionContext = sessionManager.getSessionContextWithSessionId(session.getId()); bag.put(ATTRIBUTE_SESSION_CONTEXT, sessionContext); // store all conversation contexts ConversationManager conversationManager = webBeansContext.getConversationManager(); bag.put(ATTRIBUTE_CONVERSATION_CONTEXT_MAP, conversationManager.getConversationMapWithSessionId(session.getId())); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Beans for session [" + bag.getSessionId() + "] successfully stored in FailOverBag."); } }
/** * {@inheritDoc} */ @Override public void sessionDestroyed(final HttpSessionEvent event) { if (webBeansContext == null) { return; } if (logger.isDebugEnabled()) { logger.debug("Destroying a session with session id : [{0}]", event.getSession().getId()); } // ensure session ThreadLocal is set webBeansContext.getContextsService().startContext(SessionScoped.class, event.getSession()); webBeansContext.getContextsService().endContext(SessionScoped.class, event.getSession()); if (WebappWebBeansContext.class.isInstance(webBeansContext)) { // end after child WebappWebBeansContext.class.cast(webBeansContext).getParent().getContextsService().endContext(SessionScoped.class, event.getSession()); } final ConversationManager conversationManager = webBeansContext.getConversationManager(); final Map<Conversation, ConversationContext> cc = conversationManager.getAndRemoveConversationMapWithSessionId(event.getSession().getId()); for (final ConversationContext c : cc.values()) { if (c != null) { c.destroy(); } } destroyFakedRequest(); }
/** * {@inheritDoc} * * This will also remove the current ConversationContext from the SessionContext */ @Override public void end() { checkThreadUsage(); if (!isTransient) { iDontUseItAnymore(); id = null; isTransient = true; } else { logger.log(Level.WARNING, OWBLogConst.WARN_0004, id); throw new IllegalStateException(toString() + " has already ended"); } // now store this conversation in the SessionContext ConversationManager conversationManager = webBeansContext.getConversationManager(); ConversationContext conversationContext = (ConversationContext) webBeansContext.getContextsService().getCurrentContext(ConversationScoped.class); conversationManager.removeConversationFromStorage(conversationContext); }
ConversationManager conversationManager = WebBeansContext.getInstance().getConversationManager(); Conversation conversation = conversationManager.getConversationBeanReference(); if (conversation != null && !conversation.isTransient())
ConversationManager conversationManager = webBeansContext.getConversationManager(); Iterator<Conversation> iterator = conversationContextMap.keySet().iterator();
public boolean isPassivatingScope() { final CdiEjbBean<?> bean = get(CdiEjbBean.class); if (bean == null) { return true; } if (ConversationScoped.class == bean.getScope()) { try { return !bean.getWebBeansContext().getConversationManager().getConversationBeanReference().isTransient(); } catch (final RuntimeException re) { // conversation not found for instance so act as @RequestScoped return false; } } return true; }
public boolean isPassivatingScope() { final CdiEjbBean<?> bean = get(CdiEjbBean.class); if (bean == null) { return true; } if (ConversationScoped.class == bean.getScope()) { try { return !bean.getWebBeansContext().getConversationManager().getConversationBeanReference().isTransient(); } catch (final RuntimeException re) { // conversation not found for instance so act as @RequestScoped return false; } } return true; }
if (sessionContext != null && sessionContext.isActive()) conversationManager = webBeansContext.getConversationManager(); Set<ConversationContext> conversationContexts = conversationManager.getSessionConversations(sessionContext, false); if (conversationContexts != null) if (currentConversationContext.getConversation().isTransient()) conversationManager = conversationManager != null ? conversationManager : webBeansContext.getConversationManager(); conversationManager.destroyConversationContext(currentConversationContext);
private void startConversationContext() { ConversationManager conversationManager = webBeansContext.getConversationManager(); ConversationContext ctx = conversationManager.getConversationContext(getCurrentSessionContext()); ctx.setActive(true); conversationContext.set(ctx); if (ctx.getConversation().isTransient()) { webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( conversationManager.getLifecycleEventPayload(ctx), InitializedLiteral.INSTANCE_CONVERSATION_SCOPED); } }
ConversationManager conversationManager = webBeansContext.getConversationManager(); ConversationContext conversationContext = (ConversationContext) webBeansContext.getContextsService().getCurrentContext(ConversationScoped.class); conversationManager.addToConversationStorage(conversationContext, id);
private Context getCurrentConversationContext() { ConversationContext conversationCtx = conversationContext.get(); if (conversationCtx == null) { conversationCtx = webBeansContext.getConversationManager().getConversationContext(getCurrentSessionContext()); conversationContext.set(conversationCtx); // check for busy and non-existing conversations String conversationId = webBeansContext.getConversationService().getConversationId(); if (conversationId != null && conversationCtx.getConversation().isTransient()) { throw new NonexistentConversationException("Propogated conversation with cid=" + conversationId + " cannot be restored. It creates a new transient conversation."); } if (conversationCtx.getConversation().iUseIt() > 1) { //Throw Busy exception throw new BusyConversationException("Propogated conversation with cid=" + conversationId + " is used by other request. It creates a new transient conversation"); } } return conversationCtx; }
/** * {@inheritDoc} */ @Override public String getActionURL(FacesContext context, String viewId) { if(!isOwbApplication()) { return delegate.getActionURL(context, viewId); } String url = delegate.getActionURL(context, viewId); ConversationManager conversationManager = WebBeansContext.getInstance().getConversationManager(); Conversation conversation = conversationManager.getConversationBeanReference(); if (conversation != null && !conversation.isTransient()) { url = JSFUtil.getRedirectViewIdWithCid(url, conversation.getId()); } return url; }
/** * {@inheritDoc} */ @Override public String getActionURL(FacesContext context, String viewId) { if(!isOwbApplication()) { return delegate.getActionURL(context, viewId); } String url = delegate.getActionURL(context, viewId); ConversationManager conversationManager = WebBeansContext.getInstance().getConversationManager(); Conversation conversation = conversationManager.getConversationBeanReference(); if (conversation != null && !conversation.isTransient()) { url = JSFUtil.getRedirectViewIdWithCid(url, conversation.getId()); } return url; }
private void cleanupConversation() { if (webBeansContext.getService(ConversationService.class) == null) { return; } final ConversationContext conversationContext = getConversationContext(); if (conversationContext == null) { return; } final ConversationManager conversationManager = webBeansContext.getConversationManager(); final Conversation conversation = conversationManager.getConversationBeanReference(); if (conversation == null) { return; } if (conversation.isTransient()) { webBeansContext.getContextsService().endContext(ConversationScoped.class, null); } else { final ConversationImpl conversationImpl = (ConversationImpl) conversation; conversationImpl.updateTimeOut(); conversationImpl.setInUsed(false); } }