O'Reilly logo

WebLogic: The Definitive Guide by Avinash Chugh, Jon Mountjoy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required