Package org.apache.myfaces.orchestra.conversation

Examples of org.apache.myfaces.orchestra.conversation.Conversation


    }

    Iterator iterConversations = conversationManager.iterateConversations();
    while (iterConversations.hasNext())
    {
      Conversation conversation = (Conversation) iterConversations.next();
     
      // This conversation has "flash" scope if it has an attached Aspect
      // of type ConversationFlashLifetimeAspect. All other conversations
      // are not flash-scoped and should be ignored here.
      ConversationFlashLifetimeAspect aspect =
        (ConversationFlashLifetimeAspect)
          conversation.getAspect(ConversationFlashLifetimeAspect.class);

      if (aspect != null && !aspect.isAccessed())
      {
        conversation.invalidate();
      }
    }
  }
View Full Code Here


  protected Object getBean(String beanName, ObjectFactory objectFactory)
  {
    String conversationName = getConversationNameForBean(beanName);

    ConversationManager manager = ConversationManager.getInstance();
    Conversation conversation;

    // check if we have a conversation
    synchronized(manager)
    {
      conversation = manager.getConversation(conversationName);
      if (conversation == null)
      {
        // Start the conversation. This eventually results in a
        // callback to the createConversation method on this class.
        conversation = manager.startConversation(conversationName, this);
      }
      else
      {
                assertSameScope(beanName, conversation);
            }
    }

    // get the conversation
    notifyAccessConversation(conversation);
    synchronized(conversation)
    {
      if (!conversation.hasAttribute(beanName))
      {
        // create the bean (if not already done)
        Object value = objectFactory.getObject();

        ProxyFactory factory = new ProxyFactory(value);
        factory.setProxyTargetClass(true);
        factory.addAdvice(new CurrentConversationAdvice(conversation, beanName));

        if (advices != null && advices.length > 0)
        {
          for (int i = 0; i < advices.length; i++)
          {
            factory.addAdvice(advices[i]);
          }
        }

        value = factory.getProxy();

        conversation.setAttribute(beanName, value);
      }
    }

    // get the bean
    return conversation.getAttribute(beanName);
  }
View Full Code Here

      {
        public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
        {
          if (bean instanceof ConversationAware)
          {
            Conversation conversation = getConversationForBean(beanName);

            ((ConversationAware) bean).setConversation(conversation);
          }

          return bean;
View Full Code Here

   * Get the conversation for the given beanName.
   */
  protected Conversation getConversationForBean(String beanName)
  {
    ConversationManager manager = ConversationManager.getInstance();
    Conversation conversation = manager.getConversation(getConversationNameForBean(beanName));
    return conversation;
  }
View Full Code Here

   * <p>
   * This ensures it will be called during conversation destroy.
   */
  public void registerDestructionCallback(String name, final Runnable runnable)
  {
    Conversation conversation = getConversationForBean(name);
    conversation.setAttribute(
      runnable.getClass().getName() + "@" + System.identityHashCode(runnable),
      new ConversationBindingListener()
      {
        public void valueBound(ConversationBindingEvent event)
        {
View Full Code Here

  public Object invoke(MethodInvocation methodInvocation) throws Throwable
  {
    PersistenceContext persistenceContext = null;

    Conversation conversation = Conversation.getCurrentInstance();
    if (conversation != null)
    {
      PersistenceContextCloser persistenceContextCloser = (PersistenceContextCloser) conversation.getAttribute(PERSISTENCE_CONTEXT_CONV_ATTRIBUTE);
      if (persistenceContextCloser != null)
      {
        persistenceContext = persistenceContextCloser.getPersistenceContext();
      }

      if (persistenceContext == null)
      {
        persistenceContext = persistenceContextFactory.create();

        conversation.setAttribute(PERSISTENCE_CONTEXT_CONV_ATTRIBUTE, new PersistenceContextCloser(persistenceContext));
      }
    }

    if (persistenceContext != null)
    {
View Full Code Here

  /**
   * Implementation of ConversationFactory interface.
   */
  public Conversation createConversation(ConversationContext context, String name)
  {
    Conversation conversation = new Conversation(context, name, this);

    // invoke child scope classes so they can add any aspects they desire.
    initAspects(conversation);

    return conversation;
View Full Code Here

   * end and restart a conversation
   */
  public static void endAndRestartConversation(FacesContext context, String conversationName, Boolean restart, MethodBinding restartAction)
  {
    ConversationManager conversationManager = ConversationManager.getInstance();
    Conversation conversation = conversationManager.getConversation(conversationName);
    if (conversation != null)
    {
      conversation.invalidate();
    }

    if (restart != null && restart.booleanValue())
    {
      FrameworkAdapter.getCurrentInstance().getBean(conversationName);
View Full Code Here

        boolean isDebug = log.isDebugEnabled();
        Iterator iterConversations = conversationManager.iterateConversations();
        while (iterConversations.hasNext())
        {
            Conversation conversation = (Conversation) iterConversations.next();
           
            // This conversation has "access" scope if it has an attached Aspect
            // of type ConversationAccessLifetimeAspect. All other conversations
            // are not access-scoped and should be ignored here.
            ConversationAccessLifetimeAspect aspect =
                (ConversationAccessLifetimeAspect)
                    conversation.getAspect(ConversationAccessLifetimeAspect.class);

            if (aspect != null)
            {
                if (aspect.isAccessed())
                {
                    if (isDebug)
                    {
                        log.debug(
                            "Not clearing accessed conversation " + conversation.getName()
                            + " after rendering view " + viewId);
                    }
                }
                else
                {
                    if (isDebug)
                    {
                        log.debug(
                            "Clearing access-scoped conversation " + conversation.getName()
                            + " after rendering view " + viewId);
                    }
                    conversation.invalidate();
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.orchestra.conversation.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.