Adding the APIBuilder

The APIBuilder is an implementation for the MBeanServerBuilder that is
used to instantiate the APIMBeanServer as the platform MBeanServer.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This commit is contained in:
Amnon Heiman 2016-05-02 13:21:55 +03:00
parent 4e02c52aee
commit 1daa5eb030
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
package com.scylladb.jmx.utils;
/**
* Copyright 2016 ScyllaDB
*/
/*
* This file is part of Scylla.
*
* Scylla is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Scylla is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Scylla. If not, see <http://www.gnu.org/licenses/>.
*/
import javax.management.MBeanServer;
import javax.management.MBeanServerDelegate;
import mx4j.server.ChainedMBeanServerBuilder;
public class APIBuilder extends ChainedMBeanServerBuilder {
public APIBuilder() {
super(new mx4j.server.MX4JMBeanServerBuilder());
}
public MBeanServer newMBeanServer(String defaultDomain, MBeanServer outer,
MBeanServerDelegate delegate) {
APIMBeanServer extern = new APIMBeanServer();
MBeanServer nested = getMBeanServerBuilder().newMBeanServer(
defaultDomain, outer == null ? extern : outer, delegate);
extern.setMBeanServer(nested);
return extern;
}
}