[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...

Gavin King gavin.king at jboss.com
Thu Nov 16 17:58:13 EST 2006


  User: gavin   
  Date: 06/11/16 17:58:13

  Modified:    src/main/org/jboss/seam/core      Conversation.java
                        ConversationEntry.java Manager.java Page.java
                        Pages.java
  Log:
  JBSEAM-493
  
  Revision  Changes    Path
  1.27      +52 -10    jboss-seam/src/main/org/jboss/seam/core/Conversation.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Conversation.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Conversation.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -b -r1.26 -r1.27
  --- Conversation.java	16 Nov 2006 17:25:04 -0000	1.26
  +++ Conversation.java	16 Nov 2006 22:58:13 -0000	1.27
  @@ -178,26 +178,68 @@
      }
      
      /**
  -    * Start a long-running conversation.
  +    * Start a long-running conversation, if no long-running
  +    * conversation is active.
  +    * 
  +    * @return true if a new long-running conversation was begin
  +    */
  +   public boolean begin()
  +   {
  +      if ( Manager.instance().isLongRunningConversation() )
  +      {
  +         return false;
  +      }
  +      else
  +      {
  +         Manager.instance().beginConversation( Seam.getComponentName(Conversation.class) );
  +         return true;
  +      }
  +   }
  +   
  +   /**
  +    * Start a nested conversation.
  +    * 
  +    * @throws IllegalStateException if no long-running conversation was active
       */
  -   public void begin()
  +   public void beginNested()
      {
  -      begin( Seam.getComponentName(Conversation.class) );
  -      //TODO: let them pass a pageflow name as a request parameter
  +      if ( Manager.instance().isLongRunningConversation() )
  +      {
  +         Manager.instance().beginNestedConversation( Seam.getComponentName(Conversation.class) );
  +      }
  +      else
  +      {
  +         throw new IllegalStateException("beginNested() called with no long-running conversation");
  +      }
      }
      
      /**
  -    * Start a long-running conversation.
  +    * Begin or join a conversation, or begin a new nested conversation.
  +    * 
  +    * @param join if a conversation is active, should we join it?
  +    * @param nested if a conversation is active, should we start a new nested conversation?
       */
  -   public void begin(String componentName)
  +   public void begin(boolean join, boolean nested)
      {
  -      if ( !Manager.instance().isLongRunningConversation() )
  +      boolean longRunningConversation = Manager.instance().isLongRunningConversation();
  +      if ( !join && !nested && longRunningConversation  )
         {
  -         Manager.instance().beginConversation(componentName);
  +         throw new IllegalStateException("begin() called from long-running conversation, try join=true");
  +      }
  +      else if ( !longRunningConversation )
  +      {
  +         begin();
  +      }
  +      else if (nested)
  +      {
  +         beginNested();
         }
  -      //TODO: let them pass a pageflow name as a request parameter
      }
      
  +   /**
  +    * @deprecated use org.jboss.seam.core.Pageflow.begin(String)
  +    * @param pageflowName
  +    */
      public void beginPageflow(String pageflowName)
      {
         Pageflow.instance().begin(pageflowName);
  @@ -304,7 +346,7 @@
      }
      
      /**
  -    * Change the flush mode of all Seam-managed peristence 
  +    * Change the flush mode of all Seam-managed persistence 
       * contexts in this conversation.
       */
      public void changeFlushMode(FlushModeType flushMode)
  
  
  
  1.30      +7 -0      jboss-seam/src/main/org/jboss/seam/core/ConversationEntry.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConversationEntry.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ConversationEntry.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -b -r1.29 -r1.30
  --- ConversationEntry.java	9 Nov 2006 14:17:52 -0000	1.29
  +++ ConversationEntry.java	16 Nov 2006 22:58:13 -0000	1.30
  @@ -154,11 +154,18 @@
         return conversationIdStack;
      }
   
  +   /**
  +    * @deprecated
  +    * @return a component name
  +    */
      public String getInitiatorComponentName() 
      {
         return initiatorComponentName;
      }
   
  +   /**
  +    * @deprecated
  +    */
      void setInitiatorComponentName(String ownerComponentName) {
         entries.setDirty(this.initiatorComponentName, ownerComponentName);
         this.initiatorComponentName = ownerComponentName;
  
  
  
  1.115     +12 -1     jboss-seam/src/main/org/jboss/seam/core/Manager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Manager.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Manager.java,v
  retrieving revision 1.114
  retrieving revision 1.115
  diff -u -b -r1.114 -r1.115
  --- Manager.java	9 Nov 2006 16:18:07 -0000	1.114
  +++ Manager.java	16 Nov 2006 22:58:13 -0000	1.115
  @@ -40,7 +40,7 @@
    *
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.114 $
  + * @version $Revision: 1.115 $
    */
   @Scope(ScopeType.EVENT)
   @Name("org.jboss.seam.core.manager")
  @@ -138,6 +138,8 @@
      /**
       * Get the name of the component that started the current
       * conversation.
  +    * 
  +    * @deprecated
       */
      public Object getCurrentConversationInitiator()
      {
  @@ -602,8 +604,10 @@
       * 
       * @param initiator the name of the component starting the conversation.
       */
  +   @SuppressWarnings("deprecation")
      public void beginConversation(String initiator)
      {
  +      log.debug("Beginning long-running conversation");
         setLongRunningConversation(true);
         createConversationEntry().setInitiatorComponentName(initiator);
         Conversation.instance(); //force instantiation of the Conversation in the outer (non-nested) conversation
  @@ -616,9 +620,15 @@
       * 
       * @param ownerName the name of the component starting the conversation
       */
  +   @SuppressWarnings("deprecation")
      public void beginNestedConversation(String ownerName)
      {
  +      log.debug("Beginning nested conversation");
         List<String> oldStack = getCurrentConversationIdStack();
  +      if (oldStack==null)
  +      {
  +         throw new IllegalStateException("No long-running conversation active");
  +      }
         String id = Id.nextId();
         setCurrentConversationId(id);
         createCurrentConversationIdStack(id).addAll(oldStack);
  @@ -633,6 +643,7 @@
       */
      public void endConversation(boolean beforeRedirect)
      {
  +      log.debug("Ending long-running conversation");
         if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.endConversation");
         setLongRunningConversation(false);
         destroyBeforeRedirect = beforeRedirect;
  
  
  
  1.3       +79 -2     jboss-seam/src/main/org/jboss/seam/core/Page.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Page.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Page.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- Page.java	11 Nov 2006 02:42:11 -0000	1.2
  +++ Page.java	16 Nov 2006 22:58:13 -0000	1.3
  @@ -7,6 +7,7 @@
   import javax.faces.context.FacesContext;
   import javax.faces.convert.Converter;
   
  +import org.jboss.seam.annotations.FlushModeType;
   import org.jboss.seam.core.Expressions.MethodBinding;
   import org.jboss.seam.core.Expressions.ValueBinding;
   
  @@ -99,6 +100,11 @@
      private List<Page.PageParameter> pageParameters = new ArrayList<Page.PageParameter>();
      private boolean isBeginConversation;
      private boolean isEndConversation;
  +   private boolean join;
  +   private boolean nested;
  +   private FlushModeType flushMode;
  +   private String pageflow;
  +   private boolean beforeRedirect;
      
      Page(String viewId)
      {
  @@ -249,7 +255,78 @@
      
      public void beginOrEndConversation()
      {
  -      if ( isEndConversation ) Conversation.instance().end();
  -      if ( isBeginConversation ) Conversation.instance().begin();
  +      if ( isEndConversation )
  +      {
  +         if (beforeRedirect)
  +         {
  +            Conversation.instance().endBeforeRedirect();
  +         }
  +         else
  +         {
  +            Conversation.instance().end();
  +         }
  +      }
  +      if ( isBeginConversation )
  +      {
  +         Conversation.instance().begin(join, nested);
  +         if (flushMode!=null)
  +         {
  +            Conversation.instance().changeFlushMode(flushMode);
  +         }
  +         if (pageflow!=null)
  +         {
  +            Pageflow.instance().begin(pageflow);
  +         }
  +      }
  +   }
  +
  +   protected FlushModeType getFlushMode()
  +   {
  +      return flushMode;
  +   }
  +
  +   protected void setFlushMode(FlushModeType flushMode)
  +   {
  +      this.flushMode = flushMode;
  +   }
  +
  +   protected boolean isJoin()
  +   {
  +      return join;
  +   }
  +
  +   protected void setJoin(boolean join)
  +   {
  +      this.join = join;
  +   }
  +
  +   protected boolean isNested()
  +   {
  +      return nested;
  +   }
  +
  +   protected void setNested(boolean nested)
  +   {
  +      this.nested = nested;
  +   }
  +
  +   protected String getPageflow()
  +   {
  +      return pageflow;
  +   }
  +
  +   protected void setPageflow(String pageflow)
  +   {
  +      this.pageflow = pageflow;
  +   }
  +
  +   protected boolean isBeforeRedirect()
  +   {
  +      return beforeRedirect;
  +   }
  +
  +   protected void setBeforeRedirect(boolean beforeRedirect)
  +   {
  +      this.beforeRedirect = beforeRedirect;
      }
   }
  \ No newline at end of file
  
  
  
  1.48      +14 -2     jboss-seam/src/main/org/jboss/seam/core/Pages.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Pages.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Pages.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -b -r1.47 -r1.48
  --- Pages.java	14 Nov 2006 00:31:27 -0000	1.47
  +++ Pages.java	16 Nov 2006 22:58:13 -0000	1.48
  @@ -25,6 +25,7 @@
   import org.jboss.seam.Component;
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.annotations.Create;
  +import org.jboss.seam.annotations.FlushModeType;
   import org.jboss.seam.annotations.Intercept;
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
  @@ -155,14 +156,25 @@
            }
         }
         
  -      if ( page.elementIterator("end-conversation").hasNext() )
  +      Element endConversation = page.element("end-conversation");
  +      if ( endConversation!=null )
         {
            entry.setEndConversation(true);
  +         entry.setBeforeRedirect( "true".equals( endConversation.attributeValue("before-redirect") ) );
         }
         
  -      if ( page.elementIterator("begin-conversation").hasNext() )
  +      Element beginConversation = page.element("begin-conversation");
  +      if ( beginConversation!=null )
         {
            entry.setBeginConversation(true);
  +         entry.setJoin( "true".equals( beginConversation.attributeValue("join") ) );
  +         entry.setNested( "nested".equals( beginConversation.attributeValue("nested") ) );
  +         entry.setPageflow( beginConversation.attributeValue("pageflow") );
  +         String flushMode = beginConversation.attributeValue("flush-mode");
  +         if (flushMode!=null)
  +         {
  +            entry.setFlushMode( FlushModeType.valueOf( flushMode.toUpperCase() ) );
  +         }
         }
         
         if ( entry.isBeginConversation() && entry.isEndConversation() )
  
  
  



More information about the jboss-cvs-commits mailing list