SGF-458 - Enable resolution of GemFire's DistributedSystem and System properties to be overridden in PoolFactoryBean.

(cherry picked from commit 10fadc0d9a)
Signed-off-by: John Blum <jblum@pivotal.io>
This commit is contained in:
John Blum
2016-01-08 15:10:00 -08:00
parent 7654049b2f
commit 4c73671cf8
3 changed files with 26 additions and 6 deletions

View File

@@ -189,15 +189,30 @@ public class PoolFactoryBean implements FactoryBean<Pool>, InitializingBean, Dis
return PoolManager.createFactory();
}
/* (non-Javadoc) */
void resolveDistributedSystem() {
if (DistributedSystemUtils.getDistributedSystem() == null) {
/**
* Attempts to find an existing, running GemFire {@link DistributedSystem} or proceeds to create
* a new {@link DistributedSystem} if one does not exist.
*
* @see DistributedSystemUtils#getDistributedSystem()
* @see #resolveGemfireProperties()
* @see #doDistributedSystemConnect(Properties)
*/
protected void resolveDistributedSystem() {
if (DistributedSystemUtils.isNotConnected(DistributedSystemUtils.getDistributedSystem())) {
doDistributedSystemConnect(resolveGemfireProperties());
}
}
/* (non-Javadoc) */
Properties resolveGemfireProperties() {
/**
* Attempts to resolve existing GemFire System properties from the {@link ClientCacheFactoryBean}
* if set by the user.
*
* @return a {@link Properties} object containing GemFire System properties
* or null if no properties were configured.
* @see ClientCacheFactoryBean#resolveProperties()
* @see java.util.Properties
*/
protected Properties resolveGemfireProperties() {
try {
ClientCacheFactoryBean clientCacheFactoryBean = beanFactory.getBean(ClientCacheFactoryBean.class);
return clientCacheFactoryBean.getProperties();

View File

@@ -42,4 +42,9 @@ public abstract class DistributedSystemUtils {
return (distributedSystem != null && distributedSystem.isConnected());
}
/* (non-Javadoc) */
public static boolean isNotConnected(DistributedSystem distributedSystem) {
return !isConnected(distributedSystem);
}
}

View File

@@ -155,7 +155,7 @@ public class PoolUsingLocatorsAndServersPropertyPlaceholdersTest {
}
@Override
void resolveDistributedSystem() {
protected void resolveDistributedSystem() {
}
}