Merge branch 'master' of github.com:SpringSource/spring-gemfire
This commit is contained in:
@@ -21,25 +21,21 @@ import java.util.List;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.ManagedSet;
|
||||
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.gemfire.listener.ContinuousQueryDefinition;
|
||||
import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer;
|
||||
import org.springframework.data.gemfire.listener.adapter.ContinuousQueryListenerAdapter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
|
||||
/**
|
||||
* Parser for SGF <code><cq-listener-container></code> element.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
class GemfireListenerContainerParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
class GemfireListenerContainerParser extends AbstractSingleBeanDefinitionParser {
|
||||
@Override
|
||||
protected Class<ContinuousQueryListenerContainer> getBeanClass(Element element) {
|
||||
return ContinuousQueryListenerContainer.class;
|
||||
@@ -47,24 +43,11 @@ class GemfireListenerContainerParser extends AbstractSimpleBeanDefinitionParser
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
// parse attributes (but replace the value assignment with references)
|
||||
NamedNodeMap attributes = element.getAttributes();
|
||||
|
||||
for (int x = 0; x < attributes.getLength(); x++) {
|
||||
Attr attribute = (Attr) attributes.item(x);
|
||||
if (isEligibleAttribute(attribute, parserContext)) {
|
||||
String propertyName = extractPropertyName(attribute.getLocalName());
|
||||
Assert.state(StringUtils.hasText(propertyName),
|
||||
"Illegal property name returned from 'extractPropertyName(String)': cannot be null or empty.");
|
||||
builder.addPropertyReference(propertyName, attribute.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ParsingUtils.setPropertyValue(element, builder, "phase", "phase");
|
||||
ParsingUtils.setPropertyValue(element, builder, "pool-name", "poolName");
|
||||
|
||||
postProcess(builder, element);
|
||||
ParsingUtils.setPropertyValue(element, builder, "phase");
|
||||
ParsingUtils.setPropertyValue(element, builder, "pool-name");
|
||||
ParsingUtils.setPropertyReference(element, builder, "cache","cache");
|
||||
ParsingUtils.setPropertyReference(element, builder, "task-executor","task-executor");
|
||||
|
||||
// parse nested listeners
|
||||
List<Element> listDefs = DomUtils.getChildElementsByTagName(element, "listener");
|
||||
@@ -79,11 +62,6 @@ class GemfireListenerContainerParser extends AbstractSimpleBeanDefinitionParser
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEligibleAttribute(String attributeName) {
|
||||
return (!"phase".equals(attributeName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a listener definition. Returns the listener bean reference definition (of a {@link ContinuousQueryDefinition}).
|
||||
*
|
||||
@@ -117,9 +95,4 @@ class GemfireListenerContainerParser extends AbstractSimpleBeanDefinitionParser
|
||||
|
||||
return defBuilder.getBeanDefinition();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldGenerateId() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -277,7 +277,7 @@ public class ContinuousQueryListenerContainer implements InitializingBean, Dispo
|
||||
logger.warn("Execution of JMS event listener failed, and no ErrorHandler has been set.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setBeanName(String name) {
|
||||
this.beanName = name;
|
||||
}
|
||||
|
||||
@@ -2016,21 +2016,29 @@ The name of the bean defining the GemFire cache (by default 'gemfireCache').
|
||||
<xsd:documentation><![CDATA[
|
||||
Container for continuous query listeners. All listeners will be hosted by the same container.
|
||||
]]></xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation>
|
||||
<tool:exports
|
||||
type="org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer" />
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="listener" type="listenerType"
|
||||
minOccurs="0" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="cache" type="xsd:string" default="gemfireCache">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
<xsd:appinfo>
|
||||
<tool:annotation>
|
||||
<tool:exports
|
||||
type="org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer" />
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="listener" type="listenerType"
|
||||
minOccurs="0" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="id" type="xsd:string" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The id of the listener (optional)
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="cache" type="xsd:string"
|
||||
default="gemfireCache">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
A reference (by name) to the GemFire cache bean. Default is "gemfireCache".
|
||||
]]></xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
|
||||
@@ -24,6 +24,8 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.support.GenericXmlApplicationContext;
|
||||
import org.springframework.data.gemfire.ForkUtil;
|
||||
import org.springframework.data.gemfire.listener.ContinuousQueryDefinition;
|
||||
import org.springframework.data.gemfire.listener.ContinuousQueryListener;
|
||||
import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
@@ -56,6 +58,9 @@ public class ContainerXmlSetupTest {
|
||||
|
||||
Cache cache = ctx.getBean("gemfireCache", Cache.class);
|
||||
Pool pool = ctx.getBean("client", Pool.class);
|
||||
|
||||
// Test getting container listener bean by ID
|
||||
ctx.getBean("testContainerId");
|
||||
|
||||
CqQuery[] cqs = cache.getQueryService().getCqs();
|
||||
CqQuery[] pcqs = pool.getQueryService().getCqs();
|
||||
|
||||
@@ -24,6 +24,7 @@ import javax.annotation.Resource;
|
||||
|
||||
import org.codehaus.jackson.JsonGenerationException;
|
||||
import org.codehaus.jackson.map.JsonMappingException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -49,6 +50,10 @@ public class JSONRegionAdviceTest {
|
||||
@Autowired
|
||||
GemfireOperations template;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
region.clear();
|
||||
}
|
||||
@Test
|
||||
public void testPutString() {
|
||||
String json = "{\"hello\":\"world\"}";
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
<task:executor id="testTaskExecutor" />
|
||||
|
||||
<gfe:cq-listener-container cache="gemfireCache" pool-name="client">
|
||||
<gfe:cq-listener-container id="testContainerId" cache="gemfireCache" pool-name="client">
|
||||
<!-- default handle method -->
|
||||
<gfe:listener ref="testBean1" query="SELECT * from /test-cq"/>
|
||||
<gfe:listener ref="testBean1" query="SELECT * from /test-cq" name="test-bean-1" method="handleQuery"/>
|
||||
|
||||
Reference in New Issue
Block a user