Added support for gateway conflict resolver and function service
This commit is contained in:
@@ -47,6 +47,9 @@ import com.gemstone.gemfire.cache.DynamicRegionFactory;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.TransactionListener;
|
||||
import com.gemstone.gemfire.cache.TransactionWriter;
|
||||
import com.gemstone.gemfire.cache.execute.Function;
|
||||
import com.gemstone.gemfire.cache.execute.FunctionService;
|
||||
import com.gemstone.gemfire.cache.util.GatewayConflictResolver;
|
||||
import com.gemstone.gemfire.distributed.DistributedMember;
|
||||
import com.gemstone.gemfire.distributed.DistributedSystem;
|
||||
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
|
||||
@@ -129,6 +132,10 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
if (messageSyncInterval != null) {
|
||||
cacheImpl.setMessageSyncInterval(messageSyncInterval);
|
||||
}
|
||||
|
||||
if (gatewayConflictResolver != null) {
|
||||
cacheImpl.setGatewayConflictResolver(gatewayConflictResolver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,6 +265,10 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
|
||||
protected List<JndiDataSource> jndiDataSources;
|
||||
|
||||
protected List<Function> functions;
|
||||
|
||||
protected GatewayConflictResolver gatewayConflictResolver;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
// initialize locator
|
||||
@@ -324,12 +335,24 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
registerTransactionListeners();
|
||||
registerTransactionWriter();
|
||||
registerJndiDataSources();
|
||||
registerFunctions();
|
||||
}
|
||||
finally {
|
||||
th.setContextClassLoader(oldTCCL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void registerFunctions() {
|
||||
if (!CollectionUtils.isEmpty(functions)) {
|
||||
for (Function function : functions) {
|
||||
FunctionService.registerFunction(function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerJndiDataSources() {
|
||||
if (jndiDataSources != null) {
|
||||
for (JndiDataSource jndiDataSource : jndiDataSources) {
|
||||
@@ -605,6 +628,14 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
this.transactionWriter = transactionWriter;
|
||||
}
|
||||
|
||||
public void setFunctions(List<Function> functions) {
|
||||
this.functions = functions;
|
||||
}
|
||||
|
||||
public void setGatewayConflictResolver(GatewayConflictResolver gatewayConflictResolver) {
|
||||
this.gatewayConflictResolver = gatewayConflictResolver;
|
||||
}
|
||||
|
||||
public void setDynamicRegionSupport(DynamicRegionSupport dynamicRegionSupport) {
|
||||
this.dynamicRegionSupport = dynamicRegionSupport;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2010-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.execute.Function;
|
||||
import com.gemstone.gemfire.cache.execute.FunctionService;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
*/
|
||||
public class FunctionServiceFactoryBean implements FactoryBean<FunctionService>, InitializingBean {
|
||||
static FunctionService functionService;
|
||||
|
||||
private List<Function> functions;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (!CollectionUtils.isEmpty(functions)) {
|
||||
for (Function function : functions) {
|
||||
FunctionService.registerFunction(function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setFunctions(List<Function> functions) {
|
||||
this.functions = functions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FunctionService getObject() throws Exception {
|
||||
return functionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return FunctionService.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,20 @@ class CacheParser extends AbstractSimpleBeanDefinitionParser {
|
||||
ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, txWriter, builder));
|
||||
}
|
||||
|
||||
Element gatewayConflictResolver = DomUtils.getChildElementByTagName(element, "gateway-conflict-resolver");
|
||||
if (gatewayConflictResolver != null) {
|
||||
ParsingUtils.throwExceptionIfNotGemfireV7(element.getLocalName(), "gateway-conflict-resolver",
|
||||
parserContext);
|
||||
builder.addPropertyValue("gatewayConflictResolver",
|
||||
ParsingUtils.parseRefOrSingleNestedBeanDeclaration(parserContext, gatewayConflictResolver, builder));
|
||||
}
|
||||
|
||||
Element function = DomUtils.getChildElementByTagName(element, "function");
|
||||
if (function != null) {
|
||||
builder.addPropertyValue("functions",
|
||||
ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, function, builder));
|
||||
}
|
||||
|
||||
parseDynamicRegionFactory(element, builder);
|
||||
parseJndiBindings(element, builder);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2010-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.FunctionServiceFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for <function-service;gt; definitions.
|
||||
* @author David Turanski
|
||||
*/
|
||||
class FunctionServiceParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return FunctionServiceFactoryBean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
builder.setLazyInit(false);
|
||||
super.doParse(element, builder);
|
||||
Element function = DomUtils.getChildElementByTagName(element, "function");
|
||||
if (function != null) {
|
||||
builder.addPropertyValue("functions",
|
||||
ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, function, builder));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
|
||||
throws BeanDefinitionStoreException {
|
||||
String name = super.resolveId(element, definition, parserContext);
|
||||
if (!StringUtils.hasText(name)) {
|
||||
name = "gemfire-function-service";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -64,6 +64,7 @@ class GemfireNamespaceHandler extends NamespaceHandlerSupport {
|
||||
registerBeanDefinitionParser("async-event-queue", new AsyncEventQueueParser());
|
||||
registerBeanDefinitionParser("gateway-sender", new GatewaySenderParser());
|
||||
registerBeanDefinitionParser("gateway-receiver", new GatewayReceiverParser());
|
||||
registerBeanDefinitionParser("function-service", new FunctionServiceParser());
|
||||
// V6 WAN parsers
|
||||
registerBeanDefinitionParser("gateway-hub", new GatewayHubParser());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user