added "forwarder" property to ConnectorServerFactoryBean, accepting an MBeanServerForwarder (SPR-8820)

This commit is contained in:
Juergen Hoeller 2011-11-28 17:17:47 +00:00
parent b55040cf02
commit 1843bdde35
1 changed files with 16 additions and 1 deletions

View File

@ -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<String, Object> environment = new HashMap<String, Object>();
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 <code>JMXConnectorServer</code>.
*/
public void setForwarder(MBeanServerForwarder forwarder) {
this.forwarder = forwarder;
}
/**
* Set the <code>ObjectName</code> used to register the <code>JMXConnectorServer</code>
* itself with the <code>MBeanServer</code>, as <code>ObjectName</code> 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);