/** * {@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()); }
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 = new ConversationManager(this);
Conversation conversation = conversationManager.getConversationBeanReference(); if (conversation != null && !conversation.isTransient())
/** * Destroy the given ConversationContext and fire the proper * @Destroyed event with the correct payload. */ public void destroyConversationContext(ConversationContext ctx) { webBeansContext.getBeanManagerImpl().fireEvent( getLifecycleEventPayload(ctx), BeforeDestroyedLiteral.INSTANCE_CONVERSATION_SCOPED); ctx.destroy(); webBeansContext.getBeanManagerImpl().fireEvent( getLifecycleEventPayload(ctx), DestroyedLiteral.INSTANCE_CONVERSATION_SCOPED); }
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; }
conversationManager.addConversationContext(conversation, context);
conversationManager.addToConversationStorage(conversationContext, id);
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; }
/** * Get current conversation ctx. * @return conversation context */ public ConversationContext getConversationContext(boolean create, boolean ignoreProblems) { ConversationContext conversationContext = conversationContexts.get(); if (conversationContext == null) { SessionContext sessionContext = getSessionContext(create); if (sessionContext != null) { conversationContext = conversationManager.getConversationContext(sessionContext); conversationContexts.set(conversationContext); if (conversationContext.getConversation().isTransient()) { webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( conversationManager.getLifecycleEventPayload(conversationContext), InitializedLiteral.INSTANCE_CONVERSATION_SCOPED); } if (!ignoreProblems && conversationContext.getConversation().getProblemDuringCreation() != null) { throw conversationContext.getConversation().getProblemDuringCreation(); } } } return 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} */ @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); } }