SGF-148 - Added 'close' property on CacheFactoryBean which, if false, will leave cache open when ApplicationContext closes

This commit is contained in:
David Turanski
2013-01-21 09:01:39 -05:00
parent 0e92a8f51d
commit 1e7ccc44b1
6 changed files with 84 additions and 3 deletions

View File

@@ -201,6 +201,8 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
protected String beanName;
protected boolean useBeanFactoryLocator = true;
protected boolean close = true;
// PDX options
protected Object pdxSerializer;
@@ -405,6 +407,9 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
@Override
public void destroy() throws Exception {
if (!close) {
return;
}
if (cache != null && !cache.isClosed()) {
cache.close();
}
@@ -614,6 +619,14 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
public void setCriticalHeapPercentage(Float criticalHeapPercentage) {
this.criticalHeapPercentage = criticalHeapPercentage;
}
/**
*
* @param close set to false if destroy() should not close the cache
*/
public void setClose(boolean close) {
this.close = close;
}
/**
*

View File

@@ -67,6 +67,7 @@ class CacheParser extends AbstractSimpleBeanDefinitionParser {
ParsingUtils.setPropertyValue(element, builder, "search-timeout");
ParsingUtils.setPropertyValue(element, builder, "critical-heap-percentage");
ParsingUtils.setPropertyValue(element, builder, "eviction-heap-percentage");
ParsingUtils.setPropertyValue(element, builder, "close");
List<Element> txListeners = DomUtils.getChildElementsByTagName(element, "transaction-listener");
if (!CollectionUtils.isEmpty(txListeners)) {