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
|
@ -248,6 +248,8 @@ public class PersistenceProductDerivation
|
|||
rsrc, String.valueOf(name)).getMessage(), getClass().getName(),
|
||||
rsrc);
|
||||
} else if (!isOpenJPAPersistenceProvider(pinfo, loader)) {
|
||||
if (!explicit)
|
||||
return Boolean.FALSE;
|
||||
throw new MissingResourceException(_loc.get("unknown-provider",
|
||||
rsrc, name, pinfo.getPersistenceProviderClassName()).
|
||||
getMessage(), getClass().getName(), rsrc);
|
||||
|
@ -307,19 +309,31 @@ public class PersistenceProductDerivation
|
|||
*/
|
||||
private static boolean isOpenJPAPersistenceProvider
|
||||
(PersistenceUnitInfo pinfo, ClassLoader loader) {
|
||||
String name = pinfo.getPersistenceProviderClassName();
|
||||
if (StringUtils.isEmpty(name)
|
||||
|| PersistenceProviderImpl.class.getName().equals(name))
|
||||
String provider = pinfo.getPersistenceProviderClassName();
|
||||
if (StringUtils.isEmpty(provider)
|
||||
|| PersistenceProviderImpl.class.getName().equals(provider))
|
||||
return true;
|
||||
|
||||
if (loader == null)
|
||||
loader = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
return PersistenceProviderImpl.class.isAssignableFrom
|
||||
(Class.forName(name, false, loader));
|
||||
if (PersistenceProviderImpl.class.isAssignableFrom
|
||||
(Class.forName(provider, false, loader))) {
|
||||
// log not configured yet
|
||||
warn(_loc.get("extended-provider", provider).getMessage());
|
||||
return true;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
warn(_loc.get("unloadable-provider", provider, t).
|
||||
getMessage());
|
||||
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 \
|
||||
constructor. "AllowsNoArgConstructorCallback" property of MetaDataDefaults \
|
||||
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-desc: Allows extension of standard \
|
||||
org.apache.openjpa.persistence.EntityManagerFactoryImpl for custom behavior.
|
||||
|
|
Loading…
Reference in New Issue