protected void doStart() throws IOException
{
JMXServiceURL address = getAddress();
String protocol = address.getProtocol();
Map environment = getEnvironment();
ConnectionResolver resolver = ConnectionResolver.newConnectionResolver(protocol, environment);
if (resolver == null) throw new MalformedURLException("Unsupported protocol: " + protocol);
MBeanServer realServer = null;
MBeanServer server = super.getMBeanServer();
MBeanServer resolvedServer = (MBeanServer)resolver.createServer(address, environment);
if (resolvedServer == null)
{
if (server == null) throw new IllegalStateException("This LocalConnectorServer is not attached to an MBeanServer");
realServer = server;
}
else
{
if (server == null)
{
realServer = resolvedServer;
}
else
{
if (server != resolvedServer) throw new IllegalStateException("This LocalConnectorServer cannot be attached to 2 MBeanServers");
realServer = server;
}
}
this.mbeanServer = realServer;
connectionManager = new LocalConnectionManager(this, environment);
setAddress(resolver.bindServer(realServer, address, environment));
// Here is where we give to clients the possibility to access us
register(getAddress(), connectionManager);
}