JMX编程实例:取得当前Weblogic Server的JDBCConnectionPool

类别:Java 点击:0 评论:0 推荐:
import java.util.*;
import javax.management.*;
import weblogic.management.*;

import weblogic.management.configuration.*;
import weblogic.management.runtime.ServerRuntimeMBean;
import weblogic.management.runtime.JDBCConnectionPoolRuntimeMBean;

public class TestJMX{

public MBeanHome localHome;

public MBeanHome adminHome ;
public Stack stack ;

public static String SERVER_NAME = "cgServer";

public Stack find() {

stack =  new Stack();

String url = "t3://127.0.0.1:7001" ;

try {

localHome = (MBeanHome)Helper.getMBeanHome("weblogic","weblogic",url,SERVER_NAME);

adminHome = (MBeanHome)Helper.getAdminMBeanHome("weblogic","weblogic",url);


Set set1 =adminHome.getMBeansByType("JDBCTxDataSource");
Set set2 =adminHome.getMBeansByType("JDBCDataSource");

Iterator it1 = set1.iterator();

while(it1.hasNext()){
JDBCTxDataSourceMBean dm1 = (JDBCTxDataSourceMBean)it1.next();
System.out.println("%%%%%%%%%%%"+dm1.getJNDIName());
stack.add(dm1.getJNDIName());
}
Iterator it2 = set2.iterator();

while(it2.hasNext()){
JDBCDataSourceMBean dm2 = (JDBCDataSourceMBean)it2.next();
System.out.println("%%%%%%%%%%%"+dm2.getJNDIName());
stack.add(dm2.getJNDIName());
}




} catch (IllegalArgumentException iae) {

System.out.println("Illegal Argument Exception: " + iae);

}
return stack;

}

public static void main(String[] args ) {

TestJMX test = new TestJMX();
test.find();
}

}

本文地址:http://com.8s8s.com/it/it15025.htm