Accessing MBean Servers

Now that you know how WebLogic organizes MBeans across MBean Servers, we can turn to accessing MBean Servers. The first point of entry is to find a home interface for the MBean Server. The home interface provides access to the underlying MBean server and enables you to reach the MBeans hosted on the server.

20.2.1 Local and Administration Home Interfaces

The MBean Server running on a WebLogic Server instance can be reached through the interface. Two implementations of this home interface can be obtained:

Local Home interface

This interface provides access to the local MBeans hosted on the MBean Server itself. This means that you can use the Local Home interface to access the Local Configuration and Runtime MBeans on that server instance, but not interact with any of the Administration MBeans.

Administration Home interface

This interface, exposed only by the Administration Server, provides access to the Administration MBeans and all other MBeans on all other server instances within the domain.

Figure 20-2 illustrates this architecture.

Figure 20-2. Home interfaces and their hosted MBeans


As indicated in Figure 20-2, you also can reach the Runtime MBeans on any Managed Server through the Administration Home interface itself, instead of using the Local Home interface of the Managed Server directly. Clearly, it is slower to access the local MBeans through the Administration interface rather than to access them directly through the Local interface. You incur an additional performance penalty due to the overhead imposed by the RMI communication with the local server MBeans. If you need to manipulate the local MBeans of a particular Managed Server, you should contact that server directly through its Local Home interface.

20.2.2 Retrieving the Home Interface

The home interfaces can be retrieved either by looking up the server's JNDI tree or by using a WebLogic-specific helper class. In both cases, you need to supply the authentication details of a user who is authorized to access the domain resource and the URL of the server that you wish to contact. If you intend to access a local home, you also need the name of the server that you would like to contact.

Use the getMBeanHome( ) method on the class to access the Local MBean home, and use the getAdminMBeanHome( ) method on the Helper class to access the Administration MBean home. The following code sample shows how to use these helper methods to retrieve the Local and Administration home interfaces:

public MBeanHome findLocalHomeHelper(String url, String serverName) { localHome = null;
 localHome = 
 (MBeanHome) Helper.getMBeanHome(USERNAME, PASSWORD, url, serverName);
 return localHome;

public MBeanHome findAdminHomeHelper(String adminURL) { adminHome = null;
 adminHome = 
 (MBeanHome) Helper.getAdminMBeanHome(USERNAME, PASSWORD, adminURL);
 return adminHome;

Now, if you need to access the Local home of ServerB, you need to simply issue the following call:

MBeanHome localHomeB = findLocalHomeHelper("t3://", "ServerB");

Using the JNDI to obtain a home is just as easy. The locations of the Local and Administration homes are stored in the constants MBeanHome.LOCAL_JNDI_NAME and MBeanHome.ADMIN_JNDI_NAME, respectively. Once you establish an initial context with a server, you simply look up the home interface using these names:

InitialContext ctx = new InitialContext( );
MBeanHome localHomeB = (MBeanHome) ctx.lookup(MBeanHome.LOCAL_JNDI_NAME);

An initial JNDI context obtained from the Administration Server also allows you to access the Local home from any of the Managed Servers. In this case, the JNDI name used to look up the Local home matches the following string:

 "" + "." + ServerName

This prefix is conveniently bound to the constant MBeanHome.JNDI_NAME. The following code sample shows how to locate the Local Home interface of ServerB via the initial JNDI context obtained from the Administration Server:

//create an initial JNDI context using the URL of the Admin Server
Hashtable env = new Hashtable( );
env.put(Context.PROVIDER_URL, "t3://adminserver:8001");
//set other environment properties for the initial JNDI Context
InitialContext ctx = new InitialContext(env);
//now look up Local home by prefixing MBeanHome.JNDI_NAME to "ServerB"
MBeanHome localHomeB = (MBeanHome) ctx.lookup(MBeanHome.JNDI_NAME + "." + "ServerB");


Web Applications

Managing the Web Server

Using JNDI and RMI



J2EE Connectors



Using EJBs

Using CMP and EJB QL

Packaging and Deployment

Managing Domains


Performance, Monitoring, and Tuning




Web Services


Logging and Internationalization


show all menu

WebLogic. The Definitive Guide
WebLogic: The Definitive Guide
ISBN: 059600432X
EAN: 2147483647
Year: 2003
Pages: 187
Similar book on Amazon © 2008-2017.
If you may any questions please contact us: