javax.management.StandardMBean Java Examples

The following examples show how to use javax.management.StandardMBean. 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: ServerDelegate.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #2
Source File: TooManyFooTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    final Child child = new Child();
    test(child,"Child[MBean]",false);
    final ChildMix childx = new ChildMix();
    test(childx,"ChildMix[MXBean]",true);
    final ChildMixMix childmx = new ChildMixMix();
    test(childmx,"ChildMixMix[MXBean]",false);
    final StandardMBean schild = new StandardMBean(child,ChildMBean.class);
    test(schild,"Child[StandarMBean(Child)]",false);
    final StandardMBean schildx =
            new StandardMBean(childx,ChildMXBean.class,true);
    test(schildx,"ChildMix[StandarMXBean(ChildMix)]",true);
    final StandardMBean schildmx =
            new StandardMBean(childmx,ChildMixMXBean.class,true);
    test(schildmx,"ChildMixMix[StandarMXBean(ChildMixMix)]",true);
}
 
Example #3
Source File: TooManyFooTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    final Child child = new Child();
    test(child,"Child[MBean]",false);
    final ChildMix childx = new ChildMix();
    test(childx,"ChildMix[MXBean]",true);
    final ChildMixMix childmx = new ChildMixMix();
    test(childmx,"ChildMixMix[MXBean]",false);
    final StandardMBean schild = new StandardMBean(child,ChildMBean.class);
    test(schild,"Child[StandarMBean(Child)]",false);
    final StandardMBean schildx =
            new StandardMBean(childx,ChildMXBean.class,true);
    test(schildx,"ChildMix[StandarMXBean(ChildMix)]",true);
    final StandardMBean schildmx =
            new StandardMBean(childmx,ChildMixMXBean.class,true);
    test(schildmx,"ChildMixMix[StandarMXBean(ChildMixMix)]",true);
}
 
Example #4
Source File: TooManyFooTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    final Child child = new Child();
    test(child,"Child[MBean]",false);
    final ChildMix childx = new ChildMix();
    test(childx,"ChildMix[MXBean]",true);
    final ChildMixMix childmx = new ChildMixMix();
    test(childmx,"ChildMixMix[MXBean]",false);
    final StandardMBean schild = new StandardMBean(child,ChildMBean.class);
    test(schild,"Child[StandarMBean(Child)]",false);
    final StandardMBean schildx =
            new StandardMBean(childx,ChildMXBean.class,true);
    test(schildx,"ChildMix[StandarMXBean(ChildMix)]",true);
    final StandardMBean schildmx =
            new StandardMBean(childmx,ChildMixMXBean.class,true);
    test(schildmx,"ChildMixMix[StandarMXBean(ChildMixMix)]",true);
}
 
Example #5
Source File: ServerDelegate.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #6
Source File: ServerDelegate.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #7
Source File: TestJMX.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void registerAndVerifyMBean(MBeanServer mbs) {
    try {
        ObjectName myInfoObj = new ObjectName("com.alibaba.tenant.mxbean:type=MyTest");
        MXBeanImpl myMXBean = new MXBeanImpl();
        StandardMBean smb = new StandardMBean(myMXBean, MXBean.class);
        mbs.registerMBean(smb, myInfoObj);

        assertTrue(mbs.isRegistered(myInfoObj));

        //call the method of MXBean
        MXBean mbean =
                (MXBean)MBeanServerInvocationHandler.newProxyInstance(
                     mbs,new ObjectName("com.alibaba.tenant.mxbean:type=MyTest"), MXBean.class, true);
        assertTrue("test".equals(mbean.getName()));

        Set<ObjectInstance> instances = mbs.queryMBeans(new ObjectName("com.alibaba.tenant.mxbean:type=MyTest"), null);
        ObjectInstance instance = (ObjectInstance) instances.toArray()[0];
        assertTrue(myMXBean.getClass().getName().equals(instance.getClassName()));

        MBeanInfo info = mbs.getMBeanInfo(myInfoObj);
        assertTrue(myMXBean.getClass().getName().equals(info.getClassName()));
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
 
Example #8
Source File: MBeanExporter.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Build an adapted MBean for the given bean instance, if possible.
 * <p>The default implementation builds a JMX 1.2 StandardMBean
 * for the target's MBean/MXBean interface in case of an AOP proxy,
 * delegating the interface's management operations to the proxy.
 * @param bean the original bean instance
 * @return the adapted MBean, or {@code null} if not possible
 */
@SuppressWarnings("unchecked")
protected DynamicMBean adaptMBeanIfPossible(Object bean) throws JMException {
	Class<?> targetClass = AopUtils.getTargetClass(bean);
	if (targetClass != bean.getClass()) {
		Class<?> ifc = JmxUtils.getMXBeanInterface(targetClass);
		if (ifc != null) {
			if (!ifc.isInstance(bean)) {
				throw new NotCompliantMBeanException("Managed bean [" + bean +
						"] has a target class with an MXBean interface but does not expose it in the proxy");
			}
			return new StandardMBean(bean, ((Class<Object>) ifc), true);
		}
		else {
			ifc = JmxUtils.getMBeanInterface(targetClass);
			if (ifc != null) {
				if (!ifc.isInstance(bean)) {
					throw new NotCompliantMBeanException("Managed bean [" + bean +
							"] has a target class with an MBean interface but does not expose it in the proxy");
				}
				return new StandardMBean(bean, ((Class<Object>) ifc));
			}
		}
	}
	return null;
}
 
Example #9
Source File: TooManyFooTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    final Child child = new Child();
    test(child,"Child[MBean]",false);
    final ChildMix childx = new ChildMix();
    test(childx,"ChildMix[MXBean]",true);
    final ChildMixMix childmx = new ChildMixMix();
    test(childmx,"ChildMixMix[MXBean]",false);
    final StandardMBean schild = new StandardMBean(child,ChildMBean.class);
    test(schild,"Child[StandarMBean(Child)]",false);
    final StandardMBean schildx =
            new StandardMBean(childx,ChildMXBean.class,true);
    test(schildx,"ChildMix[StandarMXBean(ChildMix)]",true);
    final StandardMBean schildmx =
            new StandardMBean(childmx,ChildMixMXBean.class,true);
    test(schildmx,"ChildMixMix[StandarMXBean(ChildMixMix)]",true);
}
 
Example #10
Source File: ServerDelegate.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #11
Source File: ServerDelegate.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #12
Source File: JMXManagementService.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Start the management service if gemfirexd.system.jmx is true.
 * <P>
 * Starting the service means:
 * <UL>
 * <LI> getting the platform MBeanServer which may require starting it
 * <LI> registering a Version mbean representing the system
 * </UL>
 */
public synchronized void boot(boolean create, Properties properties)
        throws StandardException {
    
    registeredMbeans = new HashMap<ObjectName,StandardMBean>();
    
    systemIdentifier =
        Monitor.getMonitor().getUUIDFactory().createUUID().toString();
    
    findServer();
         
    myManagementBean = (ObjectName) registerMBean(this,
            ManagementMBean.class,
            "type=Management");
    myManagementServer = mbeanServer;
    
    registerMBean(
            new Version(
                    Monitor.getMonitor().getEngineVersion(),
                    SystemPermission.ENGINE),
            VersionMBean.class,
            "type=Version,jar=gemfirexd.jar");
}
 
Example #13
Source File: ServerDelegate.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #14
Source File: TooManyFooTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    final Child child = new Child();
    test(child,"Child[MBean]",false);
    final ChildMix childx = new ChildMix();
    test(childx,"ChildMix[MXBean]",true);
    final ChildMixMix childmx = new ChildMixMix();
    test(childmx,"ChildMixMix[MXBean]",false);
    final StandardMBean schild = new StandardMBean(child,ChildMBean.class);
    test(schild,"Child[StandarMBean(Child)]",false);
    final StandardMBean schildx =
            new StandardMBean(childx,ChildMXBean.class,true);
    test(schildx,"ChildMix[StandarMXBean(ChildMix)]",true);
    final StandardMBean schildmx =
            new StandardMBean(childmx,ChildMixMXBean.class,true);
    test(schildmx,"ChildMixMix[StandarMXBean(ChildMixMix)]",true);
}
 
Example #15
Source File: TooManyFooTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    final Child child = new Child();
    test(child,"Child[MBean]",false);
    final ChildMix childx = new ChildMix();
    test(childx,"ChildMix[MXBean]",true);
    final ChildMixMix childmx = new ChildMixMix();
    test(childmx,"ChildMixMix[MXBean]",false);
    final StandardMBean schild = new StandardMBean(child,ChildMBean.class);
    test(schild,"Child[StandarMBean(Child)]",false);
    final StandardMBean schildx =
            new StandardMBean(childx,ChildMXBean.class,true);
    test(schildx,"ChildMix[StandarMXBean(ChildMix)]",true);
    final StandardMBean schildmx =
            new StandardMBean(childmx,ChildMixMXBean.class,true);
    test(schildmx,"ChildMixMix[StandarMXBean(ChildMixMix)]",true);
}
 
Example #16
Source File: TooManyFooTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    final Child child = new Child();
    test(child,"Child[MBean]",false);
    final ChildMix childx = new ChildMix();
    test(childx,"ChildMix[MXBean]",true);
    final ChildMixMix childmx = new ChildMixMix();
    test(childmx,"ChildMixMix[MXBean]",false);
    final StandardMBean schild = new StandardMBean(child,ChildMBean.class);
    test(schild,"Child[StandarMBean(Child)]",false);
    final StandardMBean schildx =
            new StandardMBean(childx,ChildMXBean.class,true);
    test(schildx,"ChildMix[StandarMXBean(ChildMix)]",true);
    final StandardMBean schildmx =
            new StandardMBean(childmx,ChildMixMXBean.class,true);
    test(schildmx,"ChildMixMix[StandarMXBean(ChildMixMix)]",true);
}
 
Example #17
Source File: ServerDelegate.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #18
Source File: JMXManagementService.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Start the management service if gemfirexd.system.jmx is true.
 * <P>
 * Starting the service means:
 * <UL>
 * <LI> getting the platform MBeanServer which may require starting it
 * <LI> registering a Version mbean representing the system
 * </UL>
 */
public synchronized void boot(boolean create, Properties properties)
        throws StandardException {
    
    registeredMbeans = new HashMap<ObjectName,StandardMBean>();
    
    systemIdentifier =
        Monitor.getMonitor().getUUIDFactory().createUUID().toString();
    
    findServer();
         
    myManagementBean = (ObjectName) registerMBean(this,
            ManagementMBean.class,
            "type=Management");
    myManagementServer = mbeanServer;
    
    registerMBean(
            new Version(
                    Monitor.getMonitor().getEngineVersion(),
                    SystemPermission.ENGINE),
            VersionMBean.class,
            "type=Version,jar=gemfirexd.jar");
}
 
Example #19
Source File: TooManyFooTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    final Child child = new Child();
    test(child,"Child[MBean]",false);
    final ChildMix childx = new ChildMix();
    test(childx,"ChildMix[MXBean]",true);
    final ChildMixMix childmx = new ChildMixMix();
    test(childmx,"ChildMixMix[MXBean]",false);
    final StandardMBean schild = new StandardMBean(child,ChildMBean.class);
    test(schild,"Child[StandarMBean(Child)]",false);
    final StandardMBean schildx =
            new StandardMBean(childx,ChildMXBean.class,true);
    test(schildx,"ChildMix[StandarMXBean(ChildMix)]",true);
    final StandardMBean schildmx =
            new StandardMBean(childmx,ChildMixMXBean.class,true);
    test(schildmx,"ChildMixMix[StandarMXBean(ChildMixMix)]",true);
}
 
Example #20
Source File: ServerDelegate.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #21
Source File: SamplesOutputStream.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Object[] toCompositeData(final List<ThreadInfo> threadInfos) {
    CompositeDataGetter getter = new CompositeDataGetter() {
        @Override
        public ThreadInfo[] getThreads() {
            return threadInfos.toArray(new ThreadInfo[0]);
        }
    };
    try {
        StandardMBean getterBean = new StandardMBean(getter,
                                                     CompositeDataGetter.class,
                                                     true);
        return (Object[]) getterBean.getAttribute("Threads");
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
        return new Object[0];
    }
}
 
Example #22
Source File: MBeanExporter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Build an adapted MBean for the given bean instance, if possible.
 * <p>The default implementation builds a JMX 1.2 StandardMBean
 * for the target's MBean/MXBean interface in case of an AOP proxy,
 * delegating the interface's management operations to the proxy.
 * @param bean the original bean instance
 * @return the adapted MBean, or {@code null} if not possible
 */
@SuppressWarnings("unchecked")
protected DynamicMBean adaptMBeanIfPossible(Object bean) throws JMException {
	Class<?> targetClass = AopUtils.getTargetClass(bean);
	if (targetClass != bean.getClass()) {
		Class<?> ifc = JmxUtils.getMXBeanInterface(targetClass);
		if (ifc != null) {
			if (!ifc.isInstance(bean)) {
				throw new NotCompliantMBeanException("Managed bean [" + bean +
						"] has a target class with an MXBean interface but does not expose it in the proxy");
			}
			return new StandardMBean(bean, ((Class<Object>) ifc), true);
		}
		else {
			ifc = JmxUtils.getMBeanInterface(targetClass);
			if (ifc != null) {
				if (!ifc.isInstance(bean)) {
					throw new NotCompliantMBeanException("Managed bean [" + bean +
							"] has a target class with an MBean interface but does not expose it in the proxy");
				}
				return new StandardMBean(bean, ((Class<Object>) ifc));
			}
		}
	}
	return null;
}
 
Example #23
Source File: ServerDelegate.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #24
Source File: ServerDelegate.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #25
Source File: ServerDelegate.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #26
Source File: TooManyFooTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    final Child child = new Child();
    test(child,"Child[MBean]",false);
    final ChildMix childx = new ChildMix();
    test(childx,"ChildMix[MXBean]",true);
    final ChildMixMix childmx = new ChildMixMix();
    test(childmx,"ChildMixMix[MXBean]",false);
    final StandardMBean schild = new StandardMBean(child,ChildMBean.class);
    test(schild,"Child[StandarMBean(Child)]",false);
    final StandardMBean schildx =
            new StandardMBean(childx,ChildMXBean.class,true);
    test(schildx,"ChildMix[StandarMXBean(ChildMix)]",true);
    final StandardMBean schildmx =
            new StandardMBean(childmx,ChildMixMXBean.class,true);
    test(schildmx,"ChildMixMix[StandarMXBean(ChildMixMix)]",true);
}
 
Example #27
Source File: ServerDelegate.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #28
Source File: ServerDelegate.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiates and registers a StandardMBean in the MBean server.
 *
 * @param implementationClassName
 *      The implementation class name of the MBean.
 * @param interfaceClassName
 *      The management interface class name of the MBean.
 * @param isMXBean
 *      If true, the resultant MBean is an MXBean.
 * @param name
 *      The object name of the StandardMBean.
 */
@SuppressWarnings("unchecked")
public void createStandardMBean(
        String implementationClassName,
        String interfaceClassName,
        boolean isMXBean,
        ObjectName name)
        throws Exception {

    Object implementation =
            Class.forName(implementationClassName).newInstance();
    Class<Object> interfaceClass = interfaceClassName == null ? null :
        (Class<Object>)Class.forName(interfaceClassName);

    // Create the StandardMBean
    StandardMBean standardMBean = new StandardMBean(
            implementation,
            interfaceClass,
            isMXBean);

    // Register the StandardMBean
    mbeanServer.registerMBean(standardMBean, name);
}
 
Example #29
Source File: TooManyFooTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    final Child child = new Child();
    test(child,"Child[MBean]",false);
    final ChildMix childx = new ChildMix();
    test(childx,"ChildMix[MXBean]",true);
    final ChildMixMix childmx = new ChildMixMix();
    test(childmx,"ChildMixMix[MXBean]",false);
    final StandardMBean schild = new StandardMBean(child,ChildMBean.class);
    test(schild,"Child[StandarMBean(Child)]",false);
    final StandardMBean schildx =
            new StandardMBean(childx,ChildMXBean.class,true);
    test(schildx,"ChildMix[StandarMXBean(ChildMix)]",true);
    final StandardMBean schildmx =
            new StandardMBean(childmx,ChildMixMXBean.class,true);
    test(schildmx,"ChildMixMix[StandarMXBean(ChildMixMix)]",true);
}
 
Example #30
Source File: TooManyFooTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    final Child child = new Child();
    test(child,"Child[MBean]",false);
    final ChildMix childx = new ChildMix();
    test(childx,"ChildMix[MXBean]",true);
    final ChildMixMix childmx = new ChildMixMix();
    test(childmx,"ChildMixMix[MXBean]",false);
    final StandardMBean schild = new StandardMBean(child,ChildMBean.class);
    test(schild,"Child[StandarMBean(Child)]",false);
    final StandardMBean schildx =
            new StandardMBean(childx,ChildMXBean.class,true);
    test(schildx,"ChildMix[StandarMXBean(ChildMix)]",true);
    final StandardMBean schildmx =
            new StandardMBean(childmx,ChildMixMXBean.class,true);
    test(schildmx,"ChildMixMix[StandarMXBean(ChildMixMix)]",true);
}