SGF-148 - Added 'close' property on CacheFactoryBean which, if false, will leave cache open when ApplicationContext closes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -239,6 +239,15 @@ JavaDocs for com.gemstone.gemfire.cache.control.ResourceManager for more informa
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="close" default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Determines if the cache should be closed when the application context is closed. This value is
|
||||
true by default but should be set to false if deploying multiple applications in a jvm that share the
|
||||
same cache instance.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
<!-- -->
|
||||
<xsd:element name="cache">
|
||||
|
||||
Reference in New Issue
Block a user