AMQP-186: enable placeholders in some corners of XSD
This commit is contained in:
@@ -53,7 +53,7 @@ public abstract class NamespaceUtils {
|
||||
String attributeName, String propertyName) {
|
||||
String attributeValue = element.getAttribute(attributeName);
|
||||
if (StringUtils.hasText(attributeValue)) {
|
||||
builder.addPropertyValue(propertyName, attributeValue);
|
||||
builder.addPropertyValue(propertyName, new TypedStringValue(attributeValue));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -35,21 +35,21 @@
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="auto-delete" use="optional" type="xsd:boolean" default="false">
|
||||
<xsd:attribute name="auto-delete" use="optional" type="xsd:string" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Flag indicating that an queue will be deleted when it is no longer in use, i.e. the connection that declared it is closed. Default is false.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="exclusive" use="optional" type="xsd:boolean" default="false">
|
||||
<xsd:attribute name="exclusive" use="optional" type="xsd:string" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Flag indicating that the queue is exclusive to this connection. Default is false.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="durable" use="optional" type="xsd:boolean" default="true">
|
||||
<xsd:attribute name="durable" use="optional" type="xsd:string" default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Flag indicating that the queue is durable, meaning that it will survive broker restarts (not that the messages in it will, although they might if they are persistent). Default is true.
|
||||
@@ -244,14 +244,14 @@
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="auto-delete" use="optional" type="xsd:boolean" default="false">
|
||||
<xsd:attribute name="auto-delete" use="optional" type="xsd:string" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Flag indicating that an exchange will be deleted when no longer in use, i.e. the connection that declared it is closed. Default is false.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="durable" use="optional" type="xsd:boolean" default="false">
|
||||
<xsd:attribute name="durable" use="optional" type="xsd:string " default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Flag indicating that the exchange is durable, i.e. will survive broker restart. Default is false.
|
||||
@@ -464,7 +464,7 @@
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="prefetch" type="xsd:int">
|
||||
<xsd:attribute name="prefetch" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Tells the broker how many messages to send to each consumer in a single request. Often this can be set quite high
|
||||
@@ -472,7 +472,7 @@
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="transaction-size" type="xsd:int">
|
||||
<xsd:attribute name="transaction-size" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Tells the container how many messages to process in a single transaction (if the channel is transactional). For
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.Arrays;
|
||||
import org.aopalliance.aop.Advice;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.amqp.core.AcknowledgeMode;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
@@ -33,6 +32,8 @@ import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter;
|
||||
import org.springframework.aop.MethodBeforeAdvice;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.context.expression.StandardBeanExpressionResolver;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@@ -41,14 +42,14 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public final class ListenerContainerParserTests {
|
||||
public class ListenerContainerParserTests {
|
||||
|
||||
private XmlBeanFactory beanFactory;
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
beanFactory = new XmlBeanFactory(new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass()));
|
||||
beanFactory.setBeanExpressionResolver(new StandardBeanExpressionResolver());
|
||||
((ConfigurableBeanFactory)beanFactory).setBeanExpressionResolver(new StandardBeanExpressionResolver());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2010-2011 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.amqp.rabbit.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.amqp.core.AcknowledgeMode;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.config.ListenerContainerParserTests.TestBean;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.expression.StandardBeanExpressionResolver;
|
||||
import org.springframework.context.support.GenericXmlApplicationContext;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public final class ListenerContainerPlaceholderParserTests {
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
beanFactory = new GenericXmlApplicationContext(new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass()));
|
||||
((GenericXmlApplicationContext)beanFactory).getDefaultListableBeanFactory().setBeanExpressionResolver(new StandardBeanExpressionResolver());
|
||||
}
|
||||
|
||||
@After
|
||||
public void closeBeanFactory() throws Exception {
|
||||
if (beanFactory!=null) {
|
||||
((ConfigurableApplicationContext)beanFactory).close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseWithQueueNames() throws Exception {
|
||||
SimpleMessageListenerContainer container = beanFactory.getBean("container1", SimpleMessageListenerContainer.class);
|
||||
assertEquals(AcknowledgeMode.MANUAL, container.getAcknowledgeMode());
|
||||
assertEquals(beanFactory.getBean(ConnectionFactory.class), container.getConnectionFactory());
|
||||
assertEquals(MessageListenerAdapter.class, container.getMessageListener().getClass());
|
||||
DirectFieldAccessor listenerAccessor = new DirectFieldAccessor(container.getMessageListener());
|
||||
assertEquals(beanFactory.getBean(TestBean.class), listenerAccessor.getPropertyValue("delegate"));
|
||||
assertEquals("handle", listenerAccessor.getPropertyValue("defaultListenerMethod"));
|
||||
Queue queue = beanFactory.getBean("bar", Queue.class);
|
||||
assertEquals("[foo, "+queue.getName()+"]", Arrays.asList(container.getQueueNames()).toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.amqp.rabbit.config;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.GenericXmlApplicationContext;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class QueueParserPlaceholderTests extends QueueParserTests {
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUpDefaultBeanFactory() throws Exception {
|
||||
beanFactory = new GenericXmlApplicationContext(new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass()));
|
||||
}
|
||||
|
||||
@After
|
||||
public void closeBeanFactory() throws Exception {
|
||||
if (beanFactory!=null) {
|
||||
((ConfigurableApplicationContext)beanFactory).close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,12 +24,13 @@ import org.junit.Test;
|
||||
import org.springframework.amqp.core.AnonymousQueue;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
public final class QueueParserTests {
|
||||
public class QueueParserTests {
|
||||
|
||||
private XmlBeanFactory beanFactory;
|
||||
protected BeanFactory beanFactory;
|
||||
|
||||
@Before
|
||||
public void setUpDefaultBeanFactory() throws Exception {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="properties">
|
||||
<props>
|
||||
<prop key="five">5</prop>
|
||||
<prop key="one">1</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<rabbit:queue name="foo" />
|
||||
|
||||
<rabbit:queue id="bar" />
|
||||
|
||||
<rabbit:listener-container id="container1" connection-factory="connectionFactory" acknowledge="manual" concurrency="${five}" transaction-size="${one}">
|
||||
<rabbit:listener id="testListener" queue-names="foo, #{bar.name}" ref="testBean" method="handle"/>
|
||||
</rabbit:listener-container>
|
||||
|
||||
<bean id="connectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory"/>
|
||||
|
||||
<bean id="testBean" class="org.springframework.amqp.rabbit.config.ListenerContainerParserTests$TestBean"/>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:rabbit="http://www.springframework.org/schema/rabbit" xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="properties">
|
||||
<props>
|
||||
<prop key="foo">foo</prop>
|
||||
<prop key="true">true</prop>
|
||||
<prop key="bar">bar</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<rabbit:queue name="${foo}" />
|
||||
|
||||
<rabbit:queue name="override" durable="${true}" auto-delete="${true}" exclusive="${true}" />
|
||||
|
||||
<rabbit:queue id="alias" name="spam" />
|
||||
|
||||
<rabbit:queue id="overrideAlias" name="bar" durable="true" auto-delete="true" exclusive="true" />
|
||||
|
||||
<rabbit:queue id="anonymous" />
|
||||
|
||||
<rabbit:queue name="arguments">
|
||||
<rabbit:queue-arguments>
|
||||
<beans:entry key="foo" value="${bar}" />
|
||||
</rabbit:queue-arguments>
|
||||
</rabbit:queue>
|
||||
|
||||
<rabbit:queue id="anonymousArguments">
|
||||
<rabbit:queue-arguments>
|
||||
<beans:entry key="foo" value="spam" />
|
||||
</rabbit:queue-arguments>
|
||||
</rabbit:queue>
|
||||
|
||||
<rabbit:queue id="anonymousOverride" durable="false" auto-delete="true" exclusive="true" />
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user