Package javax.enterprise.context

Examples of javax.enterprise.context.Conversation


            } catch (ContextNotActiveException e) {
                activeBeforeApplyRequestValues = false;
            }
        }
        if (event.getPhaseId().equals(PhaseId.RENDER_RESPONSE)) {
            Conversation conversation = beanManager.instance().select(Conversation.class).get();
            HttpServletResponse response = (HttpServletResponse) event.getFacesContext().getExternalContext().getResponse();
            response.addHeader(CID_HEADER_NAME, conversation.getId() == null ? " null" : conversation.getId());
            response.addHeader(LONG_RUNNING_HEADER_NAME, String.valueOf(!conversation.isTransient()));
            response.addHeader(Cloud.RAINED_HEADER_NAME, new Boolean(beanManager.instance().select(Cloud.class).get().isRained()).toString());
            response.addHeader(ACTIVE_BEFORE_APPLY_REQUEST_VALUES_HEADER_NAME, new Boolean(activeBeforeApplyRequestValues).toString());
        }
    }
View Full Code Here


            public void sendRedirect(String path) throws IOException {
                FacesContext context = FacesContext.getCurrentInstance();
                if (context != null) { // this is a JSF request
                    ConversationContext conversationContext = instance(contextId).select(HttpConversationContext.class).get();
                    if (conversationContext.isActive()) {
                        Conversation conversation = conversationContext.getCurrentConversation();
                        if (!conversation.isTransient()) {
                            path = new FacesUrlTransformer(path, context)
                                .toRedirectViewId()
                                .toActionUrl()
                                .appendConversationIdIfNecessary(conversationContext.getParameterName(), conversation.getId())
                                .encode();
                        }
                    }
                }
                super.sendRedirect(path);
View Full Code Here

        // Set a value into Baz1
        Baz baz1 = Utils.getReference(beanManager1, Baz.class);
        baz1.setName("pete");

        // Begin the conversation
        Conversation conversation1 = Utils.getReference(beanManager1, Conversation.class);
        conversation1.begin();

        // refetch the test bean and check it has the right value
        baz1 = Utils.getReference(beanManager1, Baz.class);
        assert baz1.getName().equals("pete");

        // Simulate ending the request (from the POV of the conversation only!)
        assert !conversation1.isTransient();
        String cid = conversation1.getId();
        conversationContext1.invalidate();
        conversationContext1.deactivate();
        conversationContext1.dissociate(request1);

        // and start another, propagating the conversation
        request1 = new BoundRequestImpl(container1.getSessionStore());
        conversationContext1.associate(request1);
        conversationContext1.activate(cid);

        // refetch the test bean and check it has the right value
        baz1 = Utils.getReference(beanManager1, Baz.class);
        assert baz1.getName().equals("pete");
        assert !conversation1.isTransient();

        replicateSession(1, container1, 2, container2);

        use(2);

        // Set up the conversation context
        BoundRequest request2 = new BoundRequestImpl(container2.getSessionStore());
        BoundConversationContext conversationContext2 = Utils.getReference(beanManager2, BoundConversationContext.class);
        conversationContext2.associate(request2);
        conversationContext2.activate(cid);

        Baz baz2 = Utils.getReference(beanManager2, Baz.class);
        assert baz2.getName().equals("pete");

        Conversation conversation2 = Utils.getReference(beanManager2, Conversation.class);
        assert !conversation2.isTransient();

        use(2);
        container2.stopContainer();
        use(1);
        container1.stopContainer();
View Full Code Here

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

    @SuppressWarnings("unchecked")
    public Conversation getConversationBeanReference()
    {
        BeanManager beanManager = webBeansContext.getBeanManagerImpl();
        Bean<Conversation> bean = (Bean<Conversation>)beanManager.getBeans(Conversation.class, new DefaultLiteral()).iterator().next();
        Conversation conversation =(Conversation) beanManager.getReference(bean, Conversation.class, beanManager.createCreationalContext(bean));

        return conversation;
    }
View Full Code Here

             */
            @Override
            public void sendRedirect(String location) throws IOException
            {
                Bean<?> bean = BeanManagerImpl.getManager().resolveByType(Conversation.class, new CurrentLiteral()).iterator().next();
                Conversation conversation = (Conversation)BeanManagerImpl.getManager().getInstance(bean);

                String path = location;

                if (conversation != null)
                {

                    if (conversation.isLongRunning())
                    {
                        // Find JSFish view od of the redirection
                        path = JSFUtil.getRedirectViewId(location);
                        path = JSFUtil.getViewHandler().getActionURL(JSFUtil.getCurrentFacesContext(), path);
                        path = JSFUtil.getExternalContext().encodeActionURL(path + "?cid=" + conversation.getId());
                    }
                }

                super.sendRedirect(path);

View Full Code Here

        {
            return;
        }

        ConversationManager conversationManager = webBeansContext.getConversationManager();
        Conversation conversation = conversationManager.getConversationBeanReference();

        if (conversation == null)
        {
            return;
        }

        if (conversation.isTransient())
        {
            if (logger.wblWillLogDebug())
            {
                logger.debug("Destroying the conversation context with cid : [{0}]", conversation.getId());
            }
            ContextFactory contextFactory = webBeansContext.getContextFactory();
            contextFactory.destroyConversationContext();
        }
        else
View Full Code Here

    @SuppressWarnings("unchecked")
    public Conversation getConversationBeanReference()
    {
        BeanManager beanManager = webBeansContext.getBeanManagerImpl();
        Bean<Conversation> bean = (Bean<Conversation>)beanManager.getBeans(Conversation.class, new DefaultLiteral()).iterator().next();
        Conversation conversation =(Conversation) beanManager.getReference(bean, Conversation.class, beanManager.createCreationalContext(bean));

        return conversation;
    }
View Full Code Here

    if (cid == null && page != null)
    {
      cid = page.getMetaData(CID_KEY);
    }

    Conversation current = getConversation(cycle);
    if (current != null && !Objects.isEqual(current.getId(), cid))
    {
      logger.info("Conversation {} has expired for {}", cid, page);
      throw new ConversationExpiredException(null, cid, page, handler);
    }
View Full Code Here

  }

  private void activateConversationIfNeeded(RequestCycle cycle, IRequestHandler handler,
    String cid)
  {
    Conversation current = getConversation(cycle);

    if (current != null || !activateForHandler(handler))
    {
      return;
    }
View Full Code Here

TOP

Related Classes of javax.enterprise.context.Conversation

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.