SGF-57
SGF-63 + improved schema + fix some bugs that prevented the client cache to reuse an already defined pool
This commit is contained in:
@@ -103,6 +103,7 @@ public class ClientCacheFactoryBean extends CacheFactoryBean {
|
||||
+ Pool.class.getName() + " found");
|
||||
|
||||
p = getBeanFactory().getBean(poolName, Pool.class);
|
||||
Assert.notNull(p, "No pool named [" + poolName + "] found");
|
||||
}
|
||||
|
||||
if (p != null) {
|
||||
@@ -137,7 +138,7 @@ public class ClientCacheFactoryBean extends CacheFactoryBean {
|
||||
List<InetSocketAddress> servers = p.getServers();
|
||||
if (locators != null) {
|
||||
for (InetSocketAddress inet : servers) {
|
||||
ccf.addPoolLocator(inet.getHostName(), inet.getPort());
|
||||
ccf.addPoolServer(inet.getHostName(), inet.getPort());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +60,9 @@ class GemfireListenerContainerParser extends AbstractSimpleBeanDefinitionParser
|
||||
}
|
||||
}
|
||||
|
||||
String phase = element.getAttribute("phase");
|
||||
if (StringUtils.hasText(phase)) {
|
||||
builder.addPropertyValue("phase", phase);
|
||||
}
|
||||
|
||||
ParsingUtils.setPropertyValue(element, builder, "phase", "phase");
|
||||
ParsingUtils.setPropertyValue(element, builder, "pool-name", "poolName");
|
||||
|
||||
postProcess(builder, element);
|
||||
|
||||
|
||||
@@ -28,11 +28,14 @@ import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.data.gemfire.GemfireQueryException;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.RegionService;
|
||||
import com.gemstone.gemfire.cache.client.Pool;
|
||||
import com.gemstone.gemfire.cache.client.PoolManager;
|
||||
import com.gemstone.gemfire.cache.query.CqAttributes;
|
||||
import com.gemstone.gemfire.cache.query.CqAttributesFactory;
|
||||
import com.gemstone.gemfire.cache.query.CqEvent;
|
||||
@@ -74,7 +77,8 @@ public class ContinousQueryListenerContainer implements InitializingBean, Dispos
|
||||
/**
|
||||
* Default thread name prefix: "ContinousQueryListenerContainer-".
|
||||
*/
|
||||
public static final String DEFAULT_THREAD_NAME_PREFIX = ClassUtils.getShortName(ContinousQueryListenerContainer.class) + "-";
|
||||
public static final String DEFAULT_THREAD_NAME_PREFIX = ClassUtils.getShortName(ContinousQueryListenerContainer.class)
|
||||
+ "-";
|
||||
|
||||
private Executor subscriptionExecutor;
|
||||
private Executor taskExecutor;
|
||||
@@ -90,6 +94,7 @@ public class ContinousQueryListenerContainer implements InitializingBean, Dispos
|
||||
private Set<CqQuery> queries = new ConcurrentHashSet<CqQuery>();
|
||||
|
||||
private QueryService queryService;
|
||||
private String poolName;
|
||||
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
@@ -102,6 +107,12 @@ public class ContinousQueryListenerContainer implements InitializingBean, Dispos
|
||||
subscriptionExecutor = taskExecutor;
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(poolName)) {
|
||||
Pool pool = PoolManager.find(poolName);
|
||||
Assert.notNull(pool, "No pool named [" + poolName + "] found");
|
||||
queryService = pool.getQueryService();
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
|
||||
start();
|
||||
@@ -307,6 +318,15 @@ public class ContinousQueryListenerContainer implements InitializingBean, Dispos
|
||||
this.queryService = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the {@link Pool} used for performing the queries by this container.
|
||||
*
|
||||
* @param service
|
||||
*/
|
||||
public void setPoolName(String poolName) {
|
||||
this.poolName = poolName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the given query definitions.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user