|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2009 the original author or authors. |
| 2 | + * Copyright 2002-2011 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
27 | 27 | import javax.management.remote.JMXConnectorServer;
|
28 | 28 | import javax.management.remote.JMXConnectorServerFactory;
|
29 | 29 | import javax.management.remote.JMXServiceURL;
|
| 30 | +import javax.management.remote.MBeanServerForwarder; |
30 | 31 |
|
31 | 32 | import org.springframework.beans.factory.DisposableBean;
|
32 | 33 | import org.springframework.beans.factory.FactoryBean;
|
@@ -63,6 +64,8 @@ public class ConnectorServerFactoryBean extends MBeanRegistrationSupport
|
63 | 64 |
|
64 | 65 | private Map<String, Object> environment = new HashMap<String, Object>();
|
65 | 66 |
|
| 67 | + private MBeanServerForwarder forwarder; |
| 68 | + |
66 | 69 | private ObjectName objectName;
|
67 | 70 |
|
68 | 71 | private boolean threaded = false;
|
@@ -97,6 +100,13 @@ public void setEnvironmentMap(Map<String, ?> environment) {
|
97 | 100 | }
|
98 | 101 | }
|
99 | 102 |
|
| 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 | + |
100 | 110 | /**
|
101 | 111 | * Set the <code>ObjectName</code> used to register the <code>JMXConnectorServer</code>
|
102 | 112 | * itself with the <code>MBeanServer</code>, as <code>ObjectName</code> instance
|
@@ -143,6 +153,11 @@ public void afterPropertiesSet() throws JMException, IOException {
|
143 | 153 | // Create the connector server now.
|
144 | 154 | this.connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, this.environment, this.server);
|
145 | 155 |
|
| 156 | + // Set the given MBeanServerForwarder, if any. |
| 157 | + if (this.forwarder != null) { |
| 158 | + this.connectorServer.setMBeanServerForwarder(this.forwarder); |
| 159 | + } |
| 160 | + |
146 | 161 | // Do we want to register the connector with the MBean server?
|
147 | 162 | if (this.objectName != null) {
|
148 | 163 | doRegister(this.connectorServer, this.objectName);
|
|
0 commit comments