INT-1023 Added namespace support for the Control Bus.

This commit is contained in:
Mark Fisher
2010-04-08 18:10:22 +00:00
parent 0e85bbdd1d
commit 86091eecfd
5 changed files with 168 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
/*
* 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.integration.jmx.config;
import javax.management.MBeanServerFactory;
import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.util.StringUtils;
/**
* @author Mark Fisher
* @since 2.0
*/
public class ControlBusParser extends AbstractSimpleBeanDefinitionParser {
@Override
protected String getBeanClassName(Element element) {
return "org.springframework.integration.control.ControlBus";
}
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
Object source = parserContext.extractSource(element);
builder.getRawBeanDefinition().setSource(source);
String mbeanServer = element.getAttribute("mbean-server");
if (StringUtils.hasText(mbeanServer)) {
builder.addConstructorArgReference(mbeanServer);
}
else {
builder.addConstructorArgValue(MBeanServerFactory.createMBeanServer());
}
String domain = element.getAttribute("domain");
if (StringUtils.hasText(domain)) {
builder.addConstructorArgValue(domain);
}
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "operation-channel");
}
}

View File

@@ -31,6 +31,7 @@ public class JmxNamespaceHandler extends AbstractIntegrationNamespaceHandler {
this.registerBeanDefinitionParser("attribute-polling-channel-adapter", new AttributePollingChannelAdapterParser());
this.registerBeanDefinitionParser("notification-listening-channel-adapter", new NotificationListeningChannelAdapterParser());
this.registerBeanDefinitionParser("notification-publishing-channel-adapter", new NotificationPublishingChannelAdapterParser());
this.registerBeanDefinitionParser("control-bus", new ControlBusParser());
}
}

View File

@@ -84,4 +84,43 @@
</xsd:complexType>
</xsd:element>
<xsd:element name="control-bus">
<xsd:annotation>
<xsd:documentation>
Defines a Control Bus that exports Message Channels and Endpoints as MBeans
and connects to an "operation channel".
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="id" use="optional"/>
<xsd:attribute name="mbean-server" use="optional">
<xsd:annotation>
<xsd:documentation>
The MBeanServer to which this Control Bus should export MBeans.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="domain" use="optional">
<xsd:annotation>
<xsd:documentation>
The domain name for the MBeans exported by this Control Bus.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="operation-channel" use="optional">
<xsd:annotation>
<xsd:documentation>
The Message Channel that can be used to send operation commands to
this Control Bus. It must implement SubscribableChannel.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:expected-type type="org.springframework.integration.channel.SubscribableChannel"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:schema>