mx4j.util

Class StandardMBeanProxy

Known Direct Subclasses:
RemoteStandardMBeanProxy

public class StandardMBeanProxy
extends java.lang.Object

A utility class that creates proxies for invocation on standard MBeans (does not work for DynamicMBeans) on local MBeanServers.
Usage example:
 public interface MyServiceMBean {...}
 public class MyService implements MyServiceMBean {...}
 pulic class Main
 {
    public static void main(String[] args) throws Exception
    {
       MBeanServer server = ...;
       ObjectName myServiceObjectName = ...;
 

MyServiceMBean mbean = (MyServiceMBean)StandardMBeanProxy.create(MyServiceMBean.class, server, myServiceObjectName);

... } }

Version:
$Revision: 1.10 $

Nested Class Summary

protected static class
StandardMBeanProxy.Handler
Base class for MBeanServer invocation handlers.

Method Summary

static Object
create(Class mbeanInterface, javax.management.MBeanServer server, javax.management.ObjectName name)
Creates a proxy with the given MBean interface for an MBean with the specified ObjectName living in the specified local MBeanServer.
static Object
create(Class mbeanInterface, javax.management.ObjectName name)
Deprecated. Replaced by create(Class mbeanInterface, MBeanServer server, ObjectName name)

Method Details

create

public static Object create(Class mbeanInterface,
                            javax.management.MBeanServer server,
                            javax.management.ObjectName name)
Creates a proxy with the given MBean interface for an MBean with the specified ObjectName living in the specified local MBeanServer.
Calling this method when the given ObjectName does not represent a registered MBean in the given MBeanServer results in an exception being thrown. If the MBean is unregistered after the proxy has been created, an attempt to call any method on the proxy will result in a UndeclaredThrowableException being thrown. MBeanServer's behavior would be to throw an InstanceNotFoundException, but this exception is normally not declared in the throws clause of MBean's management interface, thus resulting in the UndeclaredThrowableException being thrown instead.


create

public static Object create(Class mbeanInterface,
                            javax.management.ObjectName name)

Deprecated. Replaced by create(Class mbeanInterface, MBeanServer server, ObjectName name)

Creates a proxy with the given MBean interface for an MBean with the specified name living in the MBeanServer returned by MBeanServerFactory.findMBeanServer(null).get(0).


Copyright © 2001-2003 MX4J Team. All Rights Reserved.