DefaultPersistenceUnitManager's getPersistenceUnitInfo method has 2.5 compatible signature again (SPR-7055)

This commit is contained in:
Juergen Hoeller 2010-04-06 15:38:40 +00:00
parent ff6abbd369
commit 4ee6735376
1 changed files with 15 additions and 2 deletions

View File

@ -336,8 +336,17 @@ public class DefaultPersistenceUnitManager
* @param persistenceUnitName the name of the desired persistence unit * @param persistenceUnitName the name of the desired persistence unit
* @return the PersistenceUnitInfo in mutable form, or <code>null</code> if not available * @return the PersistenceUnitInfo in mutable form, or <code>null</code> if not available
*/ */
protected final PersistenceUnitInfo getPersistenceUnitInfo(String persistenceUnitName) { protected final MutablePersistenceUnitInfo getPersistenceUnitInfo(String persistenceUnitName) {
return this.persistenceUnitInfos.get(persistenceUnitName); PersistenceUnitInfo pui = this.persistenceUnitInfos.get(persistenceUnitName);
if (Proxy.isProxyClass(pui.getClass())) {
// JPA 2.0 PersistenceUnitInfo decorator with a SpringPersistenceUnitInfo as target
Jpa2PersistenceUnitInfoDecorator dec = (Jpa2PersistenceUnitInfoDecorator) Proxy.getInvocationHandler(pui);
return dec.getTarget();
}
else {
// Must be a raw JPA 1.0 SpringPersistenceUnitInfo instance
return (MutablePersistenceUnitInfo) pui;
}
} }
/** /**
@ -420,6 +429,10 @@ public class DefaultPersistenceUnitManager
} }
} }
public final SpringPersistenceUnitInfo getTarget() {
return this.target;
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals("getSharedCacheMode")) { if (method.getName().equals("getSharedCacheMode")) {
return Enum.valueOf(this.sharedCacheModeEnum, this.target.getSharedCacheModeName()); return Enum.valueOf(this.sharedCacheModeEnum, this.target.getSharedCacheModeName());