diff --git a/org.springframework.context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java index 9a1f3991cf..a86f2a7c89 100644 --- a/org.springframework.context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2011 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. @@ -27,6 +27,7 @@ import javax.management.ObjectName; import javax.management.remote.JMXConnectorServer; import javax.management.remote.JMXConnectorServerFactory; import javax.management.remote.JMXServiceURL; +import javax.management.remote.MBeanServerForwarder; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.FactoryBean; @@ -63,6 +64,8 @@ public class ConnectorServerFactoryBean extends MBeanRegistrationSupport private Map environment = new HashMap(); + private MBeanServerForwarder forwarder; + private ObjectName objectName; private boolean threaded = false; @@ -97,6 +100,13 @@ public class ConnectorServerFactoryBean extends MBeanRegistrationSupport } } + /** + * Set an MBeanServerForwarder to be applied to the JMXConnectorServer. + */ + public void setForwarder(MBeanServerForwarder forwarder) { + this.forwarder = forwarder; + } + /** * Set the ObjectName used to register the JMXConnectorServer * itself with the MBeanServer, as ObjectName instance @@ -143,6 +153,11 @@ public class ConnectorServerFactoryBean extends MBeanRegistrationSupport // Create the connector server now. this.connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, this.environment, this.server); + // Set the given MBeanServerForwarder, if any. + if (this.forwarder != null) { + this.connectorServer.setMBeanServerForwarder(this.forwarder); + } + // Do we want to register the connector with the MBean server? if (this.objectName != null) { doRegister(this.connectorServer, this.objectName);