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

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sat Jul 24 23:50:38 EDT 2010


Author: swd847
Date: 2010-07-24 23:50:38 -0400 (Sat, 24 Jul 2010)
New Revision: 13497

Added:
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java
Removed:
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Naming.java
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/ManagedPersistenceContextExtension.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java
   modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java
Log:
update to work with latest weldx



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-07-25 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java	2010-07-25 03:50:38 UTC (rev 13497)
@@ -34,7 +34,6 @@
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 
-import org.jboss.weld.extensions.bean.BeanImpl;
 import org.jboss.weld.extensions.bean.BeanLifecycle;
 
 /**
@@ -81,7 +80,7 @@
    /**
     * creates the proxy
     */
-   public EntityManager create(BeanImpl<EntityManager> bean, CreationalContext<EntityManager> arg0)
+   public EntityManager create(Bean<EntityManager> bean, CreationalContext<EntityManager> arg0)
    {
       try
       {
@@ -97,7 +96,7 @@
       }
    }
 
-   public void destroy(BeanImpl<EntityManager> bean, EntityManager em, CreationalContext<EntityManager> arg1)
+   public void destroy(Bean<EntityManager> bean, EntityManager em, CreationalContext<EntityManager> arg1)
    {
       em.close();
       arg1.release();

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 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java	2010-07-25 03:50:38 UTC (rev 13497)
@@ -46,7 +46,6 @@
  * turn them into Seam Managed Persistence Contexts.
  * 
  * 
- * 
  * @author Stuart Douglas
  * 
  */
@@ -72,7 +71,7 @@
          {
             if (modifiedType == null)
             {
-               modifiedType = AnnotatedTypeBuilder.newInstance(event.getAnnotatedType()).mergeAnnotations(event.getAnnotatedType(), true);
+               modifiedType = new AnnotatedTypeBuilder().readFromType(event.getAnnotatedType());
             }
             Set<Annotation> qualifiers = new HashSet<Annotation>();
             Class<? extends Annotation> scope = Dependent.class;
@@ -99,15 +98,13 @@
                modifiedType.removeFromField(f.getJavaMember(), scope);
             }
             // create the new bean to be registerd later
-            AnnotatedTypeBuilder<EntityManager> typeBuilder = AnnotatedTypeBuilder.newInstance(EntityManager.class);
-            BeanBuilder<EntityManager> builder = new BeanBuilder<EntityManager>(typeBuilder.create(), manager);
-            builder.defineBeanFromAnnotatedType();
+            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());
          }
-
       }
       if (modifiedType != null)
       {

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java	2010-07-25 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java	2010-07-25 03:50:38 UTC (rev 13497)
@@ -25,6 +25,8 @@
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
 
+import org.jboss.seam.persistence.util.Naming;
+
 /**
  * utility class to look up the EJBContext
  * 

Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Naming.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Naming.java	2010-07-25 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Naming.java	2010-07-25 03:50:38 UTC (rev 13497)
@@ -1,104 +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.transaction;
-
-import java.util.Hashtable;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * this has been ported to seam and hacked to make it work
- * 
- * we need to figure out what we are doing with JNDI in seam 3 and make this go
- * away
- * 
- * @author stuart
- * 
- */
-public final class Naming
-{
-   private static final Logger log = LoggerFactory.getLogger(Naming.class);
-   private static Hashtable initialContextProperties;
-
-   private static InitialContext initialContext;
-
-   public static InitialContext getInitialContext(Hashtable<String, String> props) throws NamingException
-   {
-      if (props == null)
-      {
-         // throw new
-         // IllegalStateException("JNDI properties not initialized, Seam was not started correctly");
-      }
-      props = new Hashtable<String, String>();
-
-      if (log.isDebugEnabled())
-      {
-         log.debug("JNDI InitialContext properties:" + props);
-      }
-
-      try
-      {
-         return props.size() == 0 ? new InitialContext() : new InitialContext(props);
-      }
-      catch (NamingException e)
-      {
-         log.debug("Could not obtain initial context");
-         throw e;
-      }
-
-   }
-
-   public static InitialContext getInitialContext() throws NamingException
-   {
-      if (initialContext == null)
-         initInitialContext();
-
-      return initialContext;
-   }
-
-   private static synchronized void initInitialContext() throws NamingException
-   {
-      if (initialContext == null)
-      {
-         initialContext = getInitialContext(initialContextProperties);
-      }
-   }
-
-   private Naming()
-   {
-   }
-
-   public static void setInitialContextProperties(Hashtable initialContextProperties)
-   {
-      Naming.initialContextProperties = initialContextProperties;
-      initialContext = null;
-   }
-
-   public static Hashtable getInitialContextProperties()
-   {
-      return initialContextProperties;
-   }
-}

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java	2010-07-25 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java	2010-07-25 03:50:38 UTC (rev 13497)
@@ -10,6 +10,7 @@
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
 
+import org.jboss.seam.persistence.util.Naming;
 import org.jboss.weld.extensions.literal.DefaultLiteral;
 
 /**

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 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java	2010-07-25 03:50:38 UTC (rev 13497)
@@ -22,6 +22,7 @@
 package org.jboss.seam.persistence.util;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
 
 import org.jboss.weld.extensions.util.Reflections;
 
@@ -91,17 +92,29 @@
 
    public static String name(Annotation annotation)
    {
-      return (String) Reflections.invokeAndWrap(Reflections.getMethod(annotation.annotationType(), "name"), annotation);
+      return (String) invokeAndWrap(Reflections.getMethod(annotation.annotationType(), "name"), annotation);
    }
 
    public static Class[] value(Annotation annotation)
    {
-      return (Class[]) Reflections.invokeAndWrap(Reflections.getMethod(annotation.annotationType(), "value"), annotation);
+      return (Class[]) invokeAndWrap(Reflections.getMethod(annotation.annotationType(), "value"), annotation);
    }
 
    public static boolean rollback(Annotation annotation)
    {
-      return (Boolean) Reflections.invokeAndWrap(Reflections.getMethod(annotation.annotationType(), "rollback"), annotation);
+      return (Boolean) invokeAndWrap(Reflections.getMethod(annotation.annotationType(), "rollback"), annotation);
    }
 
+   private static Object invokeAndWrap(Method method, Object instance, Object... parameters)
+   {
+      try
+      {
+         return method.invoke(instance, parameters);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
 }

Copied: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java (from rev 13495, modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Naming.java)
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java	                        (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/Naming.java	2010-07-25 03:50:38 UTC (rev 13497)
@@ -0,0 +1,104 @@
+/*
+ * 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.util;
+
+import java.util.Hashtable;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * this has been ported to seam and hacked to make it work
+ * 
+ * we need to figure out what we are doing with JNDI in seam 3 and make this go
+ * away
+ * 
+ * @author stuart
+ * 
+ */
+public final class Naming
+{
+   private static final Logger log = LoggerFactory.getLogger(Naming.class);
+   private static Hashtable initialContextProperties;
+
+   private static InitialContext initialContext;
+
+   public static InitialContext getInitialContext(Hashtable<String, String> props) throws NamingException
+   {
+      if (props == null)
+      {
+         // throw new
+         // IllegalStateException("JNDI properties not initialized, Seam was not started correctly");
+      }
+      props = new Hashtable<String, String>();
+
+      if (log.isDebugEnabled())
+      {
+         log.debug("JNDI InitialContext properties:" + props);
+      }
+
+      try
+      {
+         return props.size() == 0 ? new InitialContext() : new InitialContext(props);
+      }
+      catch (NamingException e)
+      {
+         log.debug("Could not obtain initial context");
+         throw e;
+      }
+
+   }
+
+   public static InitialContext getInitialContext() throws NamingException
+   {
+      if (initialContext == null)
+         initInitialContext();
+
+      return initialContext;
+   }
+
+   private static synchronized void initInitialContext() throws NamingException
+   {
+      if (initialContext == null)
+      {
+         initialContext = getInitialContext(initialContextProperties);
+      }
+   }
+
+   private Naming()
+   {
+   }
+
+   public static void setInitialContextProperties(Hashtable initialContextProperties)
+   {
+      Naming.initialContextProperties = initialContextProperties;
+      initialContext = null;
+   }
+
+   public static Hashtable getInitialContextProperties()
+   {
+      return initialContextProperties;
+   }
+}

Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java	2010-07-25 01:28:57 UTC (rev 13496)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java	2010-07-25 03:50:38 UTC (rev 13497)
@@ -12,8 +12,6 @@
  */
 public class MavenArtifactResolver
 {
-   private static final String LOCAL_MAVEN_REPO = System.getProperty("user.home") + File.separatorChar + ".m2" + File.separatorChar + "repository";
-
    public static File resolve(String groupId, String artifactId)
    {
       String classPath = System.getProperty("java.class.path");



More information about the seam-commits mailing list