INT-1817 added namespace support for object-name-static-properties for IntegrationMBeanExporter
This commit is contained in:
@@ -52,6 +52,8 @@ public class MBeanExporterParser extends AbstractSingleBeanDefinitionParser {
|
|||||||
Object mbeanServer = getMBeanServer(element, parserContext);
|
Object mbeanServer = getMBeanServer(element, parserContext);
|
||||||
builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
|
builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
|
||||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "default-domain");
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "default-domain");
|
||||||
|
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "object-name-static-properties-ref", "objectNameStaticProperties");
|
||||||
|
|
||||||
builder.addPropertyValue("server", mbeanServer);
|
builder.addPropertyValue("server", mbeanServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import java.lang.reflect.Field;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
@@ -29,6 +30,7 @@ import javax.management.modelmbean.ModelMBean;
|
|||||||
import org.aopalliance.aop.Advice;
|
import org.aopalliance.aop.Advice;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.aop.Advisor;
|
import org.springframework.aop.Advisor;
|
||||||
import org.springframework.aop.PointcutAdvisor;
|
import org.springframework.aop.PointcutAdvisor;
|
||||||
import org.springframework.aop.TargetSource;
|
import org.springframework.aop.TargetSource;
|
||||||
@@ -132,7 +134,7 @@ public class IntegrationMBeanExporter extends MBeanExporter implements BeanPostP
|
|||||||
|
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
|
|
||||||
private final Map<String, String> objectNameStaticProperties = new HashMap<String, String>();
|
private final Properties objectNameStaticProperties = new Properties();
|
||||||
|
|
||||||
private final MetadataMBeanInfoAssembler assembler = new MetadataMBeanInfoAssembler(attributeSource);
|
private final MetadataMBeanInfoAssembler assembler = new MetadataMBeanInfoAssembler(attributeSource);
|
||||||
|
|
||||||
@@ -617,7 +619,8 @@ public class IntegrationMBeanExporter extends MBeanExporter implements BeanPostP
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (String key : objectNameStaticProperties.keySet()) {
|
|
||||||
|
for (Object key : objectNameStaticProperties.keySet()) {
|
||||||
builder.append("," + key + "=" + objectNameStaticProperties.get(key));
|
builder.append("," + key + "=" + objectNameStaticProperties.get(key));
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|||||||
@@ -112,6 +112,18 @@
|
|||||||
</xsd:documentation>
|
</xsd:documentation>
|
||||||
</xsd:annotation>
|
</xsd:annotation>
|
||||||
</xsd:attribute>
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="object-name-static-properties-ref" use="optional">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:appinfo>
|
||||||
|
<tool:annotation kind="ref">
|
||||||
|
<tool:expected-type type="java.util.Properties" />
|
||||||
|
</tool:annotation>
|
||||||
|
</xsd:appinfo>
|
||||||
|
<xsd:documentation>
|
||||||
|
Static object properties to be used for this domain.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
</xsd:extension>
|
</xsd:extension>
|
||||||
</xsd:complexContent>
|
</xsd:complexContent>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|||||||
@@ -4,19 +4,25 @@
|
|||||||
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
xmlns:si="http://www.springframework.org/schema/integration"
|
xmlns:si="http://www.springframework.org/schema/integration"
|
||||||
xmlns:jmx="http://www.springframework.org/schema/integration/jmx"
|
xmlns:jmx="http://www.springframework.org/schema/integration/jmx"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
xmlns:util="http://www.springframework.org/schema/util"
|
||||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||||
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/integration/jmx http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd
|
||||||
http://www.springframework.org/schema/context/spring-context.xsd
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
http://www.springframework.org/schema/integration
|
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
|
||||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||||
http://www.springframework.org/schema/integration/jmx
|
|
||||||
http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd">
|
|
||||||
|
|
||||||
<context:mbean-server id="mbs"/>
|
<context:mbean-server id="mbs"/>
|
||||||
|
|
||||||
<si:channel id="testChannel"/>
|
<si:channel id="testChannel"/>
|
||||||
|
|
||||||
<jmx:mbean-export id="integratioMbeanExporter" server="mbs" default-domain="tests.MBeanExpoerterParser"/>
|
<jmx:mbean-export id="integratioMbeanExporter"
|
||||||
|
server="mbs"
|
||||||
|
default-domain="tests.MBeanExpoerterParser"
|
||||||
|
object-name-static-properties-ref="appProperties"/>
|
||||||
|
|
||||||
|
<util:properties id="appProperties">
|
||||||
|
<prop key="foo">foo</prop>
|
||||||
|
<prop key="bar">bar</prop>
|
||||||
|
</util:properties>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|||||||
@@ -16,20 +16,27 @@
|
|||||||
|
|
||||||
package org.springframework.integration.jmx.config;
|
package org.springframework.integration.jmx.config;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
|
import static junit.framework.Assert.assertNotNull;
|
||||||
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.management.MBeanServer;
|
import javax.management.MBeanServer;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.integration.monitor.IntegrationMBeanExporter;
|
import org.springframework.integration.monitor.IntegrationMBeanExporter;
|
||||||
|
import org.springframework.integration.test.util.TestUtils;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
|
* @author Oleg Zhurakousky
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
@@ -43,6 +50,11 @@ public class MBeanExporterParserTests {
|
|||||||
public void testMBeanExporterExists() throws InterruptedException {
|
public void testMBeanExporterExists() throws InterruptedException {
|
||||||
IntegrationMBeanExporter exporter = this.context.getBean(IntegrationMBeanExporter.class);
|
IntegrationMBeanExporter exporter = this.context.getBean(IntegrationMBeanExporter.class);
|
||||||
MBeanServer server = this.context.getBean("mbs", MBeanServer.class);
|
MBeanServer server = this.context.getBean("mbs", MBeanServer.class);
|
||||||
|
Properties properties = TestUtils.getPropertyValue(exporter, "objectNameStaticProperties", Properties.class);
|
||||||
|
assertNotNull(properties);
|
||||||
|
assertEquals(2, properties.size());
|
||||||
|
assertTrue(properties.containsKey("foo"));
|
||||||
|
assertTrue(properties.containsKey("bar"));
|
||||||
assertEquals(server, exporter.getServer());
|
assertEquals(server, exporter.getServer());
|
||||||
exporter.destroy();
|
exporter.destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user