[seam-commits] Seam SVN: r13598 - in modules/persistence/trunk: impl/src/main/java/org/jboss/seam/persistence and 3 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Aug 11 07:49:40 EDT 2010


Author: swd847
Date: 2010-08-11 07:49:39 -0400 (Wed, 11 Aug 2010)
New Revision: 13598

Added:
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamPersistenceProvider.java
Removed:
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceProvider.java
Modified:
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/AbstractManagedPersistenceContextBeanLifecycle.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/ManagedPersistenceContextProxyHandler.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextProxyHandler.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextsImpl.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EntityTransaction.java
   modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java
   modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java
   modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
   modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java
   modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java
   modules/persistence/trunk/pom.xml
Log:
bug fix and refactoring 


Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/AbstractManagedPersistenceContextBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/AbstractManagedPersistenceContextBeanLifecycle.java	2010-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/AbstractManagedPersistenceContextBeanLifecycle.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -26,6 +26,7 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Proxy;
 
+import javax.enterprise.context.ContextNotActiveException;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
@@ -33,6 +34,9 @@
 import javax.persistence.EntityManagerFactory;
 
 import org.jboss.weld.extensions.bean.BeanLifecycle;
+import org.jboss.weld.extensions.literal.DefaultLiteral;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Class that is responsible for creating and destroying the seam managed
@@ -50,6 +54,10 @@
 
    private final BeanManager manager;
 
+   private static final Logger log = LoggerFactory.getLogger(AbstractManagedPersistenceContextBeanLifecycle.class);
+
+   private PersistenceContexts persistenceContexts;
+
    protected AbstractManagedPersistenceContextBeanLifecycle(BeanManager manager)
    {
       this.manager = manager;
@@ -76,7 +84,7 @@
       {
          EntityManagerFactory emf = getEntityManagerFactory();
          EntityManager entityManager = emf.createEntityManager();
-         ManagedPersistenceContextProxyHandler handler = new ManagedPersistenceContextProxyHandler(entityManager, manager, bean.getQualifiers());
+         ManagedPersistenceContextProxyHandler handler = new ManagedPersistenceContextProxyHandler(entityManager, manager, bean.getQualifiers(), getPersistenceContexts());
          EntityManager proxy = (EntityManager) proxyConstructor.newInstance(handler);
          return proxy;
       }
@@ -90,8 +98,27 @@
    {
       em.close();
       arg1.release();
+      try
+      {
+         getPersistenceContexts().untouch((PersistenceContext) em);
+      }
+      catch (ContextNotActiveException e)
+      {
+         log.debug("Could not untouch PersistenceContext as conversation scope not active");
+      }
    }
 
    protected abstract EntityManagerFactory getEntityManagerFactory();
 
+   private PersistenceContexts getPersistenceContexts()
+   {
+      if (persistenceContexts == null)
+      {
+         Bean<PersistenceContexts> bean = (Bean) manager.resolve(manager.getBeans(PersistenceContexts.class, DefaultLiteral.INSTANCE));
+         CreationalContext<PersistenceContexts> ctx = manager.createCreationalContext(bean);
+         persistenceContexts = (PersistenceContexts) manager.getReference(bean, PersistenceContexts.class, ctx);
+      }
+      return persistenceContexts;
+   }
+
 }

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-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -29,7 +29,7 @@
  * @author Stuart Douglas
  * 
  */
-public class HibernatePersistenceProvider extends PersistenceProvider
+public class HibernatePersistenceProvider extends SeamPersistenceProvider
 {
 
    @Inject

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-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -28,6 +28,7 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.enterprise.context.ContextNotActiveException;
 import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.persistence.EntityManager;
@@ -61,14 +62,19 @@
 
    private transient boolean synchronizationRegistered;
 
+   private final PersistenceContexts persistenceContexts;
+
+   private boolean persistenceContextsTouched = false;
+
    static final Logger log = LoggerFactory.getLogger(ManagedPersistenceContextProxyHandler.class);
 
-   public ManagedPersistenceContextProxyHandler(EntityManager delegate, BeanManager beanManager, Set<Annotation> qualifiers)
+   public ManagedPersistenceContextProxyHandler(EntityManager delegate, BeanManager beanManager, Set<Annotation> qualifiers, PersistenceContexts persistenceContexts)
    {
       super(delegate, beanManager, qualifiers);
       this.delegate = delegate;
       this.userTransactionInstance = InstanceResolver.getInstance(SeamTransaction.class, beanManager, DefaultTransactionLiteral.INSTANCE);
       this.qualifiers = new HashSet<Annotation>(qualifiers);
+      this.persistenceContexts = persistenceContexts;
    }
 
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
@@ -77,6 +83,7 @@
       {
          joinTransaction();
       }
+      touch((PersistenceContext) proxy);
       return super.invoke(proxy, method, args);
    }
 
@@ -101,6 +108,22 @@
       }
    }
 
+   void touch(PersistenceContext delegate)
+   {
+      if (!persistenceContextsTouched)
+      {
+         try
+         {
+            persistenceContexts.touch(delegate);
+            persistenceContextsTouched = true;
+         }
+         catch (ContextNotActiveException e)
+         {
+            log.debug("Not touching pc " + this + "as conversation scope not active");
+         }
+      }
+   }
+
    public void afterCompletion(int status)
    {
       synchronizationRegistered = false;
@@ -110,4 +133,5 @@
    {
 
    }
+
 }

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextProxyHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextProxyHandler.java	2010-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextProxyHandler.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -55,7 +55,7 @@
 
    private final Instance<Expressions> expressionsInstance;
 
-   private final Instance<PersistenceProvider> persistenceProvider;
+   private final Instance<SeamPersistenceProvider> persistenceProvider;
 
    private final Set<Annotation> qualifiers;
 
@@ -65,7 +65,7 @@
    {
       this.delegate = delegate;
       expressionsInstance = InstanceResolver.getInstance(Expressions.class, beanManager);
-      persistenceProvider = InstanceResolver.getInstance(PersistenceProvider.class, beanManager);
+      persistenceProvider = InstanceResolver.getInstance(SeamPersistenceProvider.class, beanManager);
       this.qualifiers = new HashSet<Annotation>(qualifiers);
    }
 

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-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextsImpl.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -47,7 +47,7 @@
    Instance<PersistenceContext> persistenceContexts;
 
    @Inject
-   Instance<PersistenceProvider> persistenceProvider;
+   Instance<SeamPersistenceProvider> persistenceProvider;
 
    @Inject
    public void create(FlushModeManager manager)

Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceProvider.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceProvider.java	2010-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceProvider.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -1,267 +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.reflect.Method;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.persistence.EntityManager;
-import javax.persistence.OptimisticLockException;
-import javax.persistence.PersistenceContexts;
-import javax.transaction.Synchronization;
-
-import org.jboss.seam.persistence.transaction.FlushModeType;
-
-/**
- * Abstraction layer for persistence providers (JPA implementations). This class
- * provides a working base implementation that can be optimized for performance
- * and non-standardized features by extending and overriding the methods.
- * 
- * The methods on this class are a great todo list for the next rev of the JPA
- * spec ;-)
- * 
- * @author Gavin King
- * @author Pete Muir
- * @author Stuart Douglas
- * 
- */
-public class PersistenceProvider
-{
-   public enum Feature
-   {
-      /**
-       * Identifies whether this JPA provider supports using a wildcard as the
-       * subject of a count query.
-       * 
-       * <p>
-       * Here's a count query that uses a wildcard as the subject.
-       * </p>
-       * 
-       * <pre>
-       * select count(*) from Vehicle v
-       * </pre>
-       * <p>
-       * Per the JPA 1.0 spec, using a wildcard as a subject of a count query is
-       * not permitted. Instead, the subject must be the entity or the alias, as
-       * in this count query:
-       * </p>
-       * 
-       * <pre>
-       * select count(v) from Vehicle v
-       * </pre>
-       * <p>
-       * Hibernate supports the wildcard syntax as an vendor extension.
-       * Furthermore, Hibernate produces an invalid SQL query when using the
-       * compliant subject if the entity has a composite primary key. Therefore,
-       * we prefer to use the wildcard syntax if it is supported.
-       * </p>
-       */
-      WILDCARD_AS_COUNT_QUERY_SUBJECT
-   }
-
-   protected Set<Feature> featureSet = new HashSet<Feature>();
-
-   /**
-    * Indicate whether this JPA provider supports the feature defined by the
-    * provided Feature enum value.
-    */
-   public boolean supportsFeature(Feature feature)
-   {
-      return featureSet.contains(feature);
-   }
-
-   /**
-    * sets the flush mode
-    */
-   public void setFlushMode(EntityManager entityManager, FlushModeType type)
-   {
-      switch (type)
-      {
-      case AUTO:
-         entityManager.setFlushMode(javax.persistence.FlushModeType.AUTO);
-         break;
-      case COMMIT:
-         entityManager.setFlushMode(javax.persistence.FlushModeType.COMMIT);
-      case MANUAL:
-         setFlushModeManual(entityManager);
-      default:
-         throw new RuntimeException("Unkown flush mode: " + type);
-      }
-   }
-
-   /**
-    * Set the flush mode to manual-only flushing. Called when an atomic
-    * persistence context is required.
-    */
-   public void setFlushModeManual(EntityManager entityManager)
-   {
-      throw new UnsupportedOperationException("Use of FlushMode.MANUAL requires Hibernate as the persistence provider. Please use Hibernate, a custom persistenceProvider, or remove the MANUAL flush mode setting.");
-   }
-
-   /**
-    * <p>
-    * Set the FlushMode the persistence contexts should use during rendering by
-    * calling {@link PersistenceContexts#changeFlushMode(FlushModeType, true)}.
-    * The actual changing of the flush mode is handled by the
-    * {@link PersistenceContexts} instance. The boolean argument should be true
-    * to indicate that this is a temporary change and that the old flush mode
-    * should be restored after render.
-    * </p>
-    * <p>
-    * Ideally, this should be MANUAL since changes should never flush to the
-    * database while in render response and the cost of a dirty check can be
-    * avoided. However, since the MANUAL mode is not officially part of the JPA
-    * specification, the default implementation will perform no operation.
-    * </p>
-    */
-   public void setRenderFlushMode()
-   {
-      // no-op in default implementation
-   }
-
-   /**
-    * Does the persistence context have unflushed changes? If it does not,
-    * persistence context replication can be optimized.
-    * 
-    * @return true to indicate that there are unflushed changes
-    */
-   public boolean isDirty(EntityManager entityManager)
-   {
-      return true; // best we can do!
-   }
-
-   /**
-    * Get the value of the entity identifier attribute.
-    * 
-    * @param bean a managed entity instance
-    */
-   public Object getId(Object bean, EntityManager entityManager)
-   {
-      // return Entity.forBean(bean).getIdentifier(bean);
-      return null;
-   }
-
-   /**
-    * Get the name of the entity
-    * 
-    * @param bean
-    * @param entityManager
-    * 
-    * @throws IllegalArgumentException if the passed object is not an entity
-    */
-   public String getName(Object bean, EntityManager entityManager) throws IllegalArgumentException
-   {
-      return null;
-      // return Entity.forBean(bean).getName();
-   }
-
-   /**
-    * Get the value of the entity version attribute.
-    * 
-    * @param bean a managed entity instance
-    */
-   public Object getVersion(Object bean, EntityManager entityManager)
-   {
-      return null;
-      // return Entity.forBean(bean).getVersion(bean);
-   }
-
-   public void checkVersion(Object bean, EntityManager entityManager, Object oldVersion, Object version)
-   {
-      boolean equal;
-      if (oldVersion instanceof Date)
-      {
-         equal = ((Date) oldVersion).getTime() == ((Date) version).getTime();
-      }
-      else
-      {
-         equal = oldVersion.equals(version);
-      }
-      if (!equal)
-      {
-         throw new OptimisticLockException("Current database version number does not match passivated version number");
-      }
-   }
-
-   /**
-    * 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 boolean registerSynchronization(Synchronization sync, EntityManager entityManager)
-   {
-      return false; // best we can do!
-   }
-
-   /**
-    * Wrap the delegate before returning it to the application
-    */
-   public Object proxyDelegate(Object delegate)
-   {
-      return delegate;
-   }
-
-   /**
-    * Returns the class of an entity bean instance
-    * 
-    * @param bean The entity bean instance
-    * @return The class of the entity bean
-    */
-   public Class getBeanClass(Object bean)
-   {
-      return null;
-      // return Entity.forBean(bean).getBeanClass();
-   }
-
-   public Method getPostLoadMethod(Object bean, EntityManager entityManager)
-   {
-      return null;
-      // return Entity.forBean(bean).getPostLoadMethod();
-   }
-
-   public Method getPrePersistMethod(Object bean, EntityManager entityManager)
-   {
-      return null;
-      // return Entity.forBean(bean).getPrePersistMethod();
-   }
-
-   public Method getPreUpdateMethod(Object bean, EntityManager entityManager)
-   {
-      return null;
-      // return Entity.forBean(bean).getPreUpdateMethod();
-   }
-
-   public Method getPreRemoveMethod(Object bean, EntityManager entityManager)
-   {
-      return null;
-      // return Entity.forBean(bean).getPreRemoveMethod();
-   }
-
-}

Copied: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamPersistenceProvider.java (from rev 13576, modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceProvider.java)
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamPersistenceProvider.java	                        (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamPersistenceProvider.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -0,0 +1,267 @@
+/*
+ * 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.reflect.Method;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.EntityManager;
+import javax.persistence.OptimisticLockException;
+import javax.persistence.PersistenceContexts;
+import javax.transaction.Synchronization;
+
+import org.jboss.seam.persistence.transaction.FlushModeType;
+
+/**
+ * Abstraction layer for persistence providers (JPA implementations). This class
+ * provides a working base implementation that can be optimized for performance
+ * and non-standardized features by extending and overriding the methods.
+ * 
+ * The methods on this class are a great todo list for the next rev of the JPA
+ * spec ;-)
+ * 
+ * @author Gavin King
+ * @author Pete Muir
+ * @author Stuart Douglas
+ * 
+ */
+public class SeamPersistenceProvider
+{
+   public enum Feature
+   {
+      /**
+       * Identifies whether this JPA provider supports using a wildcard as the
+       * subject of a count query.
+       * 
+       * <p>
+       * Here's a count query that uses a wildcard as the subject.
+       * </p>
+       * 
+       * <pre>
+       * select count(*) from Vehicle v
+       * </pre>
+       * <p>
+       * Per the JPA 1.0 spec, using a wildcard as a subject of a count query is
+       * not permitted. Instead, the subject must be the entity or the alias, as
+       * in this count query:
+       * </p>
+       * 
+       * <pre>
+       * select count(v) from Vehicle v
+       * </pre>
+       * <p>
+       * Hibernate supports the wildcard syntax as an vendor extension.
+       * Furthermore, Hibernate produces an invalid SQL query when using the
+       * compliant subject if the entity has a composite primary key. Therefore,
+       * we prefer to use the wildcard syntax if it is supported.
+       * </p>
+       */
+      WILDCARD_AS_COUNT_QUERY_SUBJECT
+   }
+
+   protected Set<Feature> featureSet = new HashSet<Feature>();
+
+   /**
+    * Indicate whether this JPA provider supports the feature defined by the
+    * provided Feature enum value.
+    */
+   public boolean supportsFeature(Feature feature)
+   {
+      return featureSet.contains(feature);
+   }
+
+   /**
+    * sets the flush mode
+    */
+   public void setFlushMode(EntityManager entityManager, FlushModeType type)
+   {
+      switch (type)
+      {
+      case AUTO:
+         entityManager.setFlushMode(javax.persistence.FlushModeType.AUTO);
+         break;
+      case COMMIT:
+         entityManager.setFlushMode(javax.persistence.FlushModeType.COMMIT);
+      case MANUAL:
+         setFlushModeManual(entityManager);
+      default:
+         throw new RuntimeException("Unkown flush mode: " + type);
+      }
+   }
+
+   /**
+    * Set the flush mode to manual-only flushing. Called when an atomic
+    * persistence context is required.
+    */
+   public void setFlushModeManual(EntityManager entityManager)
+   {
+      throw new UnsupportedOperationException("Use of FlushMode.MANUAL requires Hibernate as the persistence provider. Please use Hibernate, a custom persistenceProvider, or remove the MANUAL flush mode setting.");
+   }
+
+   /**
+    * <p>
+    * Set the FlushMode the persistence contexts should use during rendering by
+    * calling {@link PersistenceContexts#changeFlushMode(FlushModeType, true)}.
+    * The actual changing of the flush mode is handled by the
+    * {@link PersistenceContexts} instance. The boolean argument should be true
+    * to indicate that this is a temporary change and that the old flush mode
+    * should be restored after render.
+    * </p>
+    * <p>
+    * Ideally, this should be MANUAL since changes should never flush to the
+    * database while in render response and the cost of a dirty check can be
+    * avoided. However, since the MANUAL mode is not officially part of the JPA
+    * specification, the default implementation will perform no operation.
+    * </p>
+    */
+   public void setRenderFlushMode()
+   {
+      // no-op in default implementation
+   }
+
+   /**
+    * Does the persistence context have unflushed changes? If it does not,
+    * persistence context replication can be optimized.
+    * 
+    * @return true to indicate that there are unflushed changes
+    */
+   public boolean isDirty(EntityManager entityManager)
+   {
+      return true; // best we can do!
+   }
+
+   /**
+    * Get the value of the entity identifier attribute.
+    * 
+    * @param bean a managed entity instance
+    */
+   public Object getId(Object bean, EntityManager entityManager)
+   {
+      // return Entity.forBean(bean).getIdentifier(bean);
+      return null;
+   }
+
+   /**
+    * Get the name of the entity
+    * 
+    * @param bean
+    * @param entityManager
+    * 
+    * @throws IllegalArgumentException if the passed object is not an entity
+    */
+   public String getName(Object bean, EntityManager entityManager) throws IllegalArgumentException
+   {
+      return null;
+      // return Entity.forBean(bean).getName();
+   }
+
+   /**
+    * Get the value of the entity version attribute.
+    * 
+    * @param bean a managed entity instance
+    */
+   public Object getVersion(Object bean, EntityManager entityManager)
+   {
+      return null;
+      // return Entity.forBean(bean).getVersion(bean);
+   }
+
+   public void checkVersion(Object bean, EntityManager entityManager, Object oldVersion, Object version)
+   {
+      boolean equal;
+      if (oldVersion instanceof Date)
+      {
+         equal = ((Date) oldVersion).getTime() == ((Date) version).getTime();
+      }
+      else
+      {
+         equal = oldVersion.equals(version);
+      }
+      if (!equal)
+      {
+         throw new OptimisticLockException("Current database version number does not match passivated version number");
+      }
+   }
+
+   /**
+    * 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 boolean registerSynchronization(Synchronization sync, EntityManager entityManager)
+   {
+      return false; // best we can do!
+   }
+
+   /**
+    * Wrap the delegate before returning it to the application
+    */
+   public Object proxyDelegate(Object delegate)
+   {
+      return delegate;
+   }
+
+   /**
+    * Returns the class of an entity bean instance
+    * 
+    * @param bean The entity bean instance
+    * @return The class of the entity bean
+    */
+   public Class getBeanClass(Object bean)
+   {
+      return null;
+      // return Entity.forBean(bean).getBeanClass();
+   }
+
+   public Method getPostLoadMethod(Object bean, EntityManager entityManager)
+   {
+      return null;
+      // return Entity.forBean(bean).getPostLoadMethod();
+   }
+
+   public Method getPrePersistMethod(Object bean, EntityManager entityManager)
+   {
+      return null;
+      // return Entity.forBean(bean).getPrePersistMethod();
+   }
+
+   public Method getPreUpdateMethod(Object bean, EntityManager entityManager)
+   {
+      return null;
+      // return Entity.forBean(bean).getPreUpdateMethod();
+   }
+
+   public Method getPreRemoveMethod(Object bean, EntityManager entityManager)
+   {
+      return null;
+      // return Entity.forBean(bean).getPreRemoveMethod();
+   }
+
+}

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EntityTransaction.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EntityTransaction.java	2010-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EntityTransaction.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -33,7 +33,7 @@
 import javax.transaction.Synchronization;
 import javax.transaction.SystemException;
 
-import org.jboss.seam.persistence.PersistenceProvider;
+import org.jboss.seam.persistence.SeamPersistenceProvider;
 import org.jboss.weld.extensions.core.Veto;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -57,7 +57,7 @@
    private EntityManager entityManager;
 
    @Inject
-   private Instance<PersistenceProvider> persistenceProvider;
+   private Instance<SeamPersistenceProvider> persistenceProvider;
 
    @Inject
    public EntityTransaction(Synchronizations sync)

Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java	2010-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -35,7 +35,6 @@
 import org.jboss.seam.persistence.transaction.DefaultTransaction;
 import org.jboss.seam.persistence.transaction.SeamTransaction;
 import org.jboss.seam.persistence.transaction.TransactionExtension;
-import org.jboss.seam.persistence.util.NamingUtils;
 import org.jboss.seam.transactions.test.util.ArtifactNames;
 import org.jboss.seam.transactions.test.util.HelloService;
 import org.jboss.seam.transactions.test.util.Hotel;
@@ -60,7 +59,6 @@
       war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
       war.addPackage(TransactionExtension.class.getPackage());
       war.addPackage(PersistenceContextExtension.class.getPackage());
-      war.addPackage(NamingUtils.class.getPackage());
       war.addClasses(ManagedPersistenceContextELTest.class, Hotel.class, ManagedPersistenceContextProvider.class, HotelNameProducer.class, HelloService.class);
       war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
       war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");

Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java	2010-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -37,7 +37,7 @@
 
 import org.jboss.arquillian.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.persistence.PersistenceProvider;
+import org.jboss.seam.persistence.SeamPersistenceProvider;
 import org.jboss.seam.persistence.transaction.DefaultTransaction;
 import org.jboss.seam.persistence.transaction.SeamTransaction;
 import org.jboss.seam.persistence.transaction.TransactionExtension;
@@ -75,7 +75,7 @@
       war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
       war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
       war.addPackage(TransactionExtension.class.getPackage());
-      war.addPackage(PersistenceProvider.class.getPackage());
+      war.addPackage(SeamPersistenceProvider.class.getPackage());
       war.addPackage(NamingUtils.class.getPackage());
       war.addClasses(TransactionAttributeInterceptorTest.class, TransactionAttributeManagedBean.class, HelloService.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class);
       war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");

Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java	2010-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -37,7 +37,7 @@
 
 import org.jboss.arquillian.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.persistence.PersistenceProvider;
+import org.jboss.seam.persistence.SeamPersistenceProvider;
 import org.jboss.seam.persistence.transaction.DefaultTransaction;
 import org.jboss.seam.persistence.transaction.SeamTransaction;
 import org.jboss.seam.persistence.transaction.TransactionExtension;
@@ -76,7 +76,7 @@
       war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
       war.addPackage(TransactionExtension.class.getPackage());
       war.addPackage(NamingUtils.class.getPackage());
-      war.addPackage(PersistenceProvider.class.getPackage());
+      war.addPackage(SeamPersistenceProvider.class.getPackage());
       war.addClasses(TransactionInterceptorTest.class, TransactionManagedBean.class, HelloService.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class);
       war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
       war.addWebResource(new ByteArrayAsset(("<beans><interceptors><class>" + TransactionInterceptor.class.getName() + "</class></interceptors></beans>").getBytes()), "beans.xml");

Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java	2010-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -13,7 +13,7 @@
 
 import org.jboss.arquillian.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.persistence.PersistenceProvider;
+import org.jboss.seam.persistence.SeamPersistenceProvider;
 import org.jboss.seam.persistence.transaction.DefaultTransaction;
 import org.jboss.seam.persistence.transaction.SeamTransaction;
 import org.jboss.seam.persistence.transaction.TransactionExtension;
@@ -41,7 +41,7 @@
       war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
       war.addPackage(TransactionExtension.class.getPackage());
       war.addPackage(TransactionScopeExtension.class.getPackage());
-      war.addPackage(PersistenceProvider.class.getPackage());
+      war.addPackage(SeamPersistenceProvider.class.getPackage());
       war.addPackage(NamingUtils.class.getPackage());
       war.addClasses(TransactionScopedTest.class, Hotel.class, HelloService.class, TransactionScopedObject.class);
       war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");

Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java	2010-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java	2010-08-11 11:49:39 UTC (rev 13598)
@@ -16,6 +16,7 @@
 
 import org.jboss.arquillian.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.SeamPersistenceProvider;
 import org.jboss.seam.persistence.transaction.DefaultTransaction;
 import org.jboss.seam.persistence.transaction.SeamTransaction;
 import org.jboss.seam.persistence.transaction.TransactionExtension;
@@ -43,6 +44,7 @@
       war.addPackage(TransactionExtension.class.getPackage());
       war.addPackage(PersistenceException.class.getPackage());
       war.addClasses(UserTransactionTest.class, Hotel.class, HelloService.class);
+      war.addClass(SeamPersistenceProvider.class);
       war.addPackage(NamingUtils.class.getPackage());
       war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
       war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");

Modified: modules/persistence/trunk/pom.xml
===================================================================
--- modules/persistence/trunk/pom.xml	2010-08-11 09:17:10 UTC (rev 13597)
+++ modules/persistence/trunk/pom.xml	2010-08-11 11:49:39 UTC (rev 13598)
@@ -66,12 +66,6 @@
             <version>${project.version}</version>
          </dependency>
          
-         <dependency>
-	         <groupId>org.hibernate</groupId>
-	         <artifactId>hibernate-core</artifactId>
-	         <version>3.5.1-Final</version>
-	      </dependency>
-
       </dependencies>
    </dependencyManagement>
 



More information about the seam-commits mailing list