Skip to content

Commit 1843bdd

Browse files
committed
added "forwarder" property to ConnectorServerFactoryBean, accepting an MBeanServerForwarder (SPR-8820)
1 parent b55040c commit 1843bdd

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

org.springframework.context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2011 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
import javax.management.remote.JMXConnectorServer;
2828
import javax.management.remote.JMXConnectorServerFactory;
2929
import javax.management.remote.JMXServiceURL;
30+
import javax.management.remote.MBeanServerForwarder;
3031

3132
import org.springframework.beans.factory.DisposableBean;
3233
import org.springframework.beans.factory.FactoryBean;
@@ -63,6 +64,8 @@ public class ConnectorServerFactoryBean extends MBeanRegistrationSupport
6364

6465
private Map<String, Object> environment = new HashMap<String, Object>();
6566

67+
private MBeanServerForwarder forwarder;
68+
6669
private ObjectName objectName;
6770

6871
private boolean threaded = false;
@@ -97,6 +100,13 @@ public void setEnvironmentMap(Map<String, ?> environment) {
97100
}
98101
}
99102

103+
/**
104+
* Set an MBeanServerForwarder to be applied to the <code>JMXConnectorServer</code>.
105+
*/
106+
public void setForwarder(MBeanServerForwarder forwarder) {
107+
this.forwarder = forwarder;
108+
}
109+
100110
/**
101111
* Set the <code>ObjectName</code> used to register the <code>JMXConnectorServer</code>
102112
* itself with the <code>MBeanServer</code>, as <code>ObjectName</code> instance
@@ -143,6 +153,11 @@ public void afterPropertiesSet() throws JMException, IOException {
143153
// Create the connector server now.
144154
this.connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, this.environment, this.server);
145155

156+
// Set the given MBeanServerForwarder, if any.
157+
if (this.forwarder != null) {
158+
this.connectorServer.setMBeanServerForwarder(this.forwarder);
159+
}
160+
146161
// Do we want to register the connector with the MBean server?
147162
if (this.objectName != null) {
148163
doRegister(this.connectorServer, this.objectName);

0 commit comments

Comments
 (0)