DATAGEODE-1 - Polish.
Resolves gh-29.
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static java.util.stream.StreamSupport.stream;
|
||||
@@ -92,6 +91,7 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.apache.geode.cache.CacheFactory
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.RegionService
|
||||
* @see org.apache.geode.cache.client.ClientCacheFactory
|
||||
* @see org.apache.geode.distributed.DistributedMember
|
||||
* @see org.apache.geode.distributed.DistributedSystem
|
||||
* @see org.apache.geode.cache.pdx.PdxSerializer
|
||||
@@ -195,6 +195,7 @@ public class CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache>
|
||||
|
||||
gemfireProperties.setProperty("use-cluster-configuration",
|
||||
String.valueOf(Boolean.TRUE.equals(getUseClusterConfiguration())));
|
||||
|
||||
};
|
||||
|
||||
this.peerCacheConfigurers.add(autoReconnectClusterConfigurationConfigurer);
|
||||
@@ -281,7 +282,6 @@ public class CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache>
|
||||
|
||||
});
|
||||
|
||||
|
||||
return getCache();
|
||||
}
|
||||
catch (Exception cause) {
|
||||
@@ -614,14 +614,13 @@ public class CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache>
|
||||
/**
|
||||
* Destroys the {@link Cache} bean on Spring container shutdown.
|
||||
*
|
||||
* @throws Exception if an error occurs while closing the cache.
|
||||
* @see org.springframework.beans.factory.DisposableBean#destroy()
|
||||
* @see #destroyBeanFactoryLocator()
|
||||
* @see #close(GemFireCache)
|
||||
* @see #isClose()
|
||||
*/
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
public void destroy() {
|
||||
|
||||
if (isClose()) {
|
||||
close(fetchCache());
|
||||
@@ -650,7 +649,6 @@ public class CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache>
|
||||
* @see org.springframework.dao.DataAccessException
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public DataAccessException translateExceptionIfPossible(RuntimeException exception) {
|
||||
|
||||
if (exception instanceof IllegalArgumentException) {
|
||||
@@ -760,15 +758,8 @@ public class CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache>
|
||||
* @return boolean value indicating whether a {@link Resource cache.xml} {@link File} is present.
|
||||
* @see #getCacheXmlFile()
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
private boolean isCacheXmlAvailable() {
|
||||
|
||||
try {
|
||||
return getCacheXmlFile() != null;
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
return false;
|
||||
}
|
||||
return SpringUtils.safeGetValue(() -> getCacheXml() != null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -780,11 +771,8 @@ public class CacheFactoryBean extends AbstractFactoryBeanSupport<GemFireCache>
|
||||
* @see #getCache()
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public GemFireCache getObject() throws Exception {
|
||||
|
||||
return Optional.<GemFireCache>ofNullable(getCache())
|
||||
.orElseGet(this::init);
|
||||
return Optional.<GemFireCache>ofNullable(getCache()).orElseGet(this::init);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.annotation;
|
||||
|
||||
import static org.springframework.data.gemfire.CacheFactoryBean.JndiDataSource;
|
||||
@@ -81,6 +80,7 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.springframework.data.gemfire.config.support.CustomEditorBeanFactoryPostProcessor
|
||||
* @see org.springframework.data.gemfire.config.support.DefinedIndexesApplicationListener
|
||||
* @see org.springframework.data.gemfire.config.support.DiskStoreDirectoryBeanPostProcessor
|
||||
* @see org.springframework.data.gemfire.util.PropertiesBuilder
|
||||
* @since 1.9.0
|
||||
*/
|
||||
@Configuration
|
||||
@@ -142,7 +142,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
*
|
||||
* {@literal mcast-port} is set to {@literal 0} and {@literal locators} is set to an {@link String empty String},
|
||||
* which is necessary for {@link ClientCache cache client}-based applications. These values can be changed
|
||||
* and set accoridingly for {@link Cache peer cache} and {@link CacheServer cache server} applications.
|
||||
* and set accordingly for {@link Cache peer cache} and {@link CacheServer cache server} applications.
|
||||
*
|
||||
* Finally, the {@literal log-level} property defaults to {@literal config}.
|
||||
*
|
||||
@@ -154,6 +154,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
* @see #logLevel()
|
||||
* @see #mcastPort()
|
||||
* @see #name()
|
||||
* @see #startLocator()
|
||||
*/
|
||||
@Bean
|
||||
protected Properties gemfireProperties() {
|
||||
@@ -305,7 +306,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
* @see #newCacheFactoryBean()
|
||||
*/
|
||||
protected <T extends CacheFactoryBean> T constructCacheFactoryBean() {
|
||||
return configureCacheFactoryBean(this.<T>newCacheFactoryBean());
|
||||
return configureCacheFactoryBean(this.newCacheFactoryBean());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,7 +355,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return gemfireCache;
|
||||
}
|
||||
|
||||
// REVIEW JAVADOC FROM HERE
|
||||
// TODO: REVIEW JAVADOC FROM HERE
|
||||
|
||||
/**
|
||||
* Determines whether this is a GemFire {@link org.apache.geode.cache.server.CacheServer} application,
|
||||
@@ -436,7 +437,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
* @see #isPeerCacheApplication(AnnotationMetadata)
|
||||
*/
|
||||
protected boolean isCacheServerOrPeerCacheApplication(AnnotationMetadata importMetadata) {
|
||||
return (isCacheServerApplication(importMetadata) || isPeerCacheApplication(importMetadata));
|
||||
return isCacheServerApplication(importMetadata) || isPeerCacheApplication(importMetadata);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -452,8 +453,10 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
* @see #isPeerCacheApplication(AnnotationMetadata)
|
||||
*/
|
||||
protected boolean isClientPeerOrServerCacheApplication(AnnotationMetadata importMetadata) {
|
||||
return (isCacheServerApplication(importMetadata) || isClientCacheApplication(importMetadata)
|
||||
|| isPeerCacheApplication(importMetadata));
|
||||
|
||||
return isCacheServerApplication(importMetadata)
|
||||
|| isClientCacheApplication(importMetadata)
|
||||
|| isPeerCacheApplication(importMetadata);
|
||||
}
|
||||
|
||||
void setCacheXml(Resource cacheXml) {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import java.util.List;
|
||||
@@ -33,6 +32,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.support.ManagedMap;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.CacheFactoryBean;
|
||||
import org.springframework.data.gemfire.config.support.CustomEditorBeanFactoryPostProcessor;
|
||||
@@ -43,13 +43,14 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
|
||||
/**
|
||||
* Bean definition parser for the <gfe:cache> SDG XML namespace (XSD) element.
|
||||
* {@link BeanDefinitionParser} for the <gfe:cache> SDG XML Namespace (XSD) element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Oliver Gierke
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @author Patrick Johnson
|
||||
* @see org.w3c.dom.Element
|
||||
* @see org.springframework.beans.factory.support.AbstractBeanDefinition
|
||||
* @see org.springframework.beans.factory.support.BeanDefinitionBuilder
|
||||
* @see org.springframework.beans.factory.support.BeanDefinitionRegistry
|
||||
@@ -99,33 +100,36 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
|
||||
ParsingUtils.setPropertyValue(element, cacheBuilder, "search-timeout");
|
||||
ParsingUtils.setPropertyValue(element, cacheBuilder, "use-cluster-configuration");
|
||||
|
||||
List<Element> txListeners = DomUtils.getChildElementsByTagName(element, "transaction-listener");
|
||||
List<Element> transactionListeners =
|
||||
DomUtils.getChildElementsByTagName(element, "transaction-listener");
|
||||
|
||||
if (!CollectionUtils.isEmpty(txListeners)) {
|
||||
if (!CollectionUtils.isEmpty(transactionListeners)) {
|
||||
|
||||
ManagedList<Object> transactionListeners = new ManagedList<>();
|
||||
ManagedList<Object> managedTransactionListeners = new ManagedList<>();
|
||||
|
||||
for (Element txListener : txListeners) {
|
||||
transactionListeners.add(ParsingUtils.parseRefOrNestedBeanDeclaration(
|
||||
txListener, parserContext, cacheBuilder));
|
||||
for (Element transactionListener : transactionListeners) {
|
||||
managedTransactionListeners.add(ParsingUtils.parseRefOrNestedBeanDeclaration(
|
||||
transactionListener, parserContext, cacheBuilder));
|
||||
}
|
||||
|
||||
cacheBuilder.addPropertyValue("transactionListeners", transactionListeners);
|
||||
cacheBuilder.addPropertyValue("transactionListeners", managedTransactionListeners);
|
||||
}
|
||||
|
||||
Element txWriter = DomUtils.getChildElementByTagName(element, "transaction-writer");
|
||||
Element transactionWriter = DomUtils.getChildElementByTagName(element, "transaction-writer");
|
||||
|
||||
if (txWriter != null) {
|
||||
if (transactionWriter != null) {
|
||||
cacheBuilder.addPropertyValue("transactionWriter",
|
||||
ParsingUtils.parseRefOrNestedBeanDeclaration(txWriter, parserContext, cacheBuilder));
|
||||
ParsingUtils.parseRefOrNestedBeanDeclaration(transactionWriter, parserContext, cacheBuilder));
|
||||
}
|
||||
|
||||
Element gatewayConflictResolver =
|
||||
DomUtils.getChildElementByTagName(element, "gateway-conflict-resolver");
|
||||
|
||||
if (gatewayConflictResolver != null) {
|
||||
|
||||
ParsingUtils.throwExceptionWhenGemFireFeatureUnavailable(GemfireFeature.WAN, element.getLocalName(),
|
||||
"gateway-conflict-resolver", parserContext);
|
||||
|
||||
cacheBuilder.addPropertyValue("gatewayConflictResolver", ParsingUtils.parseRefOrSingleNestedBeanDeclaration(
|
||||
gatewayConflictResolver, parserContext, cacheBuilder));
|
||||
}
|
||||
@@ -139,9 +143,10 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
private void registerGemFireBeanFactoryPostProcessors(BeanDefinitionRegistry registry) {
|
||||
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(
|
||||
BeanDefinitionBuilder.genericBeanDefinition(CustomEditorBeanFactoryPostProcessor.class)
|
||||
.getBeanDefinition(), registry);
|
||||
AbstractBeanDefinition customEditorBeanFactoryPostProcessorDefinition =
|
||||
BeanDefinitionBuilder.genericBeanDefinition(CustomEditorBeanFactoryPostProcessor.class).getBeanDefinition();
|
||||
|
||||
BeanDefinitionReaderUtils.registerWithGeneratedName(customEditorBeanFactoryPostProcessorDefinition, registry);
|
||||
}
|
||||
|
||||
private void parsePdxDiskStore(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
|
||||
@@ -13,25 +13,29 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
|
||||
|
||||
/**
|
||||
* Bean definition parser for the <gfe:client-cache> SDG XML namespace (XSD) element.
|
||||
* {@link BeanDefinitionParser} for the <gfe:client-cache> SDG XML Namespace (XSD) element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author Lyndon Adams
|
||||
* @author John Blum
|
||||
* @author Patrick Johnson
|
||||
* @see org.w3c.dom.Element
|
||||
* @see org.springframework.beans.factory.support.BeanDefinitionBuilder
|
||||
* @see org.springframework.beans.factory.xml.BeanDefinitionParser
|
||||
* @see org.springframework.beans.factory.xml.ParserContext
|
||||
* @see org.springframework.data.gemfire.client.ClientCacheFactoryBean
|
||||
* @see CacheParser
|
||||
* @see org.springframework.data.gemfire.config.xml.CacheParser
|
||||
*/
|
||||
class ClientCacheParser extends CacheParser {
|
||||
|
||||
|
||||
@@ -89,6 +89,38 @@ use inner bean declarations.
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="dynamic-region-factory" minOccurs="0" maxOccurs="1">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Enables Dynamic Regions and specifies their configuration.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="disk-dir" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Specifies the directory path for disk persistence for dynamic regions.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="persistent" type="xsd:string"
|
||||
default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Enables persistence for dynamic regions.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="register-interest" type="xsd:string"
|
||||
default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Specifies whether dynamic regions register interest in all keys in a corresponding server region.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="jndi-binding" type="jndiBindingType" minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
|
||||
@@ -89,38 +89,6 @@ use inner bean declarations.
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="dynamic-region-factory" minOccurs="0" maxOccurs="1">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Enables Dynamic Regions and specifies their configuration.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="disk-dir" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Specifies the directory path for disk persistence for dynamic regions.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="persistent" type="xsd:string"
|
||||
default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Enables persistence for dynamic regions.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="register-interest" type="xsd:string"
|
||||
default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Specifies whether dynamic regions register interest in all keys in a corresponding server region.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="jndi-binding" type="jndiBindingType" minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
|
||||
Reference in New Issue
Block a user