[seam-commits] Seam SVN: r13695 - in modules/persistence/trunk: api/src/main/java/org/jboss/seam/persistence/transaction and 2 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Sep 2 02:53:34 EDT 2010
Author: swd847
Date: 2010-09-02 02:53:32 -0400 (Thu, 02 Sep 2010)
New Revision: 13695
Added:
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/FlushModeManager.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/FlushModeType.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/PersistenceContexts.java
Removed:
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/FlushModeType.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/PersistenceContexts.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/FlushModeManager.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContexts.java
Modified:
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamManagedPersistenceContextCreated.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamPersistenceProvider.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/TransactionPropagation.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/TransactionScoped.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/DefaultPersistenceProvider.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/FlushModeManagerImpl.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextsImpl.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextFlushModeTest.java
Log:
move classes to API and improve javadoc
Copied: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/FlushModeManager.java (from rev 13694, modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/FlushModeManager.java)
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/FlushModeManager.java (rev 0)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/FlushModeManager.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence;
+
+/**
+ * provides a means of configuring the default flush mode
+ *
+ * TODO: This needs more thought, especially with regard to how it works in with
+ * {@link PersistenceContexts}
+ *
+ * @author Stuart Douglas
+ *
+ */
+public interface FlushModeManager
+{
+ /**
+ *
+ * @return the default flush mode for all seam managed persistence contexts
+ */
+ public FlushModeType getFlushModeType();
+
+ public void setFlushModeType(FlushModeType flushModeType);
+}
Copied: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/FlushModeType.java (from rev 13694, modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/FlushModeType.java)
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/FlushModeType.java (rev 0)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/FlushModeType.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -0,0 +1,42 @@
+package org.jboss.seam.persistence;
+
+/**
+ * A full set of flush modes, including MANUAL,
+ * which is a glaring missing feature of the JPA
+ * spec.
+ *
+ * @author Gavin King
+ *
+ */
+public enum FlushModeType
+{
+
+ /**
+ * Flushing never occurs automatically, all changes are queued
+ * until the application calls flush() explicitly.
+ */
+ MANUAL,
+
+ /**
+ * Flushing occurs automatically at commit time and when necessary
+ * before query executions.
+ */
+ AUTO,
+
+ /**
+ * Flushing occurs automatically at transaction commit time.
+ */
+ COMMIT;
+
+ /**
+ * Does this flush mode keep unflushed changes past a
+ * transaction commit?
+ *
+ * @return false for all flush modes except for MANUAL
+ */
+ public boolean dirtyBetweenTransactions()
+ {
+ return this==MANUAL;
+ }
+
+}
Copied: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java (from rev 13694, modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java)
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java (rev 0)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+/**
+ * Support for additional operations for all seam managed persistence contexts.
+ *
+ *
+ * @author Gavin King
+ * @author Stuart Douglas
+ *
+ */
+public interface ManagedPersistenceContext
+{
+ /**
+ * changes the flush mode of the persistence context. This allows changing
+ * the flush mode to @{link FlushModeType#MANUAL} provided the underlying
+ * {@link SeamPersistenceProvider} supports it.
+ *
+ * @param flushMode the new flush mode
+ */
+ public void changeFlushMode(FlushModeType flushMode);
+
+ /**
+ *
+ * @return the persistence contexts qualifiers
+ */
+ public Set<Annotation> getQualifiers();
+
+ /**
+ * Returns the type of this persistence context. For JPA persistence contexts
+ * this will be <code>javax.persistence.EntityManager</code>. For pure
+ * hibernate PC's this will be <code>org.hibernate.Session</code>
+ *
+ */
+ public Class<?> getBeanType();
+
+ /**
+ * Returns the appropriate {@link SeamPersistenceProvider} implementation for
+ * this persistence context.
+ *
+ */
+ public SeamPersistenceProvider getProvider();
+
+ /**
+ * Closes the persistence context after the current transaction has
+ * completed.
+ *
+ * If no transaction is active the PC will be closed immediately
+ */
+ public void closeAfterTransaction();
+
+}
Copied: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/PersistenceContexts.java (from rev 13694, modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/PersistenceContexts.java)
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/PersistenceContexts.java (rev 0)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/PersistenceContexts.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -0,0 +1,41 @@
+package org.jboss.seam.persistence;
+
+
+/**
+ * PersistenceContexts tracks active persistence contexts within a conversation.
+ *
+ * This allows for features such as changing the flush mode of all entity
+ * managers to @{link {@link FlushModeType#MANUAL} during the render response
+ * phase when using seam managed transactions in JSF
+ *
+ */
+public interface PersistenceContexts
+{
+
+ public abstract FlushModeType getFlushMode();
+
+ /**
+ * Changes the flush mode of all persistence contexts in the conversation
+ *
+ * @param flushMode the new flush mode
+ */
+ public abstract void changeFlushMode(FlushModeType flushMode);
+
+ /**
+ * Restore the previous flush mode if the current flush mode is marked as
+ * temporary.
+ */
+ public abstract void restoreFlushMode();
+
+ /**
+ * Perform
+ */
+ public abstract void beforeRender();
+
+ public abstract void afterRender();
+
+ public abstract void touch(ManagedPersistenceContext context);
+
+ public abstract void untouch(ManagedPersistenceContext context);
+
+}
\ No newline at end of file
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamManagedPersistenceContextCreated.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamManagedPersistenceContextCreated.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamManagedPersistenceContextCreated.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -22,11 +22,13 @@
package org.jboss.seam.persistence;
import javax.persistence.EntityManager;
+
/**
- * event that is fired when the SMPC is created
+ * event that is fired when the SMPC is created. This allows you to configure
+ * the SMPC before it is used, e.g. by enabling hibernate filters
*
* @author Stuart Douglas <stuart at baileyroberts.com.au>
- *
+ *
*/
public class SeamManagedPersistenceContextCreated
{
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamPersistenceProvider.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamPersistenceProvider.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamPersistenceProvider.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -1,20 +1,22 @@
package org.jboss.seam.persistence;
-import java.lang.reflect.Method;
import java.util.Set;
import javax.persistence.EntityManager;
import javax.transaction.Synchronization;
-import org.jboss.seam.persistence.transaction.FlushModeType;
-
/**
* The interface can be implemented to provide extra functionality to a seam
* managed persistence context.
*
- * seam-persistence contains a default implementation and a hinbernate based
+ * seam-persistence contains a default implementation and a hibernate based
* implementation.
*
+ * Persistence providers are services rather than beans. Injection etc is not
+ * availible and the implementations classes must be listed in
+ *
+ * META-INF/services/org.jboss.seam.persistence.SeamPersistenceProvider
+ *
* @author Stuart Douglas
*
*/
@@ -87,14 +89,6 @@
public abstract void checkVersion(Object bean, EntityManager entityManager, Object oldVersion, Object version);
/**
- * Enable a Filter. This is here just especially for Hibernate, since we well
- * know that other products don't have such cool features.
- *
- * public void enableFilter(Filter filter, EntityManager entityManager) {
- * throw new UnsupportedOperationException("Use of filters requires Hibernate as the persistence provider. Please use Hibernate or remove the filters configuration."
- * ); }
- */
- /**
* Register a Synchronization with the current transaction.
*/
public abstract boolean registerSynchronization(Synchronization sync, EntityManager entityManager);
@@ -116,12 +110,4 @@
*/
public abstract Class<?> getBeanClass(Object bean);
- public abstract Method getPostLoadMethod(Object bean, EntityManager entityManager);
-
- public abstract Method getPrePersistMethod(Object bean, EntityManager entityManager);
-
- public abstract Method getPreUpdateMethod(Object bean, EntityManager entityManager);
-
- public abstract Method getPreRemoveMethod(Object bean, EntityManager entityManager);
-
}
\ No newline at end of file
Deleted: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/FlushModeType.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/FlushModeType.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/FlushModeType.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -1,42 +0,0 @@
-package org.jboss.seam.persistence.transaction;
-
-/**
- * A full set of flush modes, including MANUAL,
- * which is a glaring missing feature of the JPA
- * spec.
- *
- * @author Gavin King
- *
- */
-public enum FlushModeType
-{
-
- /**
- * Flushing never occurs automatically, all changes are queued
- * until the application calls flush() explicitly.
- */
- MANUAL,
-
- /**
- * Flushing occurs automatically at commit time and when necessary
- * before query executions.
- */
- AUTO,
-
- /**
- * Flushing occurs automatically at transaction commit time.
- */
- COMMIT;
-
- /**
- * Does this flush mode keep unflushed changes past a
- * transaction commit?
- *
- * @return false for all flush modes except for MANUAL
- */
- public boolean dirtyBetweenTransactions()
- {
- return this==MANUAL;
- }
-
-}
Deleted: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/PersistenceContexts.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/PersistenceContexts.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/PersistenceContexts.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -1,23 +0,0 @@
-package org.jboss.seam.persistence.transaction;
-
-
-public interface PersistenceContexts
-{
-
- public abstract FlushModeType getFlushMode();
-
- public abstract void changeFlushMode(FlushModeType flushMode);
-
- public abstract void changeFlushMode(FlushModeType flushMode, boolean temporary);
-
- /**
- * Restore the previous flush mode if the current flush mode is marked as
- * temporary.
- */
- public abstract void restoreFlushMode();
-
- public abstract void beforeRender();
-
- public abstract void afterRender();
-
-}
\ No newline at end of file
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -7,10 +7,16 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import javax.ejb.ApplicationException;
+
/**
* Seam Annotation for identifying an Exception class as an Application
- * Exception, which does not cause a transaction rollback
+ * Exception, which does not cause a transaction rollback.
*
+ * This will NOT control the behaviour of EJB container managed transactions. To
+ * avoid confusion, it is recommended that this annotation is only used outside
+ * an EE environment when @{link {@link ApplicationException} is not availible.
+ *
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/TransactionPropagation.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/TransactionPropagation.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/TransactionPropagation.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -26,7 +26,25 @@
*/
public enum TransactionPropagation
{
- REQUIRED, SUPPORTS, MANDATORY, NEVER;
+ /**
+ * A transaction will be started if one is not currently active.
+ */
+ REQUIRED,
+ /**
+ * A transaction will not be started if there is not one currently active,
+ * however this method supports running inside an existing transaction
+ */
+ SUPPORTS,
+ /**
+ * Requires a transaction to be active. If no transaction is active an
+ * {@link IllegalStateException} is thrown
+ */
+ MANDATORY,
+ /**
+ * Requires no transaction to be active. If a transaction is active an
+ * {@link IllegalStateException} is thrown
+ */
+ NEVER;
public boolean isNewTransactionRequired(boolean transactionActive)
{
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/TransactionScoped.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/TransactionScoped.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/TransactionScoped.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -30,6 +30,7 @@
import javax.enterprise.context.NormalScope;
/**
+ * CDI Scope that spans the current transaction
*
* @author Stuart Douglas
*
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/DefaultPersistenceProvider.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/DefaultPersistenceProvider.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/DefaultPersistenceProvider.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -31,7 +31,6 @@
import javax.persistence.OptimisticLockException;
import javax.transaction.Synchronization;
-import org.jboss.seam.persistence.transaction.FlushModeType;
import org.jboss.weld.extensions.defaultbean.DefaultBean;
/**
Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/FlushModeManager.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/FlushModeManager.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/FlushModeManager.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.persistence;
-
-import org.jboss.seam.persistence.transaction.FlushModeType;
-
-/**
- * provides a means of configuring the default flush mode
- *
- * @author Stuart Douglas
- *
- */
-public interface FlushModeManager
-{
- /**
- *
- * @return the default flush mode for all seam managed persistence contexts
- */
- public FlushModeType getFlushModeType();
-
- public void setFlushModeType(FlushModeType flushModeType);
-}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/FlushModeManagerImpl.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/FlushModeManagerImpl.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/FlushModeManagerImpl.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -25,7 +25,6 @@
import javax.enterprise.context.ApplicationScoped;
-import org.jboss.seam.persistence.transaction.FlushModeType;
import org.jboss.weld.extensions.defaultbean.DefaultBean;
/**
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -12,7 +12,6 @@
import org.hibernate.Session;
import org.hibernate.TransientObjectException;
import org.hibernate.proxy.HibernateProxy;
-import org.jboss.seam.persistence.transaction.FlushModeType;
import org.jboss.weld.extensions.util.Reflections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.persistence;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-import org.jboss.seam.persistence.transaction.FlushModeType;
-
-/**
- * Support for changing flushmodes for an existing persistence context.
- *
- * @author Gavin King
- * @author Stuart Douglas
- *
- */
-public interface ManagedPersistenceContext
-{
- public void changeFlushMode(FlushModeType flushMode);
-
- public Set<Annotation> getQualifiers();
-
- public Class<?> getBeanType();
-
- public SeamPersistenceProvider getProvider();
-
- public void setClosed();
-
-}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -124,7 +124,7 @@
public void destroy(Bean<EntityManager> bean, EntityManager em, CreationalContext<EntityManager> arg1)
{
- ((ManagedPersistenceContext)em).setClosed();
+ ((ManagedPersistenceContext)em).closeAfterTransaction();
arg1.release();
try
{
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -35,7 +35,6 @@
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
-import org.jboss.seam.persistence.transaction.FlushModeType;
import org.jboss.seam.persistence.transaction.SeamTransaction;
import org.jboss.seam.persistence.transaction.literal.DefaultTransactionLiteral;
import org.jboss.seam.persistence.util.InstanceResolver;
@@ -68,7 +67,7 @@
private final SeamPersistenceProvider provider;
private boolean persistenceContextsTouched = false;
-
+
private boolean closeOnTransactionCommit = false;
static final Logger log = LoggerFactory.getLogger(ManagedPersistenceContextProxyHandler.class);
@@ -107,9 +106,9 @@
{
return provider;
}
- if ("setClosed".equals(method.getName()) && method.getParameterTypes().length == 0)
+ if ("closeAfterTransaction".equals(method.getName()) && method.getParameterTypes().length == 0)
{
- setClosed();
+ closeAfterTransaction();
return null;
}
return super.invoke(proxy, method, args);
@@ -136,7 +135,7 @@
}
}
- private void setClosed()throws SystemException
+ private void closeAfterTransaction() throws SystemException
{
SeamTransaction transaction = userTransactionInstance.get();
if (transaction.isActive())
@@ -151,7 +150,7 @@
}
}
}
-
+
private void changeFushMode(FlushModeType flushModeType)
{
provider.setFlushMode(delegate, flushModeType);
@@ -178,7 +177,7 @@
public void afterCompletion(int status)
{
synchronizationRegistered = false;
- if(closeOnTransactionCommit && delegate.isOpen())
+ if (closeOnTransactionCommit && delegate.isOpen())
{
delegate.close();
}
Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContexts.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContexts.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContexts.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -1,34 +0,0 @@
-package org.jboss.seam.persistence;
-
-import java.util.Set;
-
-import org.jboss.seam.persistence.PersistenceContextsImpl.PersistenceContextDefintition;
-import org.jboss.seam.persistence.transaction.FlushModeType;
-
-public interface PersistenceContexts
-{
- public abstract void create(FlushModeManager manager);
-
- public abstract FlushModeType getFlushMode();
-
- public abstract Set<PersistenceContextDefintition> getTouchedContexts();
-
- public abstract void touch(ManagedPersistenceContext context);
-
- public abstract void untouch(ManagedPersistenceContext context);
-
- public abstract void changeFlushMode(FlushModeType flushMode);
-
- public abstract void changeFlushMode(FlushModeType flushMode, boolean temporary);
-
- /**
- * Restore the previous flush mode if the current flush mode is marked as
- * temporary.
- */
- public abstract void restoreFlushMode();
-
- public abstract void beforeRender();
-
- public abstract void afterRender();
-
-}
\ No newline at end of file
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextsImpl.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextsImpl.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextsImpl.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -12,7 +12,6 @@
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
-import org.jboss.seam.persistence.transaction.FlushModeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -85,15 +84,6 @@
public void changeFlushMode(FlushModeType flushMode)
{
- changeFlushMode(flushMode, false);
- }
-
- public void changeFlushMode(FlushModeType flushMode, boolean temporary)
- {
- if (temporary)
- {
- realFlushMode = this.flushMode;
- }
this.flushMode = flushMode;
changeFlushModes();
}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextFlushModeTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextFlushModeTest.java 2010-09-01 21:35:41 UTC (rev 13694)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextFlushModeTest.java 2010-09-02 06:53:32 UTC (rev 13695)
@@ -37,10 +37,10 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.persistence.FlushModeManager;
+import org.jboss.seam.persistence.FlushModeType;
import org.jboss.seam.persistence.ManagedPersistenceContext;
import org.jboss.seam.persistence.SePersistenceContextExtension;
import org.jboss.seam.persistence.PersistenceContexts;
-import org.jboss.seam.persistence.transaction.FlushModeType;
import org.jboss.seam.persistence.transaction.TransactionExtension;
import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
import org.jboss.seam.persistence.util.NamingUtils;
More information about the seam-commits
mailing list