Package javax.enterprise.context

Examples of javax.enterprise.context.Conversation


  }

  @Override
  public void onRequestHandlerExecuted(RequestCycle cycle, IRequestHandler handler)
  {
    Conversation conversation = getConversation(cycle);

    if (conversation == null)
    {
      return;
    }
View Full Code Here


  @Override
  public void onRequestHandlerScheduled(RequestCycle cycle, IRequestHandler handler)
  {
    // propagate current non-transient conversation to the newly scheduled page

    Conversation conversation = getConversation(cycle);

    if (conversation == null || conversation.isTransient())
    {
      return;
    }

    Page page = getPage(handler);
    if (page != null)
    {
      if (propagation.propagatesViaPage(page, handler))
      {
        // propagate a conversation across non-bookmarkable page instances
        setConversationOnPage(conversation, page);
      }
    }

    if (propagation.propagatesViaParameters(handler))
    {
      // propagate cid to a scheduled bookmarkable page

      logger.debug(
        "Propagating non-transient conversation {} via page parameters of handler {}",
        conversation.getId(), handler);

      PageParameters parameters = getPageParameters(handler);
      if (parameters != null)
      {
        parameters.set(CID, conversation.getId());
      }
    }
  }
View Full Code Here

      {
        return;
      }
    }

    Conversation conversation = getConversation(cycle);

    if (conversation == null || conversation.isTransient())
    {
      return;
    }

    if (propagation.propagatesViaParameters(handler))
    {
      // propagate cid to bookmarkable pages via urls

      logger.debug("Propagating non-transient conversation {} via url", conversation.getId());

      url.setQueryParameter(CID, conversation.getId());
    }
  }
View Full Code Here

  }

  @Override
  public void onDetach(RequestCycle cycle)
  {
    Conversation conversation = getConversation(cycle);
    if (conversation != null)
    {
      logger.debug("Deactivating conversation {}", conversation.getId());

      for (IRequestCycleListener listener : application.getRequestCycleListeners())
      {
        if (listener instanceof ICdiAwareRequestCycleListener)
        {
View Full Code Here

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

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String method = req.getParameter("method");
        if ("cid".equals(method)) {
            Conversation conversation = BeanLookupUtils.getContextualReference(beanManager, Conversation.class);
            serializeToResponse(conversation.getId(), resp);
        } else if ("cloudDestroyed".equals(method)) {
            if (Cloud.isDestroyed()) {
                resp.setStatus(HttpServletResponse.SC_OK);
            } else {
                resp.setStatus(208);
View Full Code Here

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

        return conversation;
    }
View Full Code Here

                return;
            }

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

            if (conversation.isTransient())
            {
                if (logger.isLoggable(Level.FINE))
                {
                    logger.log(Level.FINE, "Destroying the conversation context with cid : [{0}]", conversation.getId());
                }
                ContextFactory contextFactory = webBeansContext.getContextFactory();
                contextFactory.destroyConversationContext();
            }
            else
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))
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

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.