Java Code Examples for javax.management.MBeanServerConnection#unregisterMBean()
The following examples show how to use
javax.management.MBeanServerConnection#unregisterMBean() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConcurrentModificationTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void mbeanOp(MBeanServerConnection mserver, ObjectName name, boolean adding) throws Exception { if (adding) { mserver.createMBean("javax.management.timer.Timer", name); } else { mserver.unregisterMBean(name); } }
Example 2
Source File: Client.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void main(String[] args) throws Exception { // This JMXServiceURL works only if the connector server is in-VM with // the connector. If this is not the case, set the correct host name. JMXServiceURL address = new JMXServiceURL("soap", null, 8080, "/jmxconnector"); // Connect a JSR 160 JMXConnector to the server side JMXConnector connector = JMXConnectorFactory.connect(address); // Retrieve an MBeanServerConnection that represent the MBeanServer // the remote connector server is bound to MBeanServerConnection connection = connector.getMBeanServerConnection(); // Call the server side as if it is a local MBeanServer ObjectName delegateName = ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate"); Object proxy = MBeanServerInvocationHandler.newProxyInstance(connection, delegateName, MBeanServerDelegateMBean.class, true); MBeanServerDelegateMBean delegate = (MBeanServerDelegateMBean)proxy; System.out.println(delegate.getImplementationVendor() + " is cool !"); // Register an MBean, and get notifications via the SOAP protocol connection.addNotificationListener(delegateName, new NotificationListener() { public void handleNotification(Notification notification, Object handback) { System.out.println("Got the following notification: " + notification); } }, null, null); ObjectName timerName = ObjectName.getInstance("services:type=Timer"); connection.createMBean(Timer.class.getName(), timerName, null); // Unregistering the MBean to get another notification connection.unregisterMBean(timerName); // Allow the unregistration notification to arrive before killing this JVM Thread.sleep(1000); connector.close(); }
Example 3
Source File: ConcurrentModificationTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static void mbeanOp(MBeanServerConnection mserver, ObjectName name, boolean adding) throws Exception { if (adding) { mserver.createMBean("javax.management.timer.Timer", name); } else { mserver.unregisterMBean(name); } }
Example 4
Source File: ConcurrentModificationTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static void mbeanOp(MBeanServerConnection mserver, ObjectName name, boolean adding) throws Exception { if (adding) { mserver.createMBean("javax.management.timer.Timer", name); } else { mserver.unregisterMBean(name); } }
Example 5
Source File: ConcurrentModificationTest.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void mbeanOp(MBeanServerConnection mserver, ObjectName name, boolean adding) throws Exception { if (adding) { mserver.createMBean("javax.management.timer.Timer", name); } else { mserver.unregisterMBean(name); } }
Example 6
Source File: JMXAccessorUnregisterTask.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Unregister Mbean * @param jmxServerConnection * @param name * @return The value of the given named attribute * @throws Exception */ protected String jmxUuregister(MBeanServerConnection jmxServerConnection,String name) throws Exception { String error = null; if(isEcho()) { handleOutput("Unregister MBean " + name ); } jmxServerConnection.unregisterMBean( new ObjectName(name)); return error; }
Example 7
Source File: Client.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void main(String[] args) throws Exception { // This JMXServiceURL works only if the connector server is on the same host of // the connector. If this is not the case, set the correct host name. JMXServiceURL address = new JMXServiceURL("hessian", null, 8080, "/hessian"); // Connect a JSR 160 JMXConnector to the server side JMXConnector connector = JMXConnectorFactory.connect(address); // Retrieve an MBeanServerConnection that represent the MBeanServer // the remote connector server is bound to MBeanServerConnection connection = connector.getMBeanServerConnection(); // Call the server side as if it is a local MBeanServer ObjectName delegateName = ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate"); Object proxy = MBeanServerInvocationHandler.newProxyInstance(connection, delegateName, MBeanServerDelegateMBean.class, true); MBeanServerDelegateMBean delegate = (MBeanServerDelegateMBean)proxy; System.out.println(delegate.getImplementationVendor() + " is cool !"); // Register an MBean, and get notifications via the Hessian protocol connection.addNotificationListener(delegateName, new NotificationListener() { public void handleNotification(Notification notification, Object handback) { System.out.println("Got the following notification: " + notification); } }, null, null); ObjectName timerName = ObjectName.getInstance("services:type=Timer"); connection.createMBean(Timer.class.getName(), timerName, null); // Unregistering the MBean to get another notification connection.unregisterMBean(timerName); // Allow the unregistration notification to arrive before killing this JVM Thread.sleep(1000); connector.close(); }
Example 8
Source File: ConcurrentModificationTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void mbeanOp(MBeanServerConnection mserver, ObjectName name, boolean adding) throws Exception { if (adding) { mserver.createMBean("javax.management.timer.Timer", name); } else { mserver.unregisterMBean(name); } }
Example 9
Source File: JMXAccessorUnregisterTask.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Unregister MBean. * * @param jmxServerConnection Connection to the JMX server * @param name The MBean name * @return null (no error message to report other than exception) * @throws Exception An error occurred */ protected String jmxUuregister(MBeanServerConnection jmxServerConnection,String name) throws Exception { String error = null; if(isEcho()) { handleOutput("Unregister MBean " + name ); } jmxServerConnection.unregisterMBean( new ObjectName(name)); return error; }
Example 10
Source File: Client.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void main(String[] args) throws Exception { // The address of the connector server JMXServiceURL url = new JMXServiceURL("rmi", "localhost", 0, "/jndi/jmx"); // Create and connect the connector client JMXConnector cntor = JMXConnectorFactory.connect(url, null); // The connection represent, on client-side, the remote MBeanServer MBeanServerConnection connection = cntor.getMBeanServerConnection(); // The listener that will receive notifications from a remote MBean NotificationListener listener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { System.out.println(notification); } }; // The MBeanServerDelegate emits notifications about registration/unregistration of MBeans ObjectName delegateName = ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate"); connection.addNotificationListener(delegateName, listener, null, null); // Give chance to the notification machinery to setup Thread.sleep(1000); // Now register a remote MBean, for example an MLet, so that the MBeanServerDelegate // will emit notifications for its registration ObjectName name = ObjectName.getInstance("examples:mbean=mlet"); // First notification connection.createMBean(MLet.class.getName(), name, null); // Second notification connection.unregisterMBean(name); }
Example 11
Source File: JMXAccessorUnregisterTask.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Unregister Mbean * @param jmxServerConnection * @param name * @return The value of the given named attribute * @throws Exception */ protected String jmxUuregister(MBeanServerConnection jmxServerConnection,String name) throws Exception { String error = null; if(isEcho()) { handleOutput("Unregister MBean " + name ); } jmxServerConnection.unregisterMBean( new ObjectName(name)); return error; }
Example 12
Source File: ConcurrentModificationTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void mbeanOp(MBeanServerConnection mserver, ObjectName name, boolean adding) throws Exception { if (adding) { mserver.createMBean("javax.management.timer.Timer", name); } else { mserver.unregisterMBean(name); } }
Example 13
Source File: ConcurrentModificationTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void mbeanOp(MBeanServerConnection mserver, ObjectName name, boolean adding) throws Exception { if (adding) { mserver.createMBean("javax.management.timer.Timer", name); } else { mserver.unregisterMBean(name); } }
Example 14
Source File: ConcurrentModificationTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void mbeanOp(MBeanServerConnection mserver, ObjectName name, boolean adding) throws Exception { if (adding) { mserver.createMBean("javax.management.timer.Timer", name); } else { mserver.unregisterMBean(name); } }
Example 15
Source File: ConcurrentModificationTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void mbeanOp(MBeanServerConnection mserver, ObjectName name, boolean adding) throws Exception { if (adding) { mserver.createMBean("javax.management.timer.Timer", name); } else { mserver.unregisterMBean(name); } }
Example 16
Source File: MXBeanWeirdParamTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { int errorCount = 0 ; String msgTag = "ClientSide::main: "; try { // Get a connection to remote mbean server JMXServiceURL addr = new JMXServiceURL(args[0]); JMXConnector cc = JMXConnectorFactory.connect(addr); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); // ---- System.out.println(msgTag + "Create and register the MBean"); ObjectName objName = new ObjectName("sqe:type=Basic,protocol=rmi") ; mbsc.createMBean(BASIC_MXBEAN_CLASS_NAME, objName); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Get attribute SqeParameterAtt on our MXBean"); Object result = mbsc.getAttribute(objName, "SqeParameterAtt"); System.out.println(msgTag +"(OK) Got result of class " + result.getClass().getName()); System.out.println(msgTag +"Received CompositeData is " + result); System.out.println(msgTag +"---- OK\n") ; // ---- // We use the value returned by getAttribute to perform the invoke. System.out.println(msgTag +"Call operation doWeird on our MXBean [1]"); mbsc.invoke(objName, "doWeird", new Object[]{result}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- // We build the CompositeData ourselves that time. System.out.println(msgTag +"Call operation doWeird on our MXBean [2]"); String typeName = "SqeParameter"; String[] itemNames = new String[] {"glop"}; OpenType<?>[] openTypes = new OpenType<?>[] {SimpleType.STRING}; CompositeType rowType = new CompositeType(typeName, typeName, itemNames, itemNames, openTypes); Object[] itemValues = {"HECTOR"}; CompositeData data = new CompositeDataSupport(rowType, itemNames, itemValues); TabularType tabType = new TabularType(typeName, typeName, rowType, new String[]{"glop"}); TabularDataSupport tds = new TabularDataSupport(tabType); tds.put(data); System.out.println(msgTag +"Source CompositeData is " + data); mbsc.invoke(objName, "doWeird", new Object[]{data}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Unregister the MBean"); mbsc.unregisterMBean(objName); System.out.println(msgTag +"---- OK\n") ; // Terminate the JMX Client cc.close(); } catch(Exception e) { Utils.printThrowable(e, true) ; errorCount++; throw new RuntimeException(e); } finally { System.exit(errorCount); } }
Example 17
Source File: MXBeanWeirdParamTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { int errorCount = 0 ; String msgTag = "ClientSide::main: "; try { // Get a connection to remote mbean server JMXServiceURL addr = new JMXServiceURL(args[0]); JMXConnector cc = JMXConnectorFactory.connect(addr); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); // ---- System.out.println(msgTag + "Create and register the MBean"); ObjectName objName = new ObjectName("sqe:type=Basic,protocol=rmi") ; mbsc.createMBean(BASIC_MXBEAN_CLASS_NAME, objName); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Get attribute SqeParameterAtt on our MXBean"); Object result = mbsc.getAttribute(objName, "SqeParameterAtt"); System.out.println(msgTag +"(OK) Got result of class " + result.getClass().getName()); System.out.println(msgTag +"Received CompositeData is " + result); System.out.println(msgTag +"---- OK\n") ; // ---- // We use the value returned by getAttribute to perform the invoke. System.out.println(msgTag +"Call operation doWeird on our MXBean [1]"); mbsc.invoke(objName, "doWeird", new Object[]{result}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- // We build the CompositeData ourselves that time. System.out.println(msgTag +"Call operation doWeird on our MXBean [2]"); String typeName = "SqeParameter"; String[] itemNames = new String[] {"glop"}; OpenType<?>[] openTypes = new OpenType<?>[] {SimpleType.STRING}; CompositeType rowType = new CompositeType(typeName, typeName, itemNames, itemNames, openTypes); Object[] itemValues = {"HECTOR"}; CompositeData data = new CompositeDataSupport(rowType, itemNames, itemValues); TabularType tabType = new TabularType(typeName, typeName, rowType, new String[]{"glop"}); TabularDataSupport tds = new TabularDataSupport(tabType); tds.put(data); System.out.println(msgTag +"Source CompositeData is " + data); mbsc.invoke(objName, "doWeird", new Object[]{data}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Unregister the MBean"); mbsc.unregisterMBean(objName); System.out.println(msgTag +"---- OK\n") ; // Terminate the JMX Client cc.close(); } catch(Exception e) { Utils.printThrowable(e, true) ; errorCount++; throw new RuntimeException(e); } finally { System.exit(errorCount); } }
Example 18
Source File: MXBeanWeirdParamTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { int errorCount = 0 ; String msgTag = "ClientSide::main: "; try { // Get a connection to remote mbean server JMXServiceURL addr = new JMXServiceURL(args[0]); JMXConnector cc = JMXConnectorFactory.connect(addr); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); // ---- System.out.println(msgTag + "Create and register the MBean"); ObjectName objName = new ObjectName("sqe:type=Basic,protocol=rmi") ; mbsc.createMBean(BASIC_MXBEAN_CLASS_NAME, objName); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Get attribute SqeParameterAtt on our MXBean"); Object result = mbsc.getAttribute(objName, "SqeParameterAtt"); System.out.println(msgTag +"(OK) Got result of class " + result.getClass().getName()); System.out.println(msgTag +"Received CompositeData is " + result); System.out.println(msgTag +"---- OK\n") ; // ---- // We use the value returned by getAttribute to perform the invoke. System.out.println(msgTag +"Call operation doWeird on our MXBean [1]"); mbsc.invoke(objName, "doWeird", new Object[]{result}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- // We build the CompositeData ourselves that time. System.out.println(msgTag +"Call operation doWeird on our MXBean [2]"); String typeName = "SqeParameter"; String[] itemNames = new String[] {"glop"}; OpenType<?>[] openTypes = new OpenType<?>[] {SimpleType.STRING}; CompositeType rowType = new CompositeType(typeName, typeName, itemNames, itemNames, openTypes); Object[] itemValues = {"HECTOR"}; CompositeData data = new CompositeDataSupport(rowType, itemNames, itemValues); TabularType tabType = new TabularType(typeName, typeName, rowType, new String[]{"glop"}); TabularDataSupport tds = new TabularDataSupport(tabType); tds.put(data); System.out.println(msgTag +"Source CompositeData is " + data); mbsc.invoke(objName, "doWeird", new Object[]{data}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Unregister the MBean"); mbsc.unregisterMBean(objName); System.out.println(msgTag +"---- OK\n") ; // Terminate the JMX Client cc.close(); } catch(Exception e) { Utils.printThrowable(e, true) ; errorCount++; throw new RuntimeException(e); } finally { System.exit(errorCount); } }
Example 19
Source File: Client.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public static void main(String[] args) throws Exception { // Replace the value with the file path of your keystore. // IMPORTANT: this should NOT be done in production environments, it is shown here just as an example. System.setProperty("javax.net.ssl.trustStore", "<your-keystore>"); // This JMXServiceURL works only if the connector server is on the same host of // the connector. If this is not the case, set the correct host name. JMXServiceURL address = new JMXServiceURL("hessian+ssl", null, 8443, "/hessianssl"); // Connect a JSR 160 JMXConnector to the server side JMXConnector connector = JMXConnectorFactory.connect(address); // Retrieve an MBeanServerConnection that represent the MBeanServer // the remote connector server is bound to MBeanServerConnection connection = connector.getMBeanServerConnection(); // Call the server side as if it is a local MBeanServer ObjectName delegateName = ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate"); Object proxy = MBeanServerInvocationHandler.newProxyInstance(connection, delegateName, MBeanServerDelegateMBean.class, true); MBeanServerDelegateMBean delegate = (MBeanServerDelegateMBean)proxy; System.out.println(delegate.getImplementationVendor() + " is cool !"); // Register an MBean, and get notifications via the Hessian protocol connection.addNotificationListener(delegateName, new NotificationListener() { public void handleNotification(Notification notification, Object handback) { System.out.println("Got the following notification: " + notification); } }, null, null); ObjectName timerName = ObjectName.getInstance("services:type=Timer"); connection.createMBean(Timer.class.getName(), timerName, null); // Unregistering the MBean to get another notification connection.unregisterMBean(timerName); // Allow the unregistration notification to arrive before killing this JVM Thread.sleep(1000); connector.close(); }
Example 20
Source File: MXBeanWeirdParamTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { int errorCount = 0 ; String msgTag = "ClientSide::main: "; try { // Get a connection to remote mbean server JMXServiceURL addr = new JMXServiceURL(args[0]); JMXConnector cc = JMXConnectorFactory.connect(addr); MBeanServerConnection mbsc = cc.getMBeanServerConnection(); // ---- System.out.println(msgTag + "Create and register the MBean"); ObjectName objName = new ObjectName("sqe:type=Basic,protocol=rmi") ; mbsc.createMBean(BASIC_MXBEAN_CLASS_NAME, objName); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Get attribute SqeParameterAtt on our MXBean"); Object result = mbsc.getAttribute(objName, "SqeParameterAtt"); System.out.println(msgTag +"(OK) Got result of class " + result.getClass().getName()); System.out.println(msgTag +"Received CompositeData is " + result); System.out.println(msgTag +"---- OK\n") ; // ---- // We use the value returned by getAttribute to perform the invoke. System.out.println(msgTag +"Call operation doWeird on our MXBean [1]"); mbsc.invoke(objName, "doWeird", new Object[]{result}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- // We build the CompositeData ourselves that time. System.out.println(msgTag +"Call operation doWeird on our MXBean [2]"); String typeName = "SqeParameter"; String[] itemNames = new String[] {"glop"}; OpenType<?>[] openTypes = new OpenType<?>[] {SimpleType.STRING}; CompositeType rowType = new CompositeType(typeName, typeName, itemNames, itemNames, openTypes); Object[] itemValues = {"HECTOR"}; CompositeData data = new CompositeDataSupport(rowType, itemNames, itemValues); TabularType tabType = new TabularType(typeName, typeName, rowType, new String[]{"glop"}); TabularDataSupport tds = new TabularDataSupport(tabType); tds.put(data); System.out.println(msgTag +"Source CompositeData is " + data); mbsc.invoke(objName, "doWeird", new Object[]{data}, new String[]{"javax.management.openmbean.CompositeData"}); System.out.println(msgTag +"---- OK\n") ; // ---- System.out.println(msgTag +"Unregister the MBean"); mbsc.unregisterMBean(objName); System.out.println(msgTag +"---- OK\n") ; // Terminate the JMX Client cc.close(); } catch(Exception e) { Utils.printThrowable(e, true) ; errorCount++; throw new RuntimeException(e); } finally { System.exit(errorCount); } }