geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r889738 - in /geronimo/specs/trunk/geronimo-jpa_2.0_spec/src/main/java/javax/persistence: Persistence.java spi/PersistenceProviderResolverHolder.java
Date Fri, 11 Dec 2009 18:16:44 GMT
Author: dwoods
Date: Fri Dec 11 18:16:43 2009
New Revision: 889738

URL: http://svn.apache.org/viewvc?rev=889738&view=rev
Log:
cleaned up some comments in both files.  updated WeakHashMap usage in PersistenceProviderResolverHolder.

Modified:
    geronimo/specs/trunk/geronimo-jpa_2.0_spec/src/main/java/javax/persistence/Persistence.java
    geronimo/specs/trunk/geronimo-jpa_2.0_spec/src/main/java/javax/persistence/spi/PersistenceProviderResolverHolder.java

Modified: geronimo/specs/trunk/geronimo-jpa_2.0_spec/src/main/java/javax/persistence/Persistence.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jpa_2.0_spec/src/main/java/javax/persistence/Persistence.java?rev=889738&r1=889737&r2=889738&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jpa_2.0_spec/src/main/java/javax/persistence/Persistence.java
(original)
+++ geronimo/specs/trunk/geronimo-jpa_2.0_spec/src/main/java/javax/persistence/Persistence.java
Fri Dec 11 18:16:43 2009
@@ -42,7 +42,7 @@
 import javax.persistence.spi.ProviderUtil;
 
 /**
- * Bootstrap class that is used to obtain {@link javax.persistence.EntityManagerFactory}
+ * Bootstrap class to obtain {@link javax.persistence.EntityManagerFactory}
  * references.
  * 
  * Contains Geronimo implemented code as required by the JPA spec.
@@ -51,36 +51,27 @@
  */
 public class Persistence {
 
+    // The following variable is only here for TCK backward compatibility
+    @Deprecated
     protected static final Set<PersistenceProvider> providers = new HashSet<PersistenceProvider>();
-    // Changed to the hard coded PERSISTENCE_PROVIDER value to pass signature tests.
-    // public static final java.lang.String PERSISTENCE_PROVIDER = PersistenceProvider.class.getName();

-    public static final java.lang.String PERSISTENCE_PROVIDER = "javax.persistence.spi.PeristenceProvider";
+
+    // The following string is only here for TCK backward compatibility
+    @Deprecated
+    public static final String PERSISTENCE_PROVIDER = "javax.persistence.spi.PeristenceProvider";
+
     static final String PERSISTENCE_PROVIDER_PROPERTY = "javax.persistence.provider";
+
     static final String PERSISTENCE_PROVIDER_SERVICE = "META-INF/services/"
             + PersistenceProvider.class.getName();
 
-    /**
-     * Create and return an EntityManagerFactory for the named persistence unit.
-     *
-     * @param persistenceUnitName Name of the persistence unit
-     * @return The factory for the specified persistence unit or null if none
-     *         are applicable.
-     */
+
     public static EntityManagerFactory createEntityManagerFactory(
             String persistenceUnitName) {
         return createEntityManagerFactory(persistenceUnitName, Collections.EMPTY_MAP);
     }
 
     /**
-     * Create and return an EntityManagerFactory for the named persistence unit
-     * using the given properties.
-     *
-     * @param persistenceUnitName Name of the persistence unit
-     * @param properties Additional properties to use when creating the
-     *                   persistence unit factory. These properties override any
-     *                   values that have been configured elsewhere.
-     * @return The factory for the specified persistence unit or null if none
-     *         are applicable.
+     * Geronimo implementation specific code
      */
     public static EntityManagerFactory createEntityManagerFactory(
             String persistenceUnitName, Map properties) {
@@ -230,6 +221,7 @@
     
     
     /**
+     * Geronimo/OpenJPA private helper code for creating a PersistenceException
      * @param msg String to use as the exception message
      * @param failures Persistence provider exceptions to add to the exception message
      * @return PersistenceException
@@ -262,20 +254,16 @@
         }
     }
 
-    /*
-    * @return PersistenceUtil instance
-    * @since 2.0
-    */
     public static PersistenceUtil getPersistenceUtil() {
         return new PersistenceUtilImpl();
     }
     
-    /*
+    /**
      * Geronimo implementation specific code
      */
     private static class PersistenceUtilImpl implements PersistenceUtil {
 
-        /*
+        /**
          * Determines the load state of the attribute of an entity 
          * @see javax.persistence.PersistenceUtil#isLoaded(java.lang.Object, java.lang.String)
          */
@@ -351,6 +339,9 @@
             }
     }
 
+    /**
+     * Geronimo/OpenJPA private helper code for handling class loaders
+     */
     private static class PrivClassLoader implements PrivilegedAction<ClassLoader> {
         private final Class<?> c;
 

Modified: geronimo/specs/trunk/geronimo-jpa_2.0_spec/src/main/java/javax/persistence/spi/PersistenceProviderResolverHolder.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jpa_2.0_spec/src/main/java/javax/persistence/spi/PersistenceProviderResolverHolder.java?rev=889738&r1=889737&r2=889738&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jpa_2.0_spec/src/main/java/javax/persistence/spi/PersistenceProviderResolverHolder.java
(original)
+++ geronimo/specs/trunk/geronimo-jpa_2.0_spec/src/main/java/javax/persistence/spi/PersistenceProviderResolverHolder.java
Fri Dec 11 18:16:43 2009
@@ -35,7 +35,6 @@
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
-import java.util.Map;
 import java.util.WeakHashMap;
 
 import javax.persistence.PersistenceException;
@@ -83,7 +82,7 @@
             PersistenceProvider.class.getName();
 
         // cache of providers per class loader
-        private static final Map<ClassLoader, List<PersistenceProvider>> providerCache
=
+        private volatile WeakHashMap<ClassLoader, List<PersistenceProvider>>
providerCache =
             new WeakHashMap<ClassLoader, List<PersistenceProvider>>();
         
         /*
@@ -92,17 +91,13 @@
          * @see javax.persistence.spi.PersistenceProviderResolver#getPersistenceProviders()
          */
         public List<PersistenceProvider> getPersistenceProviders() {
-            List<PersistenceProvider> providers;
-            
             // get our class loader
             ClassLoader cl = PrivClassLoader.get(null);
             if (cl == null)
                 cl = PrivClassLoader.get(DefaultPersistenceProviderResolver.class);
 
             // use any previously cached providers
-            synchronized (providerCache) {
-                providers = providerCache.get(cl);
-            }
+            List<PersistenceProvider> providers = providerCache.get(cl);
             if (providers == null) {
                 // need to discover and load them for this class loader
                 providers = new ArrayList<PersistenceProvider>();
@@ -153,9 +148,7 @@
                 }
                 
                 // cache the discovered providers
-                synchronized (providerCache) {
-                    providerCache.put(cl, providers);
-                }
+                providerCache.put(cl, providers);
             }
 
             // caller must handle the case of no providers found
@@ -168,9 +161,7 @@
          * @see javax.persistence.spi.PersistenceProviderResolver#clearCachedProviders()
          */
         public void clearCachedProviders() {
-            synchronized (providerCache) {
-                providerCache.clear();
-            }
+            providerCache.clear();
         }
 
         private static class PrivClassLoader implements PrivilegedAction<ClassLoader>
{



Mime
View raw message