Examples

WebLogic contains hundreds of MBeans. The following sections cover examples of some of the Runtime, Configuration, and Security MBeans and examines common ways of manipulating these MBeans. Other MBeans provided by WebLogic may be manipulated similarly.

Runtime MBeans

A prime example of a Runtime MBean is the ServerRuntimeMBean, which provides information on the operational status of a server and other details such as its listen address and port. The following code uses WebLogic’s type-safe approach to connect to a Managed Server, print out its listen address and port, and then shut it down:

serverRuntime = (ServerRuntimeMBean) 
      localHomeB.getRuntimeMBean("ServerB", "ServerRuntime");
System.out.println("Listens on " +
      serverRuntime.getListenAddress( )+":"+serverRuntime.getListenPort( ));
serverRuntime.shutdown( );

You can do the same thing using the weblogic.Admin tool:

java weblogic.Admin -url http://serverb.x:7001 -username system -password pssst
  INVOKE -mbean "myClusterDomain:Location=ServerB,Name=ServerB,Type=ServerRuntime" 
  -method shutdown

The ServerRuntimeMBean will exist on the Local Home of each server instance. To find all of the server runtimes, we will have to contact the Administration Server:

Set mbeanSet = adminHome.getMBeansByType("ServerRuntime"); Iterator mbeanIterator = mbeanSet.iterator( ); while (mbeanIterator.hasNext( )) { ServerRuntimeMBean serverRuntime = (ServerRuntimeMBean)mbeanIterator.next( ); System.err.println("Found server: " + serverRuntime.getName( ...

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.