[seam-commits] Seam SVN: r13501 - in modules/persistence/trunk: api and 4 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sun Jul 25 06:56:32 EDT 2010


Author: swd847
Date: 2010-07-25 06:56:31 -0400 (Sun, 25 Jul 2010)
New Revision: 13501

Modified:
   modules/persistence/trunk/api/pom.xml
   modules/persistence/trunk/impl/pom.xml
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java
   modules/persistence/trunk/impl/src/main/resources/META-INF/beans.xml
   modules/persistence/trunk/pom.xml
Log:
removed dep on ee api


Modified: modules/persistence/trunk/api/pom.xml
===================================================================
--- modules/persistence/trunk/api/pom.xml	2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/api/pom.xml	2010-07-25 10:56:31 UTC (rev 13501)
@@ -24,13 +24,6 @@
         <artifactId>cdi-api</artifactId>
       </dependency>
 
-	  <dependency>
-		  <groupId>org.jboss.spec</groupId>
-		  <artifactId>jboss-javaee-6.0</artifactId>
-		  <type>pom</type>
-		  <scope>provided</scope>
-	  </dependency>
-	  
    </dependencies>
 
    <scm>

Modified: modules/persistence/trunk/impl/pom.xml
===================================================================
--- modules/persistence/trunk/impl/pom.xml	2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/impl/pom.xml	2010-07-25 10:56:31 UTC (rev 13501)
@@ -89,13 +89,6 @@
          <scope>test</scope>
       </dependency>
 
-       <dependency>
-          <groupId>org.jboss.spec</groupId>
-          <artifactId>jboss-javaee-6.0</artifactId>
-          <type>pom</type>
-          <scope>provided</scope>
-       </dependency>
-
       <dependency>
          <groupId>org.jboss.weld</groupId>
          <artifactId>weld-extensions</artifactId>

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java	2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java	2010-07-25 10:56:31 UTC (rev 13501)
@@ -66,7 +66,8 @@
       AnnotatedTypeBuilder<T> modifiedType = null;
       for (AnnotatedField<? super T> f : event.getAnnotatedType().getFields())
       {
-         // look for a seam managed persistence unit declaration
+         // look for a seam managed persistence unit declaration on EE resource
+         // producer fields
          if (f.isAnnotationPresent(SeamManaged.class) && f.isAnnotationPresent(PersistenceUnit.class) && f.isAnnotationPresent(Produces.class))
          {
             if (modifiedType == null)
@@ -97,14 +98,11 @@
             {
                modifiedType.removeFromField(f.getJavaMember(), scope);
             }
-            // create the new bean to be registerd later
-            AnnotatedTypeBuilder<EntityManager> typeBuilder = new AnnotatedTypeBuilder().setJavaClass(EntityManager.class);
-            BeanBuilder<EntityManager> builder = new BeanBuilder<EntityManager>(manager).defineBeanFromAnnotatedType(typeBuilder.create());
-            builder.setQualifiers(qualifiers);
-            builder.setScope(scope);
-            builder.setBeanLifecycle(new ManagedPersistenceContextBeanLifecycle(qualifiers, manager));
-            beans.add(builder.create());
+            registerManagedPersistenceContext(qualifiers, scope, manager);
          }
+         // now look for producer methods that produce an EntityManagerFactory.
+         // This allows the user to manually configure an EntityManagerFactory
+         // and return it from a producer method
       }
       if (modifiedType != null)
       {
@@ -112,6 +110,24 @@
       }
    }
 
+   /**
+    */
+   public void processProducer()
+   {
+
+   }
+
+   public void registerManagedPersistenceContext(Set<Annotation> qualifiers, Class<? extends Annotation> scope, BeanManager manager)
+   {
+      // create the new bean to be registerd later
+      AnnotatedTypeBuilder<EntityManager> typeBuilder = new AnnotatedTypeBuilder().setJavaClass(EntityManager.class);
+      BeanBuilder<EntityManager> builder = new BeanBuilder<EntityManager>(manager).defineBeanFromAnnotatedType(typeBuilder.create());
+      builder.setQualifiers(qualifiers);
+      builder.setScope(scope);
+      builder.setBeanLifecycle(new ManagedPersistenceContextBeanLifecycle(qualifiers, manager));
+      beans.add(builder.create());
+   }
+
    public void afterBeanDiscovery(@Observes AfterBeanDiscovery event)
    {
       for (Bean<?> i : beans)

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java	2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java	2010-07-25 10:56:31 UTC (rev 13501)
@@ -33,8 +33,6 @@
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Alternative;
-import javax.enterprise.inject.Any;
-import javax.enterprise.inject.Default;
 import javax.enterprise.inject.spi.AfterBeanDiscovery;
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.Bean;
@@ -43,24 +41,29 @@
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.ProcessProducer;
 import javax.enterprise.inject.spi.Producer;
-import javax.enterprise.util.AnnotationLiteral;
 import javax.inject.Qualifier;
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.Persistence;
 import javax.persistence.PersistenceContext;
 
+import org.jboss.weld.extensions.literal.AnyLiteral;
+import org.jboss.weld.extensions.literal.DefaultLiteral;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Support for managed persistence contexts in a Java SE environment or Servlet container.
- *
- * <p>Unlike with standard Java EE, the unitName attribute on {@link PersistenceContext} must
- * be provided if the persistence unit is assigned a name in persistence.xml. This
- * class supports multiple persistence units, but it does not permit multiple
- * producers for the same persistence unit (naturally).</p>
+ * Support for managed persistence contexts in a Java SE environment or Servlet
+ * container.
  * 
+ * <p>
+ * Unlike with standard Java EE, the unitName attribute on
+ * {@link PersistenceContext} must be provided if the persistence unit is
+ * assigned a name in persistence.xml. This class supports multiple persistence
+ * units, but it does not permit multiple producers for the same persistence
+ * unit (naturally).
+ * </p>
+ * 
  * @author Gavin King
  * @author Dan Allen
  */
@@ -117,17 +120,9 @@
             }
             if (qualifiers.isEmpty())
             {
-               qualifiers.add(new AnnotationLiteral<Default>()
-               {
-                  /** default value. Added only to suppress compiler warnings. */
-                  private static final long serialVersionUID = 1L;
-               });
+               qualifiers.add(DefaultLiteral.INSTANCE);
             }
-            qualifiers.add(new AnnotationLiteral<Any>()
-            {
-               /** default value. Added only to suppress compiler warnings. */
-               private static final long serialVersionUID = 1L;
-            });
+            qualifiers.add(AnyLiteral.INSTANCE);
             final boolean alternative = field.isAnnotationPresent(Alternative.class);
             final Set<Type> types = new HashSet<Type>()
             {
@@ -248,10 +243,11 @@
 
    /**
     * Check whether persistence is container managed. For now, this simply
-    * checks for the presence of the EJB API. If it's present, we assume
-    * this is an EE environment and that persistence is container managed.
+    * checks for the presence of the EJB API. If it's present, we assume this is
+    * an EE environment and that persistence is container managed.
     */
-   boolean isPersistenceContainerManaged() {
+   boolean isPersistenceContainerManaged()
+   {
       boolean eeEnv = true;
       try
       {

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java	2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java	2010-07-25 10:56:31 UTC (rev 13501)
@@ -39,22 +39,22 @@
    {
    }
 
-   public static final Class<Annotation> STATELESS;
-   public static final Class<Annotation> STATEFUL;
-   public static final Class<Annotation> MESSAGE_DRIVEN;
-   public static final Class<Annotation> PRE_PASSIVATE;
-   public static final Class<Annotation> POST_ACTIVATE;
-   public static final Class<Annotation> PRE_DESTROY;
-   public static final Class<Annotation> POST_CONSTRUCT;
-   public static final Class<Annotation> REMOTE;
-   public static final Class<Annotation> REMOVE;
-   public static final Class<Annotation> LOCAL;
-   public static final Class<Annotation> APPLICATION_EXCEPTION;
-   public static final Class<Annotation> PERSISTENCE_CONTEXT;
-   public static final Class<Annotation> PERSISTENCE_UNIT;
-   public static final Class<Annotation> INTERCEPTORS;
-   public static final Class<Annotation> AROUND_INVOKE;
-   public static final Class<Annotation> EJB_EXCEPTION;
+   public static final Class<? extends Annotation> TRANSACTION_ATTRIBUTE;
+   public static final Class<? extends Enum> TRANSACTION_ATTRIBUTE_TYPE;
+   public static final Class<? extends Annotation> APPLICATION_EXCEPTION;
+
+   private static final Object MANDATORY;
+
+   private static final Object REQUIRED;
+
+   private static final Object REQUIRES_NEW;
+
+   private static final Object SUPPORTS;
+
+   private static final Object NOT_SUPPORTED;
+
+   private static final Object NEVER;
+
    public static final boolean INVOCATION_CONTEXT_AVAILABLE;
 
    private static Class classForName(String name)
@@ -71,22 +71,27 @@
 
    static
    {
-      STATELESS = classForName("javax.ejb.Stateless");
-      STATEFUL = classForName("javax.ejb.Stateful");
-      MESSAGE_DRIVEN = classForName("javax.ejb.MessageDriven");
       APPLICATION_EXCEPTION = classForName("javax.ejb.ApplicationException");
-      PERSISTENCE_CONTEXT = classForName("javax.persistence.PersistenceContext");
-      PERSISTENCE_UNIT = classForName("javax.persistence.PersistenceUnit");
-      REMOVE = classForName("javax.ejb.Remove");
-      REMOTE = classForName("javax.ejb.Remote");
-      LOCAL = classForName("javax.ejb.Local");
-      PRE_PASSIVATE = classForName("javax.ejb.PrePassivate");
-      POST_ACTIVATE = classForName("javax.ejb.PostActivate");
-      PRE_DESTROY = classForName("javax.annotation.PreDestroy");
-      POST_CONSTRUCT = classForName("javax.annotation.PostConstruct");
-      INTERCEPTORS = classForName("javax.interceptor.Interceptors");
-      AROUND_INVOKE = classForName("javax.interceptor.AroundInvoke");
-      EJB_EXCEPTION = classForName("javax.ejb.EJBException");
+      TRANSACTION_ATTRIBUTE = classForName("javax.ejb.TransactionAttribute");
+      TRANSACTION_ATTRIBUTE_TYPE = classForName("javax.ejb.TransactionAttributeType");
+      if (TRANSACTION_ATTRIBUTE_TYPE.getName().equals("javax.ejb.TransactionAttributeType"))
+      {
+         MANDATORY = Enum.valueOf(TRANSACTION_ATTRIBUTE_TYPE, "MANDATORY");
+         REQUIRED = Enum.valueOf(TRANSACTION_ATTRIBUTE_TYPE, "REQUIRED");
+         NOT_SUPPORTED = Enum.valueOf(TRANSACTION_ATTRIBUTE_TYPE, "NOT_SUPPORTED");
+         REQUIRES_NEW = Enum.valueOf(TRANSACTION_ATTRIBUTE_TYPE, "REQUIRES_NEW");
+         NEVER = Enum.valueOf(TRANSACTION_ATTRIBUTE_TYPE, "NEVER");
+         SUPPORTS = Enum.valueOf(TRANSACTION_ATTRIBUTE_TYPE, "SUPPORTS");
+      }
+      else
+      {
+         MANDATORY = Dummy.class;
+         REQUIRED = Dummy.class;
+         NOT_SUPPORTED = Dummy.class;
+         REQUIRES_NEW = Dummy.class;
+         NEVER = Dummy.class;
+         SUPPORTS = Dummy.class;
+      }
       INVOCATION_CONTEXT_AVAILABLE = !classForName("javax.interceptor.InvocationContext").equals(Dummy.class);
    }
 

Modified: modules/persistence/trunk/impl/src/main/resources/META-INF/beans.xml
===================================================================
--- modules/persistence/trunk/impl/src/main/resources/META-INF/beans.xml	2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/impl/src/main/resources/META-INF/beans.xml	2010-07-25 10:56:31 UTC (rev 13501)
@@ -5,10 +5,27 @@
 -->
 <beans xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xmlns:persistence="urn:java:org.jboss.seam.persistence"
+   xmlns:s="urn:java:ee"
    xsi:schemaLocation="
       http://java.sun.com/xml/ns/javaee 
       http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
       <interceptors>
          <class>org.jboss.seam.persistence.transaction.TransactionInterceptor</class>
       </interceptors>
+     <genericBean class="org.jboss.seam.persistence.ManagedPersistenceContext" >
+      <persistence:EntityManagerFactoryProvider>
+         <s:ApplyQualifiers/>
+         
+         <persistence:managedPersistenceContext>
+            <s:Inject/>
+            <s:ApplyQualifiers/>
+         </persistence:managedPersistenceContext>
+         
+         <persistence:produceEntityManagerFactory>
+            <ApplyQualifiers/>
+            <s:Produces/>
+         </persistence:produceEntityManagerFactory>
+      </persistence:EntityManagerFactoryProvider>
+   </genericBean>
 </beans>

Modified: modules/persistence/trunk/pom.xml
===================================================================
--- modules/persistence/trunk/pom.xml	2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/pom.xml	2010-07-25 10:56:31 UTC (rev 13501)
@@ -31,7 +31,6 @@
 
    <properties>
       <seam.version>3.0.0.b01</seam.version>
-      <jboss-javaee6-spec.version>1.0.0.Beta4</jboss-javaee6-spec.version>
    </properties>
 
    <dependencyManagement>
@@ -52,14 +51,6 @@
             <version>${project.version}</version>
          </dependency>
          
-        <dependency>
-          <groupId>org.jboss.spec</groupId>
-          <artifactId>jboss-javaee-6.0</artifactId>
-          <version>${jboss-javaee6-spec.version}</version>
-          <type>pom</type>
-          <scope>provided</scope>
-        </dependency>
-       
          <dependency>
             <groupId>org.jboss.seam.persistence</groupId>
             <artifactId>seam-persistence</artifactId>



More information about the seam-commits mailing list