[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Fri Feb 2 14:41:36 EST 2007
User: gavin
Date: 07/02/02 14:41:36
Modified: src/main/org/jboss/seam/core
ManagedHibernateSession.java
ManagedPersistenceContext.java
PersistenceContextManager.java
PersistenceContexts.java
Log:
fix handling of active/passivate when no contexts
Revision Changes Path
1.28 +16 -5 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.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- ManagedHibernateSession.java 16 Dec 2006 02:58:10 -0000 1.27
+++ ManagedHibernateSession.java 2 Feb 2007 19:41:36 -0000 1.28
@@ -1,4 +1,4 @@
-//$Id: ManagedHibernateSession.java,v 1.27 2006/12/16 02:58:10 nrichards Exp $
+//$Id: ManagedHibernateSession.java,v 1.28 2007/02/02 19:41:36 gavin Exp $
package org.jboss.seam.core;
import static org.jboss.seam.InterceptionType.NEVER;
@@ -12,8 +12,6 @@
import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionEvent;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
@@ -27,6 +25,8 @@
import org.jboss.seam.annotations.Unwrap;
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.util.Naming;
/**
@@ -53,6 +53,8 @@
private ValueBinding<SessionFactory> sessionFactory;
private List<Filter> filters = new ArrayList<Filter>(0);
+ private FlushModeType flushMode;
+
public boolean clearDirty()
{
return true;
@@ -66,6 +68,9 @@
{
sessionFactoryJndiName = "java:/" + componentName;
}
+
+ flushMode = PersistenceContexts.instance().getFlushMode();
+
createSession();
PersistenceContexts.instance().touch(componentName);
@@ -79,7 +84,7 @@
private void createSession()
{
session = getSessionFactoryFromJndiOrValueBinding().openSession();
- setFlushMode( PersistenceContexts.instance().getFlushMode() );
+ setSessionFlushMode();
for (Filter f: filters)
{
enableFilter(f);
@@ -163,7 +168,13 @@
return componentName;
}
- public void setFlushMode(FlushModeType flushMode)
+ public void changeFlushMode(FlushModeType flushMode)
+ {
+ this.flushMode = flushMode;
+ setSessionFlushMode();
+ }
+
+ public void setSessionFlushMode()
{
switch (flushMode)
{
1.33 +28 -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.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- ManagedPersistenceContext.java 2 Feb 2007 14:51:58 -0000 1.32
+++ ManagedPersistenceContext.java 2 Feb 2007 19:41:36 -0000 1.33
@@ -1,5 +1,6 @@
-//$Id: ManagedPersistenceContext.java,v 1.32 2007/02/02 14:51:58 gavin Exp $
+//$Id: ManagedPersistenceContext.java,v 1.33 2007/02/02 19:41:36 gavin Exp $
package org.jboss.seam.core;
+
import static org.jboss.seam.InterceptionType.NEVER;
import java.io.Serializable;
@@ -17,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.Install;
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Scope;
@@ -52,6 +54,8 @@
private ValueBinding<EntityManagerFactory> entityManagerFactory;
private List<Filter> filters = new ArrayList<Filter>(0);
+ private FlushModeType flushMode;
+
public boolean clearDirty()
{
return true;
@@ -66,6 +70,8 @@
persistenceUnitJndiName = "java:/" + componentName;
}
+ flushMode = PersistenceContexts.instance().getFlushMode(); //can't do this inside createEntityManager()
+
createEntityManager();
PersistenceContexts.instance().touch(componentName);
@@ -86,7 +92,8 @@
private void createEntityManager()
{
entityManager = getEntityManagerFactoryFromJndiOrValueBinding().createEntityManager();
- setFlushMode( PersistenceContexts.instance().getFlushMode() );
+ setEntityManagerFlushMode();
+
for (Filter f: filters)
{
PersistenceProvider.instance().enableFilter(f, entityManager);
@@ -128,11 +135,20 @@
//we can't use @PostActivate because it is intercept NEVER
public void sessionDidActivate(HttpSessionEvent event)
{
+ boolean createContext = !Contexts.isApplicationContextActive();
+ if (createContext) Lifecycle.beginCall();
+ try
+ {
if (entityManager==null)
{
createEntityManager();
}
}
+ finally
+ {
+ if (createContext) Lifecycle.endCall();
+ }
+ }
@Destroy
public void destroy()
@@ -208,7 +224,13 @@
this.filters = filters;
}
- public void setFlushMode(org.jboss.seam.annotations.FlushModeType flushMode)
+ public void changeFlushMode(FlushModeType flushMode)
+ {
+ this.flushMode = flushMode;
+ setEntityManagerFlushMode();
+ }
+
+ public void setEntityManagerFlushMode()
{
switch (flushMode)
{
1.2 +1 -1 jboss-seam/src/main/org/jboss/seam/core/PersistenceContextManager.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PersistenceContextManager.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/PersistenceContextManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- PersistenceContextManager.java 13 Oct 2006 05:30:26 -0000 1.1
+++ PersistenceContextManager.java 2 Feb 2007 19:41:36 -0000 1.2
@@ -4,5 +4,5 @@
public interface PersistenceContextManager
{
- public void setFlushMode(FlushModeType flushMode);
+ public void changeFlushMode(FlushModeType flushMode);
}
1.4 +1 -1 jboss-seam/src/main/org/jboss/seam/core/PersistenceContexts.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PersistenceContexts.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/PersistenceContexts.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- PersistenceContexts.java 21 Dec 2006 02:38:26 -0000 1.3
+++ PersistenceContexts.java 2 Feb 2007 19:41:36 -0000 1.4
@@ -57,7 +57,7 @@
PersistenceContextManager pcm = (PersistenceContextManager) Contexts.getConversationContext().get(name);
if (pcm!=null)
{
- pcm.setFlushMode(flushMode);
+ pcm.changeFlushMode(flushMode);
}
}
More information about the jboss-cvs-commits
mailing list