编程语言

img aaronsi

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

发表于2004/10/1 9:20:00  1013人阅读

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();
}

}
阅读全文
0 0

相关文章推荐

img
取 消
img