mirror of https://github.com/apache/openjpa.git
Adding informative messages when non-default Persistence Provider is configured.
git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@450674 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e1e96406e8
commit
24c51d9fe6
openjpa-persistence/src/main
java/org/apache/openjpa/persistence
resources/org/apache/openjpa/persistence
|
@ -248,6 +248,8 @@ public class PersistenceProductDerivation
|
||||||
rsrc, String.valueOf(name)).getMessage(), getClass().getName(),
|
rsrc, String.valueOf(name)).getMessage(), getClass().getName(),
|
||||||
rsrc);
|
rsrc);
|
||||||
} else if (!isOpenJPAPersistenceProvider(pinfo, loader)) {
|
} else if (!isOpenJPAPersistenceProvider(pinfo, loader)) {
|
||||||
|
if (!explicit)
|
||||||
|
return Boolean.FALSE;
|
||||||
throw new MissingResourceException(_loc.get("unknown-provider",
|
throw new MissingResourceException(_loc.get("unknown-provider",
|
||||||
rsrc, name, pinfo.getPersistenceProviderClassName()).
|
rsrc, name, pinfo.getPersistenceProviderClassName()).
|
||||||
getMessage(), getClass().getName(), rsrc);
|
getMessage(), getClass().getName(), rsrc);
|
||||||
|
@ -307,19 +309,31 @@ public class PersistenceProductDerivation
|
||||||
*/
|
*/
|
||||||
private static boolean isOpenJPAPersistenceProvider
|
private static boolean isOpenJPAPersistenceProvider
|
||||||
(PersistenceUnitInfo pinfo, ClassLoader loader) {
|
(PersistenceUnitInfo pinfo, ClassLoader loader) {
|
||||||
String name = pinfo.getPersistenceProviderClassName();
|
String provider = pinfo.getPersistenceProviderClassName();
|
||||||
if (StringUtils.isEmpty(name)
|
if (StringUtils.isEmpty(provider)
|
||||||
|| PersistenceProviderImpl.class.getName().equals(name))
|
|| PersistenceProviderImpl.class.getName().equals(provider))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (loader == null)
|
if (loader == null)
|
||||||
loader = Thread.currentThread().getContextClassLoader();
|
loader = Thread.currentThread().getContextClassLoader();
|
||||||
try {
|
try {
|
||||||
return PersistenceProviderImpl.class.isAssignableFrom
|
if (PersistenceProviderImpl.class.isAssignableFrom
|
||||||
(Class.forName(name, false, loader));
|
(Class.forName(provider, false, loader))) {
|
||||||
|
// log not configured yet
|
||||||
|
warn(_loc.get("extended-provider", provider).getMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
warn(_loc.get("unloadable-provider", provider, t).
|
||||||
|
getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
warn(_loc.get("unrecognized-provider", provider).getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void warn(String msg) {
|
||||||
|
System.err.println(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -93,7 +93,12 @@ multiple-methods-on-callback-error: Class "{0}" declares method "{1}" as well \
|
||||||
missing-no-arg-constructor: Entity listener class "{0}" must declare a no-arg \
|
missing-no-arg-constructor: Entity listener class "{0}" must declare a no-arg \
|
||||||
constructor. "AllowsNoArgConstructorCallback" property of MetaDataDefaults \
|
constructor. "AllowsNoArgConstructorCallback" property of MetaDataDefaults \
|
||||||
can be set to true to ignore this exception.
|
can be set to true to ignore this exception.
|
||||||
|
extended-provider: WARNING: Configured to use extended Persistence Provider \
|
||||||
|
"{0}".
|
||||||
|
unloadable-provider: WARNING: Can not load configured Persistence Provider \
|
||||||
|
"{0}" due to "{1}"
|
||||||
|
unrecognized-provider: WARNING: Configured to use non-recognized Persistence \
|
||||||
|
Provider "{0}"
|
||||||
EntityManagerFactory-name: EntityManagerFactory implementation
|
EntityManagerFactory-name: EntityManagerFactory implementation
|
||||||
EntityManagerFactory-desc: Allows extension of standard \
|
EntityManagerFactory-desc: Allows extension of standard \
|
||||||
org.apache.openjpa.persistence.EntityManagerFactoryImpl for custom behavior.
|
org.apache.openjpa.persistence.EntityManagerFactoryImpl for custom behavior.
|
||||||
|
|
Loading…
Reference in New Issue