added namespace support for the 'default-notification-type' on the notification-publishing-channel-adapter
This commit is contained in:
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -34,6 +35,7 @@ public class NotificationPublishingChannelAdapterParser extends AbstractOutbound
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(
|
||||
"org.springframework.integration.jmx.NotificationPublishingMessageHandler");
|
||||
builder.addConstructorArgValue(element.getAttribute("object-name"));
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "default-notification-type");
|
||||
return builder.getBeanDefinition();
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
<xsd:attribute name="id" type="xsd:string" use="optional"/>
|
||||
<xsd:attribute name="channel" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="object-name" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="default-notification-type" type="xsd:string" use="optional"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
|
||||
<jmx:notification-publishing-channel-adapter
|
||||
id="adapter" channel="channel"
|
||||
object-name="test.publisher:name=publisher"/>
|
||||
object-name="test.publisher:name=publisher"
|
||||
default-notification-type="default.type"/>
|
||||
|
||||
<bean id="testListener" class="org.springframework.integration.jmx.config.TestListener"/>
|
||||
|
||||
|
||||
@@ -81,6 +81,17 @@ public class NotificationPublishingChannelAdapterParserTests {
|
||||
assertEquals("test.type", notification.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultNotificationType() throws Exception {
|
||||
assertNull(listener.lastNotification);
|
||||
Message<?> message = MessageBuilder.withPayload("test").build();
|
||||
channel.send(message);
|
||||
assertNotNull(listener.lastNotification);
|
||||
Notification notification = listener.lastNotification;
|
||||
assertEquals("default.type", notification.getType());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static class TestData {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user