Accessing MBeans

Once you obtain a home interface, there are several ways to access the underlying MBean Server. The first approach is to use the MBeanHome interface to retrieve an instance of javax.management.MBeanServer, the standard JMX interface for interacting with an MBean Server. It provides a generic way for accessing the attributes and invoking the operations exposed by an MBean. The onus is on you to supply the correct number of parameters, of the correct type, when you use an MBeanServer instance to issue method calls to an MBean.

The second approach is to use a proprietary type-safe interface, which is implemented as a wrapper around the MBeanServer interface. At the cost of portability, you gain very simplified and compact access to MBeans and their attributes and operations. WebLogic’s Administration Tool provides another nonprogrammatic approach to accessing MBeans. In addition, the new WLShell tool provides a shell environment for accessing and manipulating MBeans on a particular WebLogic instance.

Naming of MBeans

Before you can use the MBeanServer interface to locate MBeans, you need to understand how WebLogic names its MBeans. Each MBean hosted by an MBean Server is uniquely named, and every MBean name is constructed using an instance of the JMX ObjectName class. WebLogic uses instances of the WebLogicObjectName class, which extends ObjectName to carry additional information. When printed, the name of an MBean follows this format:

domain:Name=name,Type=type[,Location=servername][,attr=value]* ...

Get WebLogic: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.