本文整理匯總了Java中javax.management.MBeanServerFactory.releaseMBeanServer方法的典型用法代碼示例。如果您正苦於以下問題:Java MBeanServerFactory.releaseMBeanServer方法的具體用法?Java MBeanServerFactory.releaseMBeanServer怎麽用?Java MBeanServerFactory.releaseMBeanServer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.management.MBeanServerFactory
的用法示例。
在下文中一共展示了MBeanServerFactory.releaseMBeanServer方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: destroy
import javax.management.MBeanServerFactory; //導入方法依賴的package包/類
/**
* Unregisters the {@code MBeanServer} instance, if necessary.
*/
@Override
public void destroy() {
if (this.newlyRegistered) {
MBeanServerFactory.releaseMBeanServer(this.server);
}
}
示例2: releaseMBeanServer
import javax.management.MBeanServerFactory; //導入方法依賴的package包/類
/**
* Unregisters all GemFire MBeans and then releases the MBeanServer for garbage collection.
*/
static void releaseMBeanServer() {
try {
// unregister all GemFire mbeans...
Iterator iter = mbeanServer.queryNames(null, null).iterator();
while (iter.hasNext()) {
ObjectName name = (ObjectName) iter.next();
if (name.getDomain().startsWith(DEFAULT_DOMAIN)) {
unregisterMBean(name);
}
}
// last, release the mbean server...
MBeanServerFactory.releaseMBeanServer(mbeanServer);
mbeanServer = null;
} catch (JMRuntimeException e) {
logStackTrace(Level.WARN, e);
}
/*
* See #42391. Cleaning up the static maps which might be still holding references to
* ManagedResources
*/
synchronized (MBeanUtil.managedResources) {
MBeanUtil.managedResources.clear();
}
synchronized (refreshClients) {
refreshClients.clear();
}
/*
* See #42391. Cleaning up the static maps which might be still holding references to
* ManagedResources
*/
synchronized (MBeanUtil.managedResources) {
MBeanUtil.managedResources.clear();
}
synchronized (refreshClients) {
refreshClients.clear();
}
}
示例3: close
import javax.management.MBeanServerFactory; //導入方法依賴的package包/類
/**
* Abort open transactions and unregister read only modules. Since this class is
* not responsible for registering itself under
* {@link org.opendaylight.controller.config.api.ConfigRegistry#OBJECT_NAME}, it
* will not unregister itself here.
*/
@Override
public void close() {
if (!closed.compareAndSet(false, true)) {
return;
}
// abort transactions
Map<String, Entry<ConfigTransactionControllerInternal, ConfigTransactionLookupRegistry>> transactions =
transactionsHolder.getCurrentTransactions();
for (Entry<ConfigTransactionControllerInternal, ConfigTransactionLookupRegistry>
configTransactionControllerEntry : transactions.values()) {
ConfigTransactionControllerInternal configTransactionController = configTransactionControllerEntry.getKey();
configTransactionControllerEntry.getValue().close();
configTransactionController.abortConfig();
}
// destroy all live objects one after another in order of the dependency
// hierarchy, from top to bottom
List<DestroyedModule> destroyedModules = currentConfig.getModulesToBeDestroyed();
LOG.info("ConfigRegistry closing - destroying {} modules", destroyedModules.size());
for (DestroyedModule destroyedModule : destroyedModules) {
destroyedModule.close();
}
// unregister MBeans that failed to unregister properly
baseJMXRegistrator.close();
// remove jmx servers
MBeanServerFactory.releaseMBeanServer(registryMBeanServer);
MBeanServerFactory.releaseMBeanServer(transactionsMBeanServer);
LOG.info("ConfigRegistry closed");
}
示例4: main
import javax.management.MBeanServerFactory; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
boolean error = false;
// Instantiate the MBean server
//
System.out.println("Create the MBean server");
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
// Instantiate an MLet
//
System.out.println("Create the MLet");
MLet mlet = new MLet();
// Register the MLet MBean with the MBeanServer
//
System.out.println("Register the MLet MBean");
ObjectName mletObjectName = new ObjectName("Test:type=MLet");
mbs.registerMBean(mlet, mletObjectName);
// Call getMBeansFromURL
//
System.out.println("Call mlet.getMBeansFromURL(<url>)");
String testSrc = System.getProperty("test.src");
System.out.println("test.src = " + testSrc);
String urlCodebase;
if (testSrc.startsWith("/")) {
urlCodebase =
"file:" + testSrc.replace(File.separatorChar, '/') + "/";
} else {
urlCodebase =
"file:/" + testSrc.replace(File.separatorChar, '/') + "/";
}
String mletFile = urlCodebase + args[0];
System.out.println("MLet File = " + mletFile);
try {
mlet.getMBeansFromURL(mletFile);
System.out.println(
"TEST FAILED: Expected ServiceNotFoundException not thrown");
error = true;
} catch (ServiceNotFoundException e) {
if (e.getCause() == null) {
System.out.println("TEST FAILED: Got unexpected null cause " +
"in ServiceNotFoundException");
error = true;
} else if (!(e.getCause() instanceof IOException)) {
System.out.println("TEST FAILED: Got unexpected non-null " +
"cause in ServiceNotFoundException");
error = true;
} else {
System.out.println("TEST PASSED: Got expected non-null " +
"cause in ServiceNotFoundException");
error = false;
}
e.printStackTrace(System.out);
}
// Unregister the MLet MBean
//
System.out.println("Unregister the MLet MBean");
mbs.unregisterMBean(mletObjectName);
// Release MBean server
//
System.out.println("Release the MBean server");
MBeanServerFactory.releaseMBeanServer(mbs);
// End Test
//
System.out.println("Bye! Bye!");
if (error) System.exit(1);
}
示例5: main
import javax.management.MBeanServerFactory; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
boolean error = false;
// Instantiate the MBean server
//
System.out.println("Create the MBean server");
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
// Instantiate an MLet
//
System.out.println("Create the MLet");
MLet mlet = new MLet();
// Register the MLet MBean with the MBeanServer
//
System.out.println("Register the MLet MBean");
ObjectName mletObjectName = new ObjectName("Test:type=MLet");
mbs.registerMBean(mlet, mletObjectName);
// Call getMBeansFromURL
//
System.out.println("Call mlet.getMBeansFromURL(<url>)");
try {
mlet.getMBeansFromURL("bogus://whatever");
System.out.println("TEST FAILED: Expected " +
ServiceNotFoundException.class +
" exception not thrown.");
error = true;
} catch (ServiceNotFoundException e) {
if (e.getCause() == null) {
System.out.println("TEST FAILED: Got null cause in " +
ServiceNotFoundException.class +
" exception.");
error = true;
} else {
System.out.println("TEST PASSED: Got non-null cause in " +
ServiceNotFoundException.class +
" exception.");
error = false;
}
e.printStackTrace(System.out);
}
// Unregister the MLet MBean
//
System.out.println("Unregister the MLet MBean");
mbs.unregisterMBean(mletObjectName);
// Release MBean server
//
System.out.println("Release the MBean server");
MBeanServerFactory.releaseMBeanServer(mbs);
// End Test
//
System.out.println("Bye! Bye!");
if (error) System.exit(1);
}
示例6: test
import javax.management.MBeanServerFactory; //導入方法依賴的package包/類
private static void test(String proto) throws Exception {
System.out.println("Unexpected notifications test for protocol " +
proto);
MBeanServer mbs = null;
try {
// Create a MBeanServer
//
mbs = MBeanServerFactory.createMBeanServer();
// Create a NotificationEmitter MBean
//
mbean = new ObjectName ("Default:name=NotificationEmitter");
mbs.registerMBean(new NotificationEmitter(), mbean);
// Create a connector server
//
url = new JMXServiceURL("service:jmx:" + proto + "://");
server = JMXConnectorServerFactory.newJMXConnectorServer(url,
null,
mbs);
mbs.registerMBean(
server,
new ObjectName("Default:name=ConnectorServer"));
server.start();
url = server.getAddress();
for (int j = 0; j < 2; j++) {
test();
}
} finally {
// Stop server
//
server.stop();
// Release the MBeanServer
//
MBeanServerFactory.releaseMBeanServer(mbs);
}
}
示例7: main
import javax.management.MBeanServerFactory; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
boolean error = false;
// Instantiate the MBean server
//
System.out.println("Create the MBean server");
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
// Get Default Locale
Locale loc = Locale.getDefault();
// Instantiate an MLet
//
System.out.println("Create the MLet");
MLet mlet = new MLet();
// Register the MLet MBean with the MBeanServer
//
System.out.println("Register the MLet MBean");
ObjectName mletObjectName = new ObjectName("Test:type=MLet");
mbs.registerMBean(mlet, mletObjectName);
// Call getMBeansFromURL
//
System.out.println("Call mlet.getMBeansFromURL(<url>)");
String testSrc = System.getProperty("test.src");
System.out.println("test.src = " + testSrc);
String urlCodebase;
if (testSrc.startsWith("/")) {
urlCodebase =
"file:" + testSrc.replace(File.separatorChar, '/') + "/";
} else {
urlCodebase =
"file:/" + testSrc.replace(File.separatorChar, '/') + "/";
}
String mletFile = urlCodebase + args[0];
System.out.println("MLet File = " + mletFile);
try {
// Change default Locale to Turkish
Locale.setDefault(new Locale("tr", "TR"));
mlet.getMBeansFromURL(mletFile);
System.out.println("Test Passes");
} catch (Exception e) {
error = true;
e.printStackTrace(System.out);
}finally {
Locale.setDefault(loc);
}
// Unregister the MLet MBean
//
System.out.println("Unregister the MLet MBean");
mbs.unregisterMBean(mletObjectName);
// Release MBean server
//
System.out.println("Release the MBean server");
MBeanServerFactory.releaseMBeanServer(mbs);
// End Test
//
System.out.println("Bye! Bye!");
if (error) System.exit(1);
}
示例8: unregisterFromJMX
import javax.management.MBeanServerFactory; //導入方法依賴的package包/類
@After
public void unregisterFromJMX() throws Exception {
TestingFixedThreadPool.cleanUp();
platformMBeanServer.unregisterMBean(threadPoolDynamicWrapperON);
MBeanServerFactory.releaseMBeanServer(internalServer);
}
示例9: cleanUp
import javax.management.MBeanServerFactory; //導入方法依賴的package包/類
@After
public void cleanUp() {
baseJMXRegistrator.close();
MBeanServerFactory.releaseMBeanServer(transactionsMBeanServer);
}