OPENJPA-2133: OpenJPA doesn't find custom mappings with an applicable class loader

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1333982 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jody Grassel 2012-05-04 14:18:19 +00:00
parent 432499a3a6
commit 8c8e250f40
2 changed files with 15 additions and 4 deletions

View File

@ -546,7 +546,7 @@ public class MappingRepository extends MetaDataRepository {
strat = JavaTypes.classForName(name, cls,
AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(
ClassStrategy.class)));
ClassStrategy.class)), false);
ClassStrategy strategy =
(ClassStrategy) AccessController.doPrivileged(
J2DoPrivHelper.newInstanceAction(strat));
@ -579,7 +579,7 @@ public class MappingRepository extends MetaDataRepository {
try {
Class<?> c = JavaTypes.classForName(name, field,
AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(FieldStrategy.class)));
J2DoPrivHelper.getClassLoaderAction(FieldStrategy.class)), false);
if (FieldStrategy.class.isAssignableFrom(c)) {
FieldStrategy strat = (FieldStrategy)
AccessController.doPrivileged(
@ -653,7 +653,7 @@ public class MappingRepository extends MetaDataRepository {
discrim.getClassMapping(),
AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(
DiscriminatorStrategy.class)));
DiscriminatorStrategy.class)), false);
DiscriminatorStrategy strategy = (DiscriminatorStrategy)
AccessController.doPrivileged(
J2DoPrivHelper.newInstanceAction(strat));
@ -719,7 +719,7 @@ public class MappingRepository extends MetaDataRepository {
version.getClassMapping(),
AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(
VersionStrategy.class)));
VersionStrategy.class)), false);
} catch (Exception e) {
throw new MetaDataException(_loc.get("bad-version-strategy",
version.getClassMapping(), name), e);

View File

@ -186,6 +186,17 @@ public class JavaTypes {
return classForName(name, context, context.getDescribedType(), null,
loader);
}
/**
* Check the given name against the same set of standard packages used
* when parsing metadata.
*
* @param mustExist Whether the supplied loader <b>must</b> be able to load the class. If true no attempt to use a
* different classloader will be made. If false the ClassResolver from the configuration will be used.
*/
public static Class<?> classForName(String name, ClassMetaData context, ClassLoader loader, boolean mustExist) {
return classForName(name, context, context.getDescribedType(), null, loader, mustExist);
}
/**
* Check the given name against the same set of standard packages used