openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1190716 [10/10] - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/java/org...
Date Sat, 29 Oct 2011 00:44:18 GMT
Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java Sat Oct 29 00:44:11 2011
@@ -36,25 +36,28 @@ import org.apache.openjpa.conf.OpenJPACo
 import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
 import org.apache.openjpa.enhance.PCClassFileTransformer;
 import org.apache.openjpa.enhance.PCEnhancerAgent;
+import org.apache.openjpa.enhance.RuntimeUnenhancedClassesModes;
 import org.apache.openjpa.kernel.Bootstrap;
 import org.apache.openjpa.kernel.BrokerFactory;
 import org.apache.openjpa.kernel.ConnectionRetainModes;
 import org.apache.openjpa.lib.conf.Configuration;
 import org.apache.openjpa.lib.conf.ConfigurationProvider;
 import org.apache.openjpa.lib.conf.Configurations;
+import org.apache.openjpa.lib.conf.ProductDerivation;
+import org.apache.openjpa.lib.conf.ProductDerivations;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.meta.AbstractCFMetaDataFactory;
 import org.apache.openjpa.meta.MetaDataModes;
 import org.apache.openjpa.meta.MetaDataRepository;
 import org.apache.openjpa.persistence.osgi.BundleUtils;
+import org.apache.openjpa.persistence.osgi.OSGiDerivation;
 import org.apache.openjpa.persistence.validation.ValidationUtils;
 import org.apache.openjpa.util.ClassResolver;
 
 
 /**
- * Bootstrapping class that allows the creation of a stand-alone
- * {@link EntityManager}.
+ * Bootstrapping class that allows the creation of a stand-alone {@link EntityManager}.
  *
  * @see javax.persistence.Persistence#createEntityManagerFactory(String,Map)
  * @published
@@ -68,19 +71,28 @@ public class PersistenceProviderImpl
     private static final Localizer _loc = Localizer.forPackage(PersistenceProviderImpl.class);
 
     private Log _log;
+    
     /**
      * Loads the entity manager specified by <code>name</code>, applying
-     * the properties in <code>m</code> as overrides to the properties defined
+     * the properties in given map <code>m</code> as overrides to the properties defined
      * in the XML configuration file for <code>name</code>. If <code>name</code>
      * is <code>null</code>, this method loads the XML in the resource
      * identified by <code>resource</code>, and uses the first resource found
      * when doing this lookup, regardless of the name specified in the XML
      * resource or the name of the jar that the resource is contained in.
-     * This does no pooling of EntityManagersFactories.
-     * @return EntityManagerFactory or null
+     * <br>
+     * This does not pool EntityManagersFactories.
+     * 
+     * @param name name of the persistence unit
+     * @param resource name of the resource. Normally, <tt>META-INF/persistence.xml</tt>, but not necessarily.
+     * @param m a map of properties that overrides properties found in the resource.
+     * 
+     * @return EntityManagerFactory or null if anything goes wrong during loading resources.
      */
     public OpenJPAEntityManagerFactory createEntityManagerFactory(String name, String resource, Map m) {
-        PersistenceProductDerivation pd = new PersistenceProductDerivation();
+        PersistenceProductDerivation pd = BundleUtils.runningUnderOSGi() 
+        	? new OSGiDerivation() : new PersistenceProductDerivation();
+        ProductDerivations.load(resource, name);
         try {
             Object poolValue = Configurations.removeProperty(EMF_POOL, m);
             ConfigurationProvider cp = pd.load(resource, name, m);
@@ -88,10 +100,9 @@ public class PersistenceProviderImpl
                 return null;
             }
 
-            BrokerFactory factory = getBrokerFactory(cp, poolValue, BundleUtils.getBundleClassLoader());
+            BrokerFactory factory = getBrokerFactory(cp, poolValue);
             OpenJPAConfiguration conf = factory.getConfiguration();
-            _log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);            
-            pd.checkPuNameCollisions(_log,name);
+            _log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);  
             
             // add enhancer
             loadAgent(factory);
@@ -130,12 +141,11 @@ public class PersistenceProviderImpl
         }
     }
 
-    private BrokerFactory getBrokerFactory(ConfigurationProvider cp,
-        Object poolValue, ClassLoader loader) {
+    private BrokerFactory getBrokerFactory(ConfigurationProvider cp, Object poolValue) {
         // handle "true" and "false"
         if (poolValue instanceof String
             && ("true".equalsIgnoreCase((String) poolValue)
-                || "false".equalsIgnoreCase((String) poolValue)))
+             || "false".equalsIgnoreCase((String) poolValue)))
             poolValue = Boolean.valueOf((String) poolValue);
 
         if (poolValue != null && !(poolValue instanceof Boolean)) {
@@ -143,10 +153,11 @@ public class PersistenceProviderImpl
             throw new IllegalArgumentException(poolValue.toString());
         }
         
-        if (poolValue == null || !((Boolean) poolValue).booleanValue())
-            return Bootstrap.newBrokerFactory(cp, loader);
-        else
-            return Bootstrap.getBrokerFactory(cp, loader);
+        if (poolValue == null || !((Boolean) poolValue).booleanValue()) {
+            return Bootstrap.newBrokerFactory(cp);
+        } else {
+            return Bootstrap.getBrokerFactory(cp);
+        }
     }
 
     public OpenJPAEntityManagerFactory createEntityManagerFactory(String name, Map m) {
@@ -154,7 +165,9 @@ public class PersistenceProviderImpl
     }
 
     public OpenJPAEntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo pui, Map m) {
-        PersistenceProductDerivation pd = new PersistenceProductDerivation();
+        PersistenceProductDerivation pd = BundleUtils.runningUnderOSGi() 
+        		? new OSGiDerivation() 
+        		: new PersistenceProductDerivation();
         try {
             Object poolValue = Configurations.removeProperty(EMF_POOL, m);
             ConfigurationProvider cp = pd.load(pui, m);
@@ -172,20 +185,14 @@ public class PersistenceProviderImpl
                 transformerException = e;
             }
 
-            // if the BrokerImpl hasn't been specified, switch to the
-            // non-finalizing one, since anything claiming to be a container
-            // should be doing proper resource management.
+            // if the BrokerImpl hasn't been specified, switch to the non-finalizing one, 
+            // since anything claiming to be a container should be doing proper resource management.
             if (!Configurations.containsProperty(BrokerValue.KEY, cp.getProperties())) {
                 cp.addProperty("openjpa." + BrokerValue.KEY, getDefaultBrokerAlias());
             }
 
-            // OPENJPA-1491 If running under OSGi, use the Bundle's ClassLoader instead of the application one
-            BrokerFactory factory;
-            if (BundleUtils.runningUnderOSGi()) {
-                factory = getBrokerFactory(cp, poolValue, BundleUtils.getBundleClassLoader());
-            } else {
-                factory = getBrokerFactory(cp, poolValue, pui.getClassLoader());
-            }
+            BrokerFactory factory = getBrokerFactory(cp, poolValue);
+            
 
             OpenJPAConfiguration conf = factory.getConfiguration();
             setPersistenceEnvironmentInfo(conf, pui);
@@ -271,44 +278,34 @@ public class PersistenceProviderImpl
             final ClassLoader tmpLoader, OpenJPAConfiguration conf) {
             cp.setInto(conf);
             // use the temporary loader for everything
-            conf.setClassResolver(new ClassResolver() {
-                public ClassLoader getClassLoader(Class<?> context, ClassLoader env) {
-                    return tmpLoader;
-                }
-            });
+            conf.addClassLoader(tmpLoader);
             conf.setReadOnly(Configuration.INIT_STATE_FREEZING);
 
             MetaDataRepository repos = conf.getMetaDataRepositoryInstance();
             repos.setResolve(MetaDataModes.MODE_MAPPING, false);
-            _trans = new PCClassFileTransformer(repos,
-                Configurations.parseProperties(props), tmpLoader);
+            _trans = new PCClassFileTransformer(repos, Configurations.parseProperties(props), tmpLoader);
         }
 
         public byte[] transform(ClassLoader cl, String name,
-            Class<?> previousVersion, ProtectionDomain pd, byte[] bytes)
+        		Class<?> previousVersion, ProtectionDomain pd, byte[] bytes)
             throws IllegalClassFormatException {
             return _trans.transform(cl, name, previousVersion, pd, bytes);
         }
 	}
     
     /**
-     * This private worker method will attempt load the PCEnhancerAgent.
+     * Loads the PCEnhancerAgent.
      */
     private void loadAgent(BrokerFactory factory) {
         OpenJPAConfiguration conf = factory.getConfiguration();
-        Log log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);
-
-        if (conf.getDynamicEnhancementAgent() == true) {
-            boolean res = PCEnhancerAgent.loadDynamicAgent(log);
-            if (log.isInfoEnabled() && res == true ){
-                log.info(_loc.get("dynamic-agent"));
-            }
-        }
+        if (conf.getRuntimeUnenhancedClassesConstant() == RuntimeUnenhancedClassesModes.SUPPORTED
+         && conf.getDynamicEnhancementAgent()) {
+            boolean res = PCEnhancerAgent.loadDynamicAgent(conf);
+         }
     }
     
     /**
-     * This private worker method will attempt to setup the proper
-     * LifecycleEventManager type based on if the javax.validation APIs are
+     * Sets up the proper LifecycleEventManager type based on if the <tt>javax.validation APIs</tt> are
      * available and a ValidatorImpl is required by the configuration.
      * @param log
      * @param conf
@@ -318,8 +315,7 @@ public class PersistenceProviderImpl
         OpenJPAConfiguration conf = factory.getConfiguration();
         Log log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);
 
-        if ((ValidationUtils.setupValidation(conf) == true) &&
-                log.isInfoEnabled()) {
+        if ((ValidationUtils.setupValidation(conf) == true) && log.isInfoEnabled()) {
             log.info(_loc.get("vlem-creation-info"));
         }
     }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java Sat Oct 29 00:44:11 2011
@@ -62,14 +62,12 @@ public class PersistenceUnitInfoImpl
     public static final String PERSISTENCE_VERSION = "PersistenceVersion";
     
 
-    private static final Localizer s_loc = Localizer.forPackage
-        (PersistenceUnitInfoImpl.class);
+    private static final Localizer s_loc = Localizer.forPackage(PersistenceUnitInfoImpl.class);
 
     private String _name;
     private final HashMap<Object,Object> _props = new HashMap<Object, Object>();
-    private PersistenceUnitTransactionType _transType =
-        PersistenceUnitTransactionType.RESOURCE_LOCAL;
-
+    private PersistenceUnitTransactionType _transType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
+    private ClassLoader _loader;
     private String _providerClassName;
     private List<String> _mappingFileNames;
     private List<String> _entityClassNames;
@@ -98,8 +96,11 @@ public class PersistenceUnitInfoImpl
     // - an application client jar file
     private URL _root;
 
+    public PersistenceUnitInfoImpl() {
+    }
+    
     public ClassLoader getClassLoader() {
-        return null;
+        return _loader;
     }
 
     public ClassLoader getNewTempClassLoader() {
@@ -570,4 +571,8 @@ public class PersistenceUnitInfoImpl
     public void setSharedCacheMode(SharedCacheMode mode) { 
         _sharedCacheMode = mode;
     }
+    
+    public String toString() {
+    	return getPersistenceXmlFileUrl().toString() + '#' + getPersistenceUnitName();
+    }
 }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCacheImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCacheImpl.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCacheImpl.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/StoreCacheImpl.java Sat Oct 29 00:44:11 2011
@@ -141,7 +141,7 @@ public class StoreCacheImpl 
      */
     private ClassMetaData getMetaData(Class cls) {
         try {
-            return _repos.getMetaData(cls, null, true);
+            return _repos.getMetaData(cls, true);
         } catch (RuntimeException re) {
             throw PersistenceExceptions.toPersistenceException(re);
         }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java Sat Oct 29 00:44:11 2011
@@ -116,8 +116,7 @@ public class XMLPersistenceMetaDataParse
         SEQUENCE_GEN_SCHEMA
     }    
 
-    private static final Map<String, Object> _elems =
-        new HashMap<String, Object>();
+    private static final Map<String, Object> _elems = new HashMap<String, Object>();
 
     // Map for storing deferred metadata which needs to be populated
     // after embeddables are loaded.
@@ -185,13 +184,12 @@ public class XMLPersistenceMetaDataParse
         _elems.put("map-key-class", MAP_KEY_CLASS);
     }
 
-    private static final Localizer _loc = Localizer.forPackage
-        (XMLPersistenceMetaDataParser.class);
+    private static final Localizer _loc = Localizer.forPackage(XMLPersistenceMetaDataParser.class);
 
     private final OpenJPAConfiguration _conf;
     private MetaDataRepository _repos = null;
     private AnnotationPersistenceMetaDataParser _parser = null;
-    private ClassLoader _envLoader = null;
+//    private ClassLoader _envLoader = null;
     private int _mode = MODE_NONE;
     private boolean _override = false;
 
@@ -224,6 +222,7 @@ public class XMLPersistenceMetaDataParse
      * Constructor; supply configuration.
      */
     public XMLPersistenceMetaDataParser(OpenJPAConfiguration conf) {
+    	super(conf.getClassLoader());
         _conf = conf;
         setValidating(true);
         setLog(conf.getLog(OpenJPAConfiguration.LOG_METADATA));
@@ -280,31 +279,23 @@ public class XMLPersistenceMetaDataParse
         if (repos != null
             && (repos.getValidate() & MetaDataRepository.VALIDATE_RUNTIME) != 0)
             setParseComments(false);
-        
-        if (repos != null) {
-            // Determine if the Thread Context Classloader needs to be temporally overridden to the Classloader
-            // that loaded the OpenJPA classes, to avoid a potential deadlock issue with the way Xerces
-            // handles parsers and classloaders.
-            this.setOverrideContextClassloader(repos.getConfiguration().getCompatibilityInstance().
-                getOverrideContextClassloader());
-        }
     }
 
     /**
      * Return the environmental class loader to pass on to parsed
      * metadata instances.
      */
-    public ClassLoader getEnvClassLoader() {
-        return _envLoader;
-    }
+//    public ClassLoader getEnvClassLoader() {
+//        return _envLoader;
+//    }
 
     /**
      * Set the environmental class loader to pass on to parsed
      * metadata instances.
      */
-    public void setEnvClassLoader(ClassLoader loader) {
-        _envLoader = loader;
-    }
+//    public void setEnvClassLoader(ClassLoader loader) {
+//        _envLoader = loader;
+//    }
 
     /**
      * Whether to allow later parses of mapping information to override
@@ -383,8 +374,7 @@ public class XMLPersistenceMetaDataParse
         } catch (Throwable t) {
                 Log log = getLog();
                 if (log.isInfoEnabled())
-                    log.trace(_loc.get("version-check-error",
-                        file.toString()));
+                    log.trace(_loc.get("version-check-error", file.toString()));
         }
         super.parse(file);
     }
@@ -882,7 +872,7 @@ public class XMLPersistenceMetaDataParse
             && ((isMetaDataMode() && (meta.getSourceMode() & MODE_META) != 0)
             || (isMappingMode() && (meta.getSourceMode() & MODE_MAPPING) != 0)))
         {
-            if(isDuplicateClass(meta)) { 
+            if (isDuplicateClass(meta)) { 
                 if (log.isWarnEnabled()) {
                     log.warn(_loc.get("dup-metadata", _cls, getSourceName()));
                 }
@@ -911,7 +901,6 @@ public class XMLPersistenceMetaDataParse
                     fmds[i].setExplicit(true);
                 }
             }
-            meta.setEnvClassLoader(_envLoader);
             meta.setSourceMode(MODE_NONE);
 
             // parse annotations first so XML overrides them

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataSerializer.java Sat Oct 29 00:44:11 2011
@@ -960,7 +960,7 @@ public class XMLPersistenceMetaDataSeria
             ClassMetaData meta = fmd.getEmbeddedMetaData();
             ClassMetaData owner = getConfiguration().
                 getMetaDataRepositoryInstance().getMetaData
-                (meta.getDescribedType(), meta.getEnvClassLoader(), true);
+                (meta.getDescribedType(), true);
             FieldMetaData eorig;
             for (FieldMetaData efmd : meta.getFields()) {
                 eorig = owner.getField(efmd.getName());

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaExpressionBuilder.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaExpressionBuilder.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaExpressionBuilder.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaExpressionBuilder.java Sat Oct 29 00:44:11 2011
@@ -92,7 +92,7 @@ class CriteriaExpressionBuilder {
             for (Join<?,?> join : root.getJoins()) {
                 Class<?> cls = join.getAttribute().getJavaType();
                 if (join.getAttribute().isAssociation()) {
-                    ClassMetaData meta = metamodel.getRepository().getMetaData(cls, null, true);
+                    ClassMetaData meta = metamodel.getRepository().getMetaData(cls, true);
                     PersistenceType type = MetamodelImpl.getPersistenceType(meta);
                     if (type == PersistenceType.ENTITY || type == PersistenceType.EMBEDDABLE) 
                         metas.add(meta);

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/Expressions.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/Expressions.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/Expressions.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/Expressions.java Sat Oct 29 00:44:11 2011
@@ -1056,7 +1056,7 @@ class Expressions {
                 ClassMetaData can = ((Types.Entity<X>)q.getRoot().getModel()).meta;
                 Class<?> candidate = can.getDescribedType();
                 if (candidate.isAssignableFrom((Class)value)) {
-                   lit.setMetaData(q.getMetamodel().getRepository().getMetaData((Class<?>)value, null, true));
+                   lit.setMetaData(q.getMetamodel().getRepository().getMetaData((Class<?>)value, true));
                 } else {
                     lit.setMetaData(can);
                 }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java Sat Oct 29 00:44:11 2011
@@ -82,9 +82,9 @@ public class MetamodelImpl implements Me
      */
     public MetamodelImpl(MetaDataRepository repos) {
         this.repos = repos;
-        Collection<Class<?>> classes = repos.loadPersistentTypes(true, null);
+        Collection<Class<?>> classes = repos.loadPersistentTypes(true);
         for (Class<?> cls : classes) {
-        	ClassMetaData meta = repos.getMetaData(cls, null, true);
+        	ClassMetaData meta = repos.getMetaData(cls, true);
             PersistenceType type = getPersistenceType(meta);
             switch (type) {
             case ENTITY:
@@ -221,7 +221,7 @@ public class MetamodelImpl implements Me
             PersistenceType expected) {
         if (container.containsKey(cls))
             return container.get(cls);
-        ClassMetaData meta = repos.getMetaData(cls, null, false);
+        ClassMetaData meta = repos.getMetaData(cls, false);
         if (meta != null) {
             instantiate(cls, meta, container, expected);
         }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/BundleDelegatingClassLoader.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/BundleDelegatingClassLoader.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/BundleDelegatingClassLoader.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/BundleDelegatingClassLoader.java Sat Oct 29 00:44:11 2011
@@ -28,7 +28,6 @@ import org.osgi.framework.Bundle;
  * This is a simple ClassLoader that delegates to the Bundle
  * and is used by the PersistenceUnitInfo
  *
- * @version $Rev$ $Date$
  */
 public class BundleDelegatingClassLoader extends ClassLoader {
 

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/BundleUtils.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/BundleUtils.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/BundleUtils.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/BundleUtils.java Sat Oct 29 00:44:11 2011
@@ -25,7 +25,6 @@ package org.apache.openjpa.persistence.o
  * All routines MUST use reflection, so we don't have any hard-coded
  * runtime depends on OSGi classes for Java SE and EE users.
  *
- * @version $Rev$ $Date$
  */
 public class BundleUtils {
 

Added: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/OSGiDerivation.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/OSGiDerivation.java?rev=1190716&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/OSGiDerivation.java (added)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/OSGiDerivation.java Sat Oct 29 00:44:11 2011
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.osgi;
+
+import org.apache.openjpa.lib.conf.ConfigurationProvider;
+import org.apache.openjpa.persistence.PersistenceProductDerivation;
+
+/**
+ * Derives for OSGi environment. Adds bundle class loader in class loading scheme.
+ * 
+ * @author Pinaki Poddar
+ *
+ */
+public class OSGiDerivation extends PersistenceProductDerivation {
+
+	@Override
+	public void validate() throws Exception {
+		if (!BundleUtils.runningUnderOSGi()) {
+			throw new RuntimeException("Not running in OSGi environment");
+		}
+	}
+
+	@Override
+	public boolean beforeConfigurationConstruct(ConfigurationProvider cp) {
+		cp.getClassLoader().addClassLoader(BundleUtils.getBundleClassLoader());
+		super.beforeConfigurationConstruct(cp);
+		return true;
+	}
+}

Propchange: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/osgi/OSGiDerivation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidationUtils.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidationUtils.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidationUtils.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidationUtils.java Sat Oct 29 00:44:11 2011
@@ -29,17 +29,15 @@ import org.apache.openjpa.validation.Val
 
 /**
  * Validation helper routines and wrappers to remove runtime dependencies
- * on the Bean Valdiation APIs or a implementation.
+ * on the Bean Validation APIs or a implementation.
  * 
  * Note:  This class should have no direct dependency on the javax.validation
  *        packages, which should only occur in the ValidatorImpl class.
  *
- * @version $Rev$ $Date$
  */
 public class ValidationUtils {
 
-    private static final Localizer _loc = Localizer.forPackage(
-        ValidationUtils.class);
+    private static final Localizer _loc = Localizer.forPackage(ValidationUtils.class);
 
     /**
      * Setup Validation support by determining if the javax.validation APIs
@@ -50,84 +48,76 @@ public class ValidationUtils {
      * @throws If a Validator was required but could not be created.
      */
     public static boolean setupValidation(OpenJPAConfiguration conf) {
+    	if (conf.getValidationMode().equalsIgnoreCase(String.valueOf(ValidationMode.NONE))) {
+    		return false;
+    	}
         Log log = conf.getConfigurationLog();
         boolean brc = false;
         
         // only try creating a Validator for JPA2 and if not mode==NONE
+        
         if (conf.getSpecificationInstance().getVersion() < 2) {
             if (log.isTraceEnabled()) {
-                log.trace("Not creating a ValidatorImpl because " +
-                    "this app is using the JPA 1.0 Spec");
+                log.trace("Bean Validator not created because JPA specification version is " + 
+                		conf.getSpecificationInstance());
             }
+            return false;
         }
-        else if (!(String.valueOf(ValidationMode.NONE)
-                .equalsIgnoreCase(conf.getValidationMode()))) {
             // we'll use this in the exception handlers
-            boolean bValRequired = String.valueOf(ValidationMode.CALLBACK)
-                .equalsIgnoreCase(conf.getValidationMode());
-            try {
-                // see if the javax.validation spec api is available
+        boolean bValRequired = String.valueOf(ValidationMode.CALLBACK)
+            .equalsIgnoreCase(conf.getValidationMode());
+        try {
+            // see if the javax.validation spec api is available
+            @SuppressWarnings("unused")
+            Class<?> c = Class.forName("javax.validation.ValidationException");
+        } catch (ClassNotFoundException e) {
+            if (bValRequired) {
+                // fatal error - ValidationMode requires a validator
+                Message msg = _loc.get("vlem-creation-error");
+                log.error(msg, e);
+                // rethrow as a more descriptive/identifiable exception
+                throw new ValidationUnavailableException(
+                    msg.getMessage(),
+                    new RuntimeException(e), true);
+            } else {
+                // no optional validation provider, so just trace output
                 if (log.isTraceEnabled()) {
-                    log.trace("Trying to load javax.validation APIs " +
-                        "based on the ValidationMode="
-                        + conf.getValidationMode());
-                }
-                @SuppressWarnings("unused")
-                Class<?> c = Class.forName(
-                    "javax.validation.ValidationException");
-            } catch (ClassNotFoundException e) {
-                if (bValRequired) {
-                    // fatal error - ValidationMode requires a validator
-                    Message msg = _loc.get("vlem-creation-error");
-                    log.error(msg, e);
-                    // rethrow as a more descriptive/identifiable exception
-                    throw new ValidationUnavailableException(
-                        msg.getMessage(),
-                        new RuntimeException(e), true);
-                } else {
-                    // no optional validation provider, so just trace output
-                    if (log.isTraceEnabled()) {
-                        log.trace(_loc.get("vlem-creation-warn",
-                            "No available javax.validation APIs"));
-                    }
-                    return brc;
+                    log.trace(_loc.get("vlem-creation-warn",
+                        "No available javax.validation APIs"));
                 }
+                return brc;
             }
-            // we have the javax.validation APIs
-            try {
-                // try loading a validation provider
-                ValidatorImpl validator = new ValidatorImpl(conf);
-                // set the Validator into the config
-                conf.setValidatorInstance(validator);
-                // update the LifecycleEventManager plugin to use it
-                conf.setLifecycleEventManager("validating");
-                // all done, so return good rc if anyone cares
-                brc = true;
-            } catch (RuntimeException e) {
-                if (bValRequired) {
-                    // fatal error - ValidationMode requires a validator
-                    // rethrow as a WrappedException
-                    Message msg = _loc.get("vlem-creation-error");
-                    log.error(msg, e);
-                    // rethrow as a more descriptive/identifiable exception
-                    throw new ValidationUnavailableException(
-                        msg.getMessage(),
-                        e, true);
+        }
+        // we have the javax.validation APIs
+        try {
+            // try loading a validation provider
+            ValidatorImpl validator = new ValidatorImpl(conf);
+            // set the Validator into the config
+            conf.setValidatorInstance(validator);
+            // update the LifecycleEventManager plugin to use it
+            conf.setLifecycleEventManager("validating");
+            // all done, so return good rc if anyone cares
+            brc = true;
+        } catch (RuntimeException e) {
+            if (bValRequired) {
+                // fatal error - ValidationMode requires a validator
+                // rethrow as a WrappedException
+                Message msg = _loc.get("vlem-creation-error");
+                log.error(msg, e);
+                // rethrow as a more descriptive/identifiable exception
+                throw new ValidationUnavailableException(
+                    msg.getMessage(),
+                    e, true);
 
-                } else {
-                    // unexpected, but validation is optional,
-                    // so just log it as a warning
-                    String msg = e.getMessage();
-                    log.warn(_loc.get("vlem-creation-warn", msg == null ? e : msg ));
-                    return brc;
-                }
-            }
-        } else {
-            if (log.isTraceEnabled()) {
-                log.trace("Not creating a ValidatorImpl because " +
-                    "ValidationMode=" + conf.getValidationMode());
+            } else {
+                // unexpected, but validation is optional,
+                // so just log it as a warning
+                String msg = e.getMessage();
+                log.warn(_loc.get("vlem-creation-warn", msg == null ? e : msg ));
+                return brc;
             }
         }
+        
         return brc;
     }
 

Modified: openjpa/trunk/openjpa-persistence/src/main/resources/META-INF/services/org.apache.openjpa.lib.conf.ProductDerivation
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/resources/META-INF/services/org.apache.openjpa.lib.conf.ProductDerivation?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/resources/META-INF/services/org.apache.openjpa.lib.conf.ProductDerivation (original)
+++ openjpa/trunk/openjpa-persistence/src/main/resources/META-INF/services/org.apache.openjpa.lib.conf.ProductDerivation Sat Oct 29 00:44:11 2011
@@ -15,3 +15,4 @@
 # specific language governing permissions and limitations
 # under the License.
 org.apache.openjpa.persistence.PersistenceProductDerivation
+org.apache.openjpa.persistence.osgi.OSGiDerivation

Modified: openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties (original)
+++ openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties Sat Oct 29 00:44:11 2011
@@ -186,9 +186,10 @@ unwrap-em-invalid: EntityManager can not
 unwrap-query-invalid: Query can not be unwrapped to an instance of "{0}".
 invalid_entity_argument: {0} can not be invoked on "{1}". This entity is either \
 	detached or not persistent or null.
-dup-pu: The persistence unit "{0}" was found multiple times in the following \
-    resources "{1}", but persistence unit names should be unique. The first \
-    persistence unit matching the provided name in "{2}" is being used.
+dup-pu: Multiple persistence units named "{0}" were found. \
+    The first persistence unit at "{1}" being used. The duplicate units are {2}
+dup-pu-unnamed: Multiple persistence units were found while looking for unnamed unit. \
+    The first persistence unit at "{0}" being used. The duplicate units are {1}
 bad-lock-level: Invalid lock mode/level. Valid values are \
     "none"(0), "read"(10), "optimistic"(15), "write"(20), \
     "optimistic-force-increment"(25), \

Modified: openjpa/trunk/openjpa-persistence/src/test/java/org/apache/openjpa/persistence/TestPersistenceProductDerivation.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/test/java/org/apache/openjpa/persistence/TestPersistenceProductDerivation.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/test/java/org/apache/openjpa/persistence/TestPersistenceProductDerivation.java (original)
+++ openjpa/trunk/openjpa-persistence/src/test/java/org/apache/openjpa/persistence/TestPersistenceProductDerivation.java Sat Oct 29 00:44:11 2011
@@ -123,9 +123,9 @@ public class TestPersistenceProductDeriv
 
 		ConfigurationProvider provider = ppd.load(
 				PersistenceProductDerivation.RSRC_DEFAULT,
-				"encryption_plugin_pu", loader);
+				"encryption_plugin_pu");
 		provider.setInto(conf);
-		EncryptionProvider ep = conf.getEncryptionProvider();
+		EncryptionProvider ep = conf.getEncryptionProviderInstance();
 		assertNotNull(ep);
 		// Cast to test impl
 		TestEncryptionProvider tep = (TestEncryptionProvider) ep;
@@ -146,10 +146,10 @@ public class TestPersistenceProductDeriv
 
 		ConfigurationProvider provider = ppd.load(
 				PersistenceProductDerivation.RSRC_DEFAULT,
-				"encryption_plugin_default_pu", loader);
+				"encryption_plugin_default_pu");
 		provider.setInto(conf);
 
-		assertNull(conf.getEncryptionProvider());
+		assertNull(conf.getEncryptionProviderInstance());
 	}
     
     /*
@@ -158,7 +158,8 @@ public class TestPersistenceProductDeriv
      */
     public void testJPA1ExcludeUnlistedClasses() throws Exception {
         PersistenceProductDerivation.ConfigurationParser cp = 
-                new PersistenceProductDerivation.ConfigurationParser(new HashMap());
+                new PersistenceProductDerivation.ConfigurationParser(this.getClass().getClassLoader(), 
+                		new HashMap());
 
         List<URL> urls = getResourceURL(PersistenceProductDerivation.RSRC_DEFAULT);
         assertNotNull(urls);
@@ -202,7 +203,8 @@ public class TestPersistenceProductDeriv
      */
     public void testExcludeUnlistedClasses() throws Exception {
         PersistenceProductDerivation.ConfigurationParser cp = 
-            new PersistenceProductDerivation.ConfigurationParser(new HashMap());
+            new PersistenceProductDerivation.ConfigurationParser(this.getClass().getClassLoader(), 
+            		new HashMap());
 
     List<URL> urls = getResourceURL("META-INF/persistence-2_0.xml");
     assertNotNull(urls);

Modified: openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCBrokerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCBrokerFactory.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCBrokerFactory.java (original)
+++ openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCBrokerFactory.java Sat Oct 29 00:44:11 2011
@@ -99,8 +99,7 @@ public class DistributedJDBCBrokerFactor
 	
 	public Slice addSlice(String name, Map properties) {
 	    Slice slice = ((DistributedJDBCConfigurationImpl)getConfiguration()).addSlice(name, properties);
-        ClassLoader loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
-        synchronizeMappings(loader, (JDBCConfiguration)slice.getConfiguration());
+        synchronizeMappings((JDBCConfiguration)slice.getConfiguration());
         Collection<Broker> brokers = getOpenBrokers();
         for (Broker broker : brokers) {
             ((DistributedBroker)broker).getDistributedStoreManager().addSlice(slice);
@@ -118,10 +117,10 @@ public class DistributedJDBCBrokerFactor
         return new DistributedBrokerImpl();
     }
     
-    protected void synchronizeMappings(ClassLoader loader) {
+    protected void synchronizeMappings() {
         List<Slice> slices = getConfiguration().getSlices(Slice.Status.ACTIVE);
         for (Slice slice : slices) {
-            synchronizeMappings(loader, (JDBCConfiguration) slice.getConfiguration());
+            synchronizeMappings((JDBCConfiguration) slice.getConfiguration());
         }
     }
 

Modified: openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java (original)
+++ openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java Sat Oct 29 00:44:11 2011
@@ -79,10 +79,10 @@ public class DistributedJDBCConfiguratio
     protected BooleanValue lenientPlugin;
     protected StringValue masterPlugin;
     protected StringListValue namesPlugin;
-    public PluginValue distributionPolicyPlugin;
-    public PluginValue replicationPolicyPlugin;
-    public PluginValue queryTargetPolicyPlugin;
-    public PluginValue finderTargetPolicyPlugin;
+    public PluginValue<DistributionPolicy> distributionPolicyPlugin;
+    public PluginValue<ReplicationPolicy> replicationPolicyPlugin;
+    public PluginValue<QueryTargetPolicy> queryTargetPolicyPlugin;
+    public PluginValue<FinderTargetPolicy> finderTargetPolicyPlugin;
     public StringListValue replicatedTypesPlugin;
     
     private ReplicatedTypeRepository _replicationRepos;
@@ -101,22 +101,22 @@ public class DistributedJDBCConfiguratio
               false); // load globals
         brokerPlugin.setString(DistributedBrokerImpl.class.getName());
         
-        distributionPolicyPlugin = addPlugin(PREFIX_SLICE + "DistributionPolicy", true);
+        distributionPolicyPlugin = addPlugin(DistributionPolicy.class, PREFIX_SLICE + "DistributionPolicy", true);
         distributionPolicyPlugin.setAlias("random", DistributionPolicy.Default.class.getName());
         distributionPolicyPlugin.setDefault("random");
         distributionPolicyPlugin.setString("random");
         distributionPolicyPlugin.setDynamic(true);
         
-        replicationPolicyPlugin = addPlugin(PREFIX_SLICE + "ReplicationPolicy", true);
+        replicationPolicyPlugin = addPlugin(ReplicationPolicy.class, PREFIX_SLICE + "ReplicationPolicy", true);
         replicationPolicyPlugin.setAlias("all", ReplicationPolicy.Default.class.getName());
         replicationPolicyPlugin.setDefault("all");
         replicationPolicyPlugin.setString("all");
         replicationPolicyPlugin.setDynamic(true);
         
-        queryTargetPolicyPlugin = addPlugin(PREFIX_SLICE + "QueryTargetPolicy", true);
+        queryTargetPolicyPlugin = addPlugin(QueryTargetPolicy.class, PREFIX_SLICE + "QueryTargetPolicy", true);
         queryTargetPolicyPlugin.setDynamic(true);
         
-        finderTargetPolicyPlugin = addPlugin(PREFIX_SLICE + "FinderTargetPolicy", true);
+        finderTargetPolicyPlugin = addPlugin(FinderTargetPolicy.class, PREFIX_SLICE + "FinderTargetPolicy", true);
         finderTargetPolicyPlugin.setDynamic(true);
         
         replicatedTypesPlugin = new StringListValue(PREFIX_SLICE + "ReplicatedTypes");
@@ -212,16 +212,14 @@ public class DistributedJDBCConfiguratio
 
     public DistributionPolicy getDistributionPolicyInstance() {
         if (distributionPolicyPlugin.get() == null) {
-            distributionPolicyPlugin.instantiate(DistributionPolicy.class,
-                    this, true);
+            distributionPolicyPlugin.instantiate(this, true);
         }
         return (DistributionPolicy) distributionPolicyPlugin.get();
     }
     
     public String getDistributionPolicy() {
         if (distributionPolicyPlugin.get() == null) {
-            distributionPolicyPlugin.instantiate(DistributionPolicy.class,
-                    this, true);
+            distributionPolicyPlugin.instantiate(this, true);
         }
         return distributionPolicyPlugin.getString();
     }
@@ -236,16 +234,14 @@ public class DistributedJDBCConfiguratio
 
     public ReplicationPolicy getReplicationPolicyInstance() {
         if (replicationPolicyPlugin.get() == null) {
-            replicationPolicyPlugin.instantiate(ReplicationPolicy.class,
-                    this, true);
+            replicationPolicyPlugin.instantiate(this, true);
         }
-        return (ReplicationPolicy) replicationPolicyPlugin.get();
+        return replicationPolicyPlugin.get();
     }
     
     public String getReplicationPolicy() {
         if (replicationPolicyPlugin.get() == null) {
-            replicationPolicyPlugin.instantiate(ReplicationPolicy.class,
-                    this, true);
+            replicationPolicyPlugin.instantiate(this, true);
         }
         return replicationPolicyPlugin.getString();
     }
@@ -260,16 +256,14 @@ public class DistributedJDBCConfiguratio
 
     public QueryTargetPolicy getQueryTargetPolicyInstance() {
         if (queryTargetPolicyPlugin.get() == null) {
-            queryTargetPolicyPlugin.instantiate(ReplicationPolicy.class,
-                    this, true);
+            queryTargetPolicyPlugin.instantiate(this, true);
         }
-        return (QueryTargetPolicy) queryTargetPolicyPlugin.get();
+        return queryTargetPolicyPlugin.get();
     }
     
     public String getQueryTargetPolicy() {
         if (queryTargetPolicyPlugin.get() == null) {
-            queryTargetPolicyPlugin.instantiate(QueryTargetPolicy.class,
-                    this, true);
+            queryTargetPolicyPlugin.instantiate(this, true);
         }
         return queryTargetPolicyPlugin.getString();
     }
@@ -284,16 +278,14 @@ public class DistributedJDBCConfiguratio
     
     public FinderTargetPolicy getFinderTargetPolicyInstance() {
         if (finderTargetPolicyPlugin.get() == null) {
-            finderTargetPolicyPlugin.instantiate(ReplicationPolicy.class,
-                    this, true);
+            finderTargetPolicyPlugin.instantiate(this, true);
         }
-        return (FinderTargetPolicy) finderTargetPolicyPlugin.get();
+        return finderTargetPolicyPlugin.get();
     }
     
     public String getFinderTargetPolicy() {
         if (finderTargetPolicyPlugin.get() == null) {
-            finderTargetPolicyPlugin.instantiate(FinderTargetPolicy.class,
-                    this, true);
+            finderTargetPolicyPlugin.instantiate(this, true);
         }
         return finderTargetPolicyPlugin.getString();
     }
@@ -309,8 +301,7 @@ public class DistributedJDBCConfiguratio
     public DistributedDataSource getConnectionFactory() {
         if (virtualDataSource == null) {
             virtualDataSource = createDistributedDataStore();
-            DataSourceFactory.installDBDictionary(
-                getDBDictionaryInstance(), virtualDataSource, this, false);
+            DataSourceFactory.installDBDictionary(getDBDictionaryInstance(), virtualDataSource, this, false);
         }
         return virtualDataSource;
     }
@@ -661,7 +652,7 @@ public class DistributedJDBCConfiguratio
                 return true;
             if (_nonreplicatedTypes.contains(cls)) 
                 return false;
-            ClassMetaData meta = repos.getMetaData(cls, null, false);
+            ClassMetaData meta = repos.getMetaData(cls, false);
             if (meta == null) {
                 _nonreplicatedTypes.add(cls);
                 return false;

Modified: openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java (original)
+++ openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java Sat Oct 29 00:44:11 2011
@@ -175,7 +175,7 @@ class DistributedStoreQuery extends JDBC
 				result = new MergedResultObjectProvider(tmp);
 			}
 			if (hasRange) {
-                result = new RangeResultObjectProvider(result,
+                result = new RangeResultObjectProvider(result, 
                         ctx.getStartRange(), ctx.getEndRange());
 			}
 			return result;

Modified: openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/SingleEMFTestCase.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/SingleEMFTestCase.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/SingleEMFTestCase.java (original)
+++ openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/SingleEMFTestCase.java Sat Oct 29 00:44:11 2011
@@ -69,8 +69,6 @@ public abstract class SingleEMFTestCase
     }
     
     protected ClassMapping getMapping(String name) {
-        return (ClassMapping) emf.getConfiguration()
-                .getMetaDataRepositoryInstance().getMetaData(name,
-                        getClass().getClassLoader(), true);
+        return (ClassMapping) emf.getConfiguration().getMetaDataRepositoryInstance().getMetaData(name, true);
     }
 }

Modified: openjpa/trunk/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java?rev=1190716&r1=1190715&r2=1190716&view=diff
==============================================================================
--- openjpa/trunk/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java (original)
+++ openjpa/trunk/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java Sat Oct 29 00:44:11 2011
@@ -360,7 +360,7 @@ public class XMLFileHandler {
                     // get the metadata for the type we're reading
                     String type = attrs.getValue("class");
                     ClassMetaData meta = _conf.getMetaDataRepositoryInstance().
-                        getMetaData(classForName(type), null, true);
+                        getMetaData(classForName(type), true);
 
                     // construct the oid object
                     Object oid;
@@ -578,11 +578,8 @@ public class XMLFileHandler {
         /**
          * Return the class for the specified name.
          */
-        private Class classForName(String name)
-            throws Exception {
-            ClassLoader loader = _conf.getClassResolverInstance().
-                getClassLoader(getClass(), null);
-            return Class.forName(name, true, loader);
+        private Class classForName(String name) throws Exception {
+            return Class.forName(name, true, _conf.getClassLoader());
         }
     }
 



Mime
View raw message