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

Gavin King gavin.king at jboss.com
Fri Feb 2 09:51:58 EST 2007


  User: gavin   
  Date: 07/02/02 09:51:58

  Modified:    src/main/org/jboss/seam/core  ManagedPersistenceContext.java
  Log:
  fix JBSEAM-760
  
  Revision  Changes    Path
  1.32      +23 -6     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.31
  retrieving revision 1.32
  diff -u -b -r1.31 -r1.32
  --- ManagedPersistenceContext.java	28 Jan 2007 17:42:22 -0000	1.31
  +++ ManagedPersistenceContext.java	2 Feb 2007 14:51:58 -0000	1.32
  @@ -1,17 +1,18 @@
  -//$Id: ManagedPersistenceContext.java,v 1.31 2007/01/28 17:42:22 gavin Exp $
  +//$Id: ManagedPersistenceContext.java,v 1.32 2007/02/02 14:51:58 gavin Exp $
   package org.jboss.seam.core;
   import static org.jboss.seam.InterceptionType.NEVER;
  +
   import java.io.Serializable;
   import java.util.ArrayList;
   import java.util.List;
  +
   import javax.naming.NamingException;
   import javax.persistence.EntityManager;
   import javax.persistence.EntityManagerFactory;
   import javax.servlet.http.HttpSessionActivationListener;
   import javax.servlet.http.HttpSessionEvent;
   import javax.transaction.SystemException;
  -import org.jboss.seam.log.LogProvider;
  -import org.jboss.seam.log.Logging;
  +
   import org.jboss.seam.Component;
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.annotations.Create;
  @@ -20,11 +21,15 @@
   import org.jboss.seam.annotations.Intercept;
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.annotations.Unwrap;
  +import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.contexts.Lifecycle;
   import org.jboss.seam.core.Expressions.ValueBinding;
  +import org.jboss.seam.log.LogProvider;
  +import org.jboss.seam.log.Logging;
   import org.jboss.seam.persistence.PersistenceProvider;
   import org.jboss.seam.util.Naming;
   import org.jboss.seam.util.Transactions;
  +
   /**
    * A Seam component that manages a conversation-scoped extended
    * persistence context that can be shared by arbitrary other
  @@ -101,12 +106,24 @@
      //we can't use @PrePassivate because it is intercept NEVER
      public void sessionWillPassivate(HttpSessionEvent event)
      {
  +      //need to create a context, because this can get called
  +      //outside the JSF request, and we want to use the
  +      //PersistenceProvider object
  +      boolean createContext = !Contexts.isApplicationContextActive();
  +      if (createContext) Lifecycle.beginCall();
  +      try
  +      {
         if ( !PersistenceProvider.instance().isDirty(entityManager) )
         {
            entityManager.close();
            entityManager = null;
         }
      }
  +      finally
  +      {
  +         if (createContext) Lifecycle.endCall();
  +      }
  +   }
      
      //we can't use @PostActivate because it is intercept NEVER
      public void sessionDidActivate(HttpSessionEvent event)
  
  
  



More information about the jboss-cvs-commits mailing list