提交 3c5e02a5 编写于 作者: J Juergen Hoeller

JDO PersistenceManager synchronization performs close attempt after completion...

JDO PersistenceManager synchronization performs close attempt after completion (if necessary; SPR-8846)
上级 db0c9213
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -323,6 +323,11 @@ public abstract class PersistenceManagerFactoryUtils {
return this.newPersistenceManager;
}
@Override
protected boolean shouldReleaseAfterCompletion(PersistenceManagerHolder resourceHolder) {
return !resourceHolder.getPersistenceManager().isClosed();
}
@Override
protected void releaseResource(PersistenceManagerHolder resourceHolder, PersistenceManagerFactory resourceKey) {
releasePersistenceManager(resourceHolder.getPersistenceManager(), resourceKey);
......
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -92,7 +92,7 @@ public abstract class ResourceHolderSynchronization<H extends ResourceHolder, K>
releaseNecessary = true;
}
else {
releaseNecessary = !shouldReleaseBeforeCompletion();
releaseNecessary = shouldReleaseAfterCompletion(this.resourceHolder);
}
if (releaseNecessary) {
releaseResource(this.resourceHolder, this.resourceKey);
......@@ -128,6 +128,17 @@ public abstract class ResourceHolderSynchronization<H extends ResourceHolder, K>
return true;
}
/**
* Return whether this holder's resource should be released after
* transaction completion (<code>true</code>).
* <p>The default implementation returns <code>!shouldReleaseBeforeCompletion()</code>,
* releasing after completion if no attempt was made before completion.
* @see #releaseResource
*/
protected boolean shouldReleaseAfterCompletion(H resourceHolder) {
return !shouldReleaseBeforeCompletion();
}
/**
* Flush callback for the given resource holder.
* @param resourceHolder the resource holder to flush
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册