openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r1197994 [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, 05 Nov 2011 17:17:33 GMT
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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -116,7 +116,8 @@ 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.
@@ -184,12 +185,13 @@ 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;
 
@@ -222,7 +224,6 @@ public class XMLPersistenceMetaDataParse
      * Constructor; supply configuration.
      */
     public XMLPersistenceMetaDataParser(OpenJPAConfiguration conf) {
-    	super(conf.getClassLoader());
         _conf = conf;
         setValidating(true);
         setLog(conf.getLog(OpenJPAConfiguration.LOG_METADATA));
@@ -279,23 +280,31 @@ 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
@@ -374,7 +383,8 @@ 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);
     }
@@ -872,7 +882,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()));
                 }
@@ -901,6 +911,7 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -960,7 +960,7 @@ public class XMLPersistenceMetaDataSeria
             ClassMetaData meta = fmd.getEmbeddedMetaData();
             ClassMetaData owner = getConfiguration().
                 getMetaDataRepositoryInstance().getMetaData
-                (meta.getDescribedType(), true);
+                (meta.getDescribedType(), meta.getEnvClassLoader(), 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 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, true);
+                    ClassMetaData meta = metamodel.getRepository().getMetaData(cls, null,
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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 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,
true));
+                   lit.setMetaData(q.getMetamodel().getRepository().getMetaData((Class<?>)value,
null, 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -82,9 +82,9 @@ public class MetamodelImpl implements Me
      */
     public MetamodelImpl(MetaDataRepository repos) {
         this.repos = repos;
-        Collection<Class<?>> classes = repos.loadPersistentTypes(true);
+        Collection<Class<?>> classes = repos.loadPersistentTypes(true, null);
         for (Class<?> cls : classes) {
-        	ClassMetaData meta = repos.getMetaData(cls, true);
+        	ClassMetaData meta = repos.getMetaData(cls, null, 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, false);
+        ClassMetaData meta = repos.getMetaData(cls, null, 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -28,6 +28,7 @@ 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -25,6 +25,7 @@ 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 {
 

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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -29,15 +29,17 @@ import org.apache.openjpa.validation.Val
 
 /**
  * Validation helper routines and wrappers to remove runtime dependencies
- * on the Bean Validation APIs or a implementation.
+ * on the Bean Valdiation 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
@@ -48,76 +50,84 @@ 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("Bean Validator not created because JPA specification version is
" + 
-                		conf.getSpecificationInstance());
+                log.trace("Not creating a ValidatorImpl because " +
+                    "this app is using the JPA 1.0 Spec");
             }
-            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
-            @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
+            boolean bValRequired = String.valueOf(ValidationMode.CALLBACK)
+                .equalsIgnoreCase(conf.getValidationMode());
+            try {
+                // see if the javax.validation spec api is available
                 if (log.isTraceEnabled()) {
-                    log.trace(_loc.get("vlem-creation-warn",
-                        "No available javax.validation APIs"));
+                    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;
                 }
-                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 {
+                    // 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());
             }
         }
-        
         return brc;
     }
 

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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -186,10 +186,9 @@ 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: 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}
+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.
 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -123,9 +123,9 @@ public class TestPersistenceProductDeriv
 
 		ConfigurationProvider provider = ppd.load(
 				PersistenceProductDerivation.RSRC_DEFAULT,
-				"encryption_plugin_pu");
+				"encryption_plugin_pu", loader);
 		provider.setInto(conf);
-		EncryptionProvider ep = conf.getEncryptionProviderInstance();
+		EncryptionProvider ep = conf.getEncryptionProvider();
 		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");
+				"encryption_plugin_default_pu", loader);
 		provider.setInto(conf);
 
-		assertNull(conf.getEncryptionProviderInstance());
+		assertNull(conf.getEncryptionProvider());
 	}
     
     /*
@@ -158,8 +158,7 @@ public class TestPersistenceProductDeriv
      */
     public void testJPA1ExcludeUnlistedClasses() throws Exception {
         PersistenceProductDerivation.ConfigurationParser cp = 
-                new PersistenceProductDerivation.ConfigurationParser(this.getClass().getClassLoader(),

-                		new HashMap());
+                new PersistenceProductDerivation.ConfigurationParser(new HashMap());
 
         List<URL> urls = getResourceURL(PersistenceProductDerivation.RSRC_DEFAULT);
         assertNotNull(urls);
@@ -203,8 +202,7 @@ public class TestPersistenceProductDeriv
      */
     public void testExcludeUnlistedClasses() throws Exception {
         PersistenceProductDerivation.ConfigurationParser cp = 
-            new PersistenceProductDerivation.ConfigurationParser(this.getClass().getClassLoader(),

-            		new HashMap());
+            new PersistenceProductDerivation.ConfigurationParser(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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -99,7 +99,8 @@ public class DistributedJDBCBrokerFactor
 	
 	public Slice addSlice(String name, Map properties) {
 	    Slice slice = ((DistributedJDBCConfigurationImpl)getConfiguration()).addSlice(name,
properties);
-        synchronizeMappings((JDBCConfiguration)slice.getConfiguration());
+        ClassLoader loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
+        synchronizeMappings(loader, (JDBCConfiguration)slice.getConfiguration());
         Collection<Broker> brokers = getOpenBrokers();
         for (Broker broker : brokers) {
             ((DistributedBroker)broker).getDistributedStoreManager().addSlice(slice);
@@ -117,10 +118,10 @@ public class DistributedJDBCBrokerFactor
         return new DistributedBrokerImpl();
     }
     
-    protected void synchronizeMappings() {
+    protected void synchronizeMappings(ClassLoader loader) {
         List<Slice> slices = getConfiguration().getSlices(Slice.Status.ACTIVE);
         for (Slice slice : slices) {
-            synchronizeMappings((JDBCConfiguration) slice.getConfiguration());
+            synchronizeMappings(loader, (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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -79,10 +79,10 @@ public class DistributedJDBCConfiguratio
     protected BooleanValue lenientPlugin;
     protected StringValue masterPlugin;
     protected StringListValue namesPlugin;
-    public PluginValue<DistributionPolicy> distributionPolicyPlugin;
-    public PluginValue<ReplicationPolicy> replicationPolicyPlugin;
-    public PluginValue<QueryTargetPolicy> queryTargetPolicyPlugin;
-    public PluginValue<FinderTargetPolicy> finderTargetPolicyPlugin;
+    public PluginValue distributionPolicyPlugin;
+    public PluginValue replicationPolicyPlugin;
+    public PluginValue queryTargetPolicyPlugin;
+    public PluginValue finderTargetPolicyPlugin;
     public StringListValue replicatedTypesPlugin;
     
     private ReplicatedTypeRepository _replicationRepos;
@@ -101,22 +101,22 @@ public class DistributedJDBCConfiguratio
               false); // load globals
         brokerPlugin.setString(DistributedBrokerImpl.class.getName());
         
-        distributionPolicyPlugin = addPlugin(DistributionPolicy.class, PREFIX_SLICE + "DistributionPolicy",
true);
+        distributionPolicyPlugin = addPlugin(PREFIX_SLICE + "DistributionPolicy", true);
         distributionPolicyPlugin.setAlias("random", DistributionPolicy.Default.class.getName());
         distributionPolicyPlugin.setDefault("random");
         distributionPolicyPlugin.setString("random");
         distributionPolicyPlugin.setDynamic(true);
         
-        replicationPolicyPlugin = addPlugin(ReplicationPolicy.class, PREFIX_SLICE + "ReplicationPolicy",
true);
+        replicationPolicyPlugin = addPlugin(PREFIX_SLICE + "ReplicationPolicy", true);
         replicationPolicyPlugin.setAlias("all", ReplicationPolicy.Default.class.getName());
         replicationPolicyPlugin.setDefault("all");
         replicationPolicyPlugin.setString("all");
         replicationPolicyPlugin.setDynamic(true);
         
-        queryTargetPolicyPlugin = addPlugin(QueryTargetPolicy.class, PREFIX_SLICE + "QueryTargetPolicy",
true);
+        queryTargetPolicyPlugin = addPlugin(PREFIX_SLICE + "QueryTargetPolicy", true);
         queryTargetPolicyPlugin.setDynamic(true);
         
-        finderTargetPolicyPlugin = addPlugin(FinderTargetPolicy.class, PREFIX_SLICE + "FinderTargetPolicy",
true);
+        finderTargetPolicyPlugin = addPlugin(PREFIX_SLICE + "FinderTargetPolicy", true);
         finderTargetPolicyPlugin.setDynamic(true);
         
         replicatedTypesPlugin = new StringListValue(PREFIX_SLICE + "ReplicatedTypes");
@@ -212,14 +212,16 @@ public class DistributedJDBCConfiguratio
 
     public DistributionPolicy getDistributionPolicyInstance() {
         if (distributionPolicyPlugin.get() == null) {
-            distributionPolicyPlugin.instantiate(this, true);
+            distributionPolicyPlugin.instantiate(DistributionPolicy.class,
+                    this, true);
         }
         return (DistributionPolicy) distributionPolicyPlugin.get();
     }
     
     public String getDistributionPolicy() {
         if (distributionPolicyPlugin.get() == null) {
-            distributionPolicyPlugin.instantiate(this, true);
+            distributionPolicyPlugin.instantiate(DistributionPolicy.class,
+                    this, true);
         }
         return distributionPolicyPlugin.getString();
     }
@@ -234,14 +236,16 @@ public class DistributedJDBCConfiguratio
 
     public ReplicationPolicy getReplicationPolicyInstance() {
         if (replicationPolicyPlugin.get() == null) {
-            replicationPolicyPlugin.instantiate(this, true);
+            replicationPolicyPlugin.instantiate(ReplicationPolicy.class,
+                    this, true);
         }
-        return replicationPolicyPlugin.get();
+        return (ReplicationPolicy) replicationPolicyPlugin.get();
     }
     
     public String getReplicationPolicy() {
         if (replicationPolicyPlugin.get() == null) {
-            replicationPolicyPlugin.instantiate(this, true);
+            replicationPolicyPlugin.instantiate(ReplicationPolicy.class,
+                    this, true);
         }
         return replicationPolicyPlugin.getString();
     }
@@ -256,14 +260,16 @@ public class DistributedJDBCConfiguratio
 
     public QueryTargetPolicy getQueryTargetPolicyInstance() {
         if (queryTargetPolicyPlugin.get() == null) {
-            queryTargetPolicyPlugin.instantiate(this, true);
+            queryTargetPolicyPlugin.instantiate(ReplicationPolicy.class,
+                    this, true);
         }
-        return queryTargetPolicyPlugin.get();
+        return (QueryTargetPolicy) queryTargetPolicyPlugin.get();
     }
     
     public String getQueryTargetPolicy() {
         if (queryTargetPolicyPlugin.get() == null) {
-            queryTargetPolicyPlugin.instantiate(this, true);
+            queryTargetPolicyPlugin.instantiate(QueryTargetPolicy.class,
+                    this, true);
         }
         return queryTargetPolicyPlugin.getString();
     }
@@ -278,14 +284,16 @@ public class DistributedJDBCConfiguratio
     
     public FinderTargetPolicy getFinderTargetPolicyInstance() {
         if (finderTargetPolicyPlugin.get() == null) {
-            finderTargetPolicyPlugin.instantiate(this, true);
+            finderTargetPolicyPlugin.instantiate(ReplicationPolicy.class,
+                    this, true);
         }
-        return finderTargetPolicyPlugin.get();
+        return (FinderTargetPolicy) finderTargetPolicyPlugin.get();
     }
     
     public String getFinderTargetPolicy() {
         if (finderTargetPolicyPlugin.get() == null) {
-            finderTargetPolicyPlugin.instantiate(this, true);
+            finderTargetPolicyPlugin.instantiate(FinderTargetPolicy.class,
+                    this, true);
         }
         return finderTargetPolicyPlugin.getString();
     }
@@ -301,7 +309,8 @@ 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;
     }
@@ -652,7 +661,7 @@ public class DistributedJDBCConfiguratio
                 return true;
             if (_nonreplicatedTypes.contains(cls)) 
                 return false;
-            ClassMetaData meta = repos.getMetaData(cls, false);
+            ClassMetaData meta = repos.getMetaData(cls, null, 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 2011
@@ -69,6 +69,8 @@ public abstract class SingleEMFTestCase
     }
     
     protected ClassMapping getMapping(String name) {
-        return (ClassMapping) emf.getConfiguration().getMetaDataRepositoryInstance().getMetaData(name,
true);
+        return (ClassMapping) emf.getConfiguration()
+                .getMetaDataRepositoryInstance().getMetaData(name,
+                        getClass().getClassLoader(), 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=1197994&r1=1197993&r2=1197994&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 Nov  5 17:17:26 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), true);
+                        getMetaData(classForName(type), null, true);
 
                     // construct the oid object
                     Object oid;
@@ -578,8 +578,11 @@ public class XMLFileHandler {
         /**
          * Return the class for the specified name.
          */
-        private Class classForName(String name) throws Exception {
-            return Class.forName(name, true, _conf.getClassLoader());
+        private Class classForName(String name)
+            throws Exception {
+            ClassLoader loader = _conf.getClassResolverInstance().
+                getClassLoader(getClass(), null);
+            return Class.forName(name, true, loader);
         }
     }
 



Mime
View raw message