Package org.apache.webbeans.conversation

Examples of org.apache.webbeans.conversation.ConversationManager


            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());
    }
View Full Code Here


                ((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.");
        }
View Full Code Here

            Map<Conversation, ConversationContext> conversationContextMap =
                    (Map<Conversation, ConversationContext>) bag.get(ATTRIBUTE_CONVERSATION_CONTEXT_MAP);

            if (conversationContextMap != null && !conversationContextMap.isEmpty())
            {
                ConversationManager conversationManager = webBeansContext.getConversationManager();
                Iterator<Conversation> iterator = conversationContextMap.keySet().iterator();

                while (iterator.hasNext())
                {
                    Conversation conversation = iterator.next();
                    ConversationContext context = conversationContextMap.get(conversation);
                    conversationManager.addConversationContext(conversation, context);
                }
            }

            if (LOGGER.isLoggable(Level.FINE))
            {
View Full Code Here

        conversationContext.setActive(true);

        Conversation conversation = new ConversationImpl(session.getId(), getWebBeansContext());
        conversation.begin();

        ConversationManager conversationManager = getWebBeansContext().getConversationManager();
        conversationManager.addConversationContext(conversation, conversationContext);

        getWebBeansContext().registerService(ConversationService.class, new MockConversationService(session, conversation));

        // set sample text
        getInstance(ConversationScopedBean.class, conversationContext).setText(CONVERSATION_SCOPED_SAMPLE_TEXT);

        // store beans in session
        failoverService.sessionIsIdle(session);

        // serialize / deserialize and store deserialized bag back to session
        FailOverBag failOverBag;
        failOverBag = (FailOverBag) session.getAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME);
        failOverBag = (FailOverBag) serialize(failOverBag);

        session.setAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME, failOverBag);

        // remove sample text
        getInstance(ConversationScopedBean.class, conversationContext).setText(null);

        getWebBeansContext().getContextsService().endContext(ConversationScoped.class, conversationContext);

        // restore beans from session
        failoverService.sessionDidActivate(session);



        // ----- assert
        // get and activate conversation
        Map<Conversation, ConversationContext> conversationMap =
                conversationManager.getConversationMapWithSessionId(session.getId());

        Conversation propogatedConversation =
                conversationManager.getPropogatedConversation(conversation.getId(), session.getId());

        ConversationContext propogatedConversationContext =  conversationMap.get(propogatedConversation);
        propogatedConversationContext.setActive(true);

        ConversationScopedBean beanInstance = getInstance(ConversationScopedBean.class, propogatedConversationContext);
View Full Code Here

        {
            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());
    }
View Full Code Here

    {
        // get the session context
        sessionContext = (SessionContext) webBeansContext.getBeanManagerImpl().getContext(SessionScoped.class);

        // get all conversation contexts
        ConversationManager conversationManager = webBeansContext.getConversationManager();
        conversationContextMap = conversationManager.getConversationMapWithSessionId(session.getId());
    }
View Full Code Here

                sessionManager.addNewSessionContext(sessionId, sessionContext);
                sessionContext.setActive(true);
            }
            if (conversationContextMap != null && !conversationContextMap.isEmpty())
            {
                ConversationManager conversationManager = webBeansContext.getConversationManager();
                java.util.Iterator<Conversation> it = conversationContextMap.keySet().iterator();
                while(it.hasNext())
                {
                    Conversation c = it.next();
                    ConversationContext cc = conversationContextMap.get(c);
                    conversationManager.addConversationContext(c, cc);
                }
            }
        }
        catch (Exception e)
        {
View Full Code Here

       
        if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE) ||
                phaseEvent.getFacesContext().getResponseComplete())
        {
            WebBeansContext webBeansContext = WebBeansContext.getInstance();
            ConversationManager conversationManager = webBeansContext.getConversationManager();
            Conversation conversation = conversationManager.getConversationBeanReference();
            ContextFactory contextFactory = webBeansContext.getContextFactory();

            if (conversation.isTransient())
            {
                if (logger.isLoggable(Level.FINE))
View Full Code Here

        {
            //It looks for cid parameter in the JSF request.
            //If request contains cid, then it must restore conversation
            //Otherwise create NonexistentException
            WebBeansContext webBeansContext = WebBeansContext.getInstance();
            ConversationManager conversationManager = webBeansContext.getConversationManager();
            Conversation conversation = conversationManager.getConversationBeanReference();
            String cid = JSFUtil.getConversationId();
            ContextFactory contextFactory = webBeansContext.getContextFactory();

            if (conversation.isTransient())
            {
                if (logger.isLoggable(Level.FINE))
                {
                    logger.log(Level.FINE, "Creating a new transitional conversation with cid : [{0}]", conversation.getId());
                }
                contextFactory.initConversationContext(null);

                //Not restore, throw exception
                if(cid != null && !cid.equals(""))
                {
                    throw new NonexistentConversationException("Propogated conversation with cid=" + cid + " is not restored. It creates a new transient conversation.");
                }
            }
            else
            {
                if (logger.isLoggable(Level.FINE))
                {
                    logger.log(Level.FINE, "Restoring conversation with cid : [{0}]", conversation.getId());
                }

                //Conversation must be used by one thread at a time
                ConversationImpl owbConversation = (ConversationImpl)conversation;
                if(!owbConversation.getInUsed().compareAndSet(false, true))
                {
                    contextFactory.initConversationContext(null);
                    //Throw Busy exception
                    throw new BusyConversationException("Propogated conversation with cid=" + cid + " is used by other request. It creates a new transient conversation");
                }
                else
                {
                    ConversationContext conversationContext = conversationManager.getConversationContext(conversation);
                    contextFactory.initConversationContext(conversationContext);
                }
            }
        }
    }
View Full Code Here

        {
            logger.log(Level.FINE, "Destroying a session with session id : [{0}]", event.getSession().getId());
        }
        this.lifeCycle.getContextService().endContext(SessionScoped.class, event.getSession());

        ConversationManager conversationManager = WebBeansContext.getInstance().getConversationManager();
        conversationManager.destroyConversationContextWithSessionId(event.getSession().getId());
    }
View Full Code Here

TOP

Related Classes of org.apache.webbeans.conversation.ConversationManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.