From 299dd49a798916d260a8a211bad1ae20dbb87b58 Mon Sep 17 00:00:00 2001 From: John Blum Date: Tue, 19 Aug 2014 17:56:49 -0700 Subject: [PATCH] Cleanup to the SDG dependency repository references, preferring Spring IO Repos over external repos (such as dist.gemstone.com). Added conditional logic around the GemFire 8 Distribution Configuration Properties in the CacheFactoryBean in an effort to enable SDG 1.5 to work with GemFire 7.x versions and earlier. Refactored the GemfireUtils class's logic for detecting GemFire Versions at runtime. --- build.gradle | 3 ++- .../data/gemfire/CacheFactoryBean.java | 10 ++++++---- .../data/gemfire/GemfireUtils.java | 19 +++++++++++++++++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 0790046f..e53401b7 100644 --- a/build.gradle +++ b/build.gradle @@ -12,8 +12,9 @@ description = 'Spring Data GemFire' group = 'org.springframework.data' repositories { + maven { url "http://repo.spring.io/gemstone-release-cache" } //maven { url "http://nexus.gemstone.com:8081/nexus/content/repositories/snapshots" } - maven { url "http://dist.gemstone.com.s3.amazonaws.com/maven/release"} + maven { url "http://dist.gemstone.com/maven/release"} maven { url "http://repo.spring.io/gemstone-snapshot-cache" } maven { url "http://repo.spring.io/libs-snapshot" } maven { url "http://repo.spring.io/plugins-release"} diff --git a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java index d2909afe..afc1811a 100644 --- a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java +++ b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java @@ -909,10 +909,12 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, } protected void postProcessPropertiesBeforeInitialization(Properties gemfireProperties) { - gemfireProperties.setProperty("disable-auto-reconnect", String.valueOf( - !Boolean.TRUE.equals(getEnableAutoReconnect()))); - gemfireProperties.setProperty("use-cluster-configuration", String.valueOf( - Boolean.TRUE.equals(getUseClusterConfiguration()))); + if (GemfireUtils.isGemfireVersion8OrAbove()) { + gemfireProperties.setProperty("disable-auto-reconnect", String.valueOf( + !Boolean.TRUE.equals(getEnableAutoReconnect()))); + gemfireProperties.setProperty("use-cluster-configuration", String.valueOf( + Boolean.TRUE.equals(getUseClusterConfiguration()))); + } } /* (non-Javadoc) diff --git a/src/main/java/org/springframework/data/gemfire/GemfireUtils.java b/src/main/java/org/springframework/data/gemfire/GemfireUtils.java index 01e2b2a0..28988444 100644 --- a/src/main/java/org/springframework/data/gemfire/GemfireUtils.java +++ b/src/main/java/org/springframework/data/gemfire/GemfireUtils.java @@ -34,6 +34,11 @@ public abstract class GemfireUtils { public final static String GEMFIRE_VERSION = CacheFactory.getVersion(); + public static boolean isGemfireVersionGreaterThanEqual(double expectedVersion) { + double actualVersion = Double.parseDouble(GEMFIRE_VERSION.substring(0, 3)); + return actualVersion >= expectedVersion; + } + public static boolean isGemfireVersion65OrAbove() { // expected 'major.minor' try { @@ -48,15 +53,25 @@ public abstract class GemfireUtils { public static boolean isGemfireVersion7OrAbove() { try { - int version = Integer.parseInt(GEMFIRE_VERSION.substring(0, 1)); - return version >= 7; + return isGemfireVersionGreaterThanEqual(7.0); } catch (NumberFormatException e) { // NOTE the com.gemstone.gemfire.distributed.ServerLauncher class only exists in GemFire v 7.0.x or above... return ClassUtils.isPresent("com.gemstone.gemfire.distributed.ServerLauncher", Thread.currentThread().getContextClassLoader()); } + } + public static boolean isGemfireVersion8OrAbove() { + try { + return isGemfireVersionGreaterThanEqual(8.0); + } + catch (NumberFormatException e) { + // NOTE the com.gemstone.gemfire.management.internal.web.domain.LinkIndex class only exists + // in GemFire v 8.0.0 or above... + return ClassUtils.isPresent("com.gemstone.gemfire.management.internal.web.domain.LinkIndex", + Thread.currentThread().getContextClassLoader()); + } } public static void main(final String... args) {