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

Gavin King gavin.king at jboss.com
Fri Oct 13 01:30:26 EDT 2006


  User: gavin   
  Date: 06/10/13 01:30:26

  Modified:    src/main/org/jboss/seam/core       Conversation.java
                        ManagedHibernateSession.java
                        ManagedPersistenceContext.java
  Added:       src/main/org/jboss/seam/core      
                        PersistenceContextManager.java
                        PersistenceContexts.java
  Removed:     src/main/org/jboss/seam/core       TouchedContexts.java
  Log:
  fixed JBSEAM-369
  
  Revision  Changes    Path
  1.23      +7 -9      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.22
  retrieving revision 1.23
  diff -u -b -r1.22 -r1.23
  --- Conversation.java	10 Oct 2006 21:00:53 -0000	1.22
  +++ Conversation.java	13 Oct 2006 05:30:26 -0000	1.23
  @@ -28,7 +28,6 @@
   public class Conversation implements Serializable {
      
      private Integer timeout;
  -   private FlushModeType flushMode = FlushModeType.AUTO;
      String description;
      String viewId;
   
  @@ -287,14 +286,13 @@
         return redirect();
      }
   
  -   public FlushModeType getFlushMode()
  -   {
  -      return flushMode;
  -   }
  -
  -   public void setFlushMode(FlushModeType flushMode)
  +   /**
  +    * Change the flush mode of all Seam-managed peristence 
  +    * contexts in this conversation.
  +    */
  +   public void changeFlushMode(FlushModeType flushMode)
      {
  -      this.flushMode = flushMode;
  +      PersistenceContexts.instance().changeFlushMode(flushMode);
      }
      
   }
  
  
  
  1.21      +22 -9     jboss-seam/src/main/org/jboss/seam/core/ManagedHibernateSession.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ManagedHibernateSession.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ManagedHibernateSession.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -b -r1.20 -r1.21
  --- ManagedHibernateSession.java	10 Oct 2006 19:37:37 -0000	1.20
  +++ ManagedHibernateSession.java	13 Oct 2006 05:30:26 -0000	1.21
  @@ -1,4 +1,4 @@
  -//$Id: ManagedHibernateSession.java,v 1.20 2006/10/10 19:37:37 gavin Exp $
  +//$Id: ManagedHibernateSession.java,v 1.21 2006/10/13 05:30:26 gavin Exp $
   package org.jboss.seam.core;
   
   import static org.jboss.seam.InterceptionType.NEVER;
  @@ -18,6 +18,7 @@
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.annotations.Create;
   import org.jboss.seam.annotations.Destroy;
  +import org.jboss.seam.annotations.FlushModeType;
   import org.jboss.seam.annotations.Intercept;
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.annotations.Unwrap;
  @@ -32,7 +33,8 @@
    */
   @Scope(ScopeType.CONVERSATION)
   @Intercept(NEVER)
  -public class ManagedHibernateSession implements Serializable, HttpSessionActivationListener, Mutable
  +public class ManagedHibernateSession 
  +   implements Serializable, HttpSessionActivationListener, Mutable, PersistenceContextManager
   {
      
      /** The serialVersionUID */
  @@ -59,7 +61,7 @@
         }
         createSession();
         
  -      TouchedContexts.instance().touch(componentName);
  +      PersistenceContexts.instance().touch(componentName);
         
         if ( log.isDebugEnabled() )
         {
  @@ -78,12 +80,7 @@
            throw new IllegalArgumentException("SessionFactory not found", ne);
         }
         
  -      switch ( Conversation.instance().getFlushMode() )
  -      {
  -         case AUTO: break;
  -         case MANUAL: session.setFlushMode(FlushMode.NEVER); break;
  -         case COMMIT: session.setFlushMode(FlushMode.COMMIT); break;
  -      }
  +      setFlushMode( PersistenceContexts.instance().getFlushMode() );
      }
      
      @Unwrap
  @@ -142,6 +139,22 @@
         return componentName;
      }
      
  +   public void setFlushMode(FlushModeType flushMode)
  +   {
  +      switch (flushMode)
  +      {
  +         case AUTO:
  +            session.setFlushMode(FlushMode.AUTO);
  +            break;
  +         case MANUAL:
  +            session.setFlushMode(FlushMode.NEVER);
  +            break;
  +         case COMMIT:
  +            session.setFlushMode(FlushMode.COMMIT);
  +            break;
  +      }
  +   }
  +   
      public String toString()
      {
         return "ManagedHibernateSession(" + sessionFactoryJndiName + ")";
  
  
  
  1.22      +21 -15    jboss-seam/src/main/org/jboss/seam/core/ManagedPersistenceContext.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ManagedPersistenceContext.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ManagedPersistenceContext.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -b -r1.21 -r1.22
  --- ManagedPersistenceContext.java	12 Oct 2006 08:32:37 -0000	1.21
  +++ ManagedPersistenceContext.java	13 Oct 2006 05:30:26 -0000	1.22
  @@ -1,4 +1,4 @@
  -//$Id: ManagedPersistenceContext.java,v 1.21 2006/10/12 08:32:37 gavin Exp $
  +//$Id: ManagedPersistenceContext.java,v 1.22 2006/10/13 05:30:26 gavin Exp $
   package org.jboss.seam.core;
   
   import static org.jboss.seam.InterceptionType.NEVER;
  @@ -8,7 +8,6 @@
   import javax.naming.NamingException;
   import javax.persistence.EntityManager;
   import javax.persistence.EntityManagerFactory;
  -import javax.persistence.FlushModeType;
   import javax.servlet.http.HttpSessionActivationListener;
   import javax.servlet.http.HttpSessionEvent;
   import javax.transaction.SystemException;
  @@ -35,7 +34,8 @@
    */
   @Scope(ScopeType.CONVERSATION)
   @Intercept(NEVER)
  -public class ManagedPersistenceContext implements Serializable, HttpSessionActivationListener, Mutable
  +public class ManagedPersistenceContext 
  +   implements Serializable, HttpSessionActivationListener, Mutable, PersistenceContextManager
   {
   
      private static final Log log = LogFactory.getLog(ManagedPersistenceContext.class);
  @@ -60,7 +60,7 @@
         
         createEntityManager();
         
  -      TouchedContexts.instance().touch(componentName);
  +      PersistenceContexts.instance().touch(componentName);
         
         if ( log.isDebugEnabled() )
         {
  @@ -79,17 +79,7 @@
            throw new IllegalArgumentException("EntityManagerFactory not found", ne);
         }
         
  -      switch ( Conversation.instance().getFlushMode() )
  -      {
  -         case AUTO: 
  -            break;
  -         case MANUAL:
  -            PersistenceProvider.instance().setFlushModeManual(entityManager); 
  -            break;
  -         case COMMIT: 
  -            entityManager.setFlushMode(FlushModeType.COMMIT); 
  -            break;
  -      }
  +      setFlushMode( PersistenceContexts.instance().getFlushMode() );
      }
   
      @Unwrap
  @@ -154,6 +144,22 @@
         return componentName;
      }
   
  +   public void setFlushMode(org.jboss.seam.annotations.FlushModeType flushMode)
  +   {
  +      switch (flushMode)
  +      {
  +         case AUTO:
  +            entityManager.setFlushMode(javax.persistence.FlushModeType.AUTO);
  +            break;
  +         case COMMIT:
  +            entityManager.setFlushMode(javax.persistence.FlushModeType.COMMIT);
  +            break;
  +         case MANUAL:
  +            PersistenceProvider.instance().setFlushModeManual(entityManager);
  +            break;
  +      }
  +   }
  +   
      public String toString()
      {
         return "ManagedPersistenceContext(" + persistenceUnitJndiName + ")";
  
  
  
  1.1      date: 2006/10/13 05:30:26;  author: gavin;  state: Exp;jboss-seam/src/main/org/jboss/seam/core/PersistenceContextManager.java
  
  Index: PersistenceContextManager.java
  ===================================================================
  package org.jboss.seam.core;
  
  import org.jboss.seam.annotations.FlushModeType;
  
  public interface PersistenceContextManager
  {
     public void setFlushMode(FlushModeType flushMode);
  }
  
  
  
  1.1      date: 2006/10/13 05:30:26;  author: gavin;  state: Exp;jboss-seam/src/main/org/jboss/seam/core/PersistenceContexts.java
  
  Index: PersistenceContexts.java
  ===================================================================
  package org.jboss.seam.core;
  
  import static org.jboss.seam.InterceptionType.NEVER;
  
  import java.io.Serializable;
  import java.util.Collections;
  import java.util.HashSet;
  import java.util.Set;
  
  import org.jboss.seam.Component;
  import org.jboss.seam.ScopeType;
  import org.jboss.seam.annotations.FlushModeType;
  import org.jboss.seam.annotations.Intercept;
  import org.jboss.seam.annotations.Name;
  import org.jboss.seam.annotations.Scope;
  import org.jboss.seam.contexts.Contexts;
  
  @Name("org.jboss.seam.core.persistenceContexts")
  @Scope(ScopeType.CONVERSATION)
  @Intercept(NEVER)
  public class PersistenceContexts extends AbstractMutable implements Serializable
  {
     private Set<String> set = new HashSet<String>();
     private FlushModeType flushMode = FlushModeType.AUTO;
     
     public FlushModeType getFlushMode()
     {
        return flushMode;
     }
     
     public Set<String> getTouchedContexts()
     {
        return Collections.unmodifiableSet(set);
     }
     
     public void touch(String context)
     {
        if ( set.add(context) ) setDirty();
     }
     
     public static PersistenceContexts instance()
     {
        if ( Contexts.isConversationContextActive() )
        {
           return (PersistenceContexts) Component.getInstance(PersistenceContexts.class);
        }
        else
        {
           return null;
        }
     }
  
     public void changeFlushMode(FlushModeType flushMode)
     {
        this.flushMode = flushMode;
        for (String name: set)
        {
           PersistenceContextManager pcm = (PersistenceContextManager) Contexts.getConversationContext().get(name);
           if (pcm!=null)
           {
              pcm.setFlushMode(flushMode);
           }
        }
        
     }
     
  }
  
  
  



More information about the jboss-cvs-commits mailing list