mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
jconsole
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@235 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
package com.alibaba.druid.jconsole;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
import javax.management.MBeanServerConnection;
|
||||
import javax.management.ObjectInstance;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.TabularData;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
|
||||
public class ConnectionsPanel extends JPanel {
|
||||
|
||||
@@ -12,11 +18,51 @@ public class ConnectionsPanel extends JPanel {
|
||||
private ObjectInstance objectInstance;
|
||||
private DataSourceInfo dataSourceInfo;
|
||||
|
||||
private JTable table;
|
||||
|
||||
private String[] columns = new String[] { "id", "connectTime", "connectTimespan", "establishTime", "aliveTimespan", "lastSql",
|
||||
"lastError", "lastErrorTime", "connectStatckTrace", "lastStatementStackTrace", "dataSource" };
|
||||
|
||||
public ConnectionsPanel(MBeanServerConnection connection, ObjectInstance objectInstance, DataSourceInfo dataSourceInfo){
|
||||
super();
|
||||
this.connection = connection;
|
||||
this.objectInstance = objectInstance;
|
||||
this.dataSourceInfo = dataSourceInfo;
|
||||
|
||||
try {
|
||||
TabularData connectionTabularData = (TabularData) connection.getAttribute(objectInstance.getObjectName(), "ConnectionList");
|
||||
|
||||
Object[][] rows = new Object[connectionTabularData.size()][];
|
||||
int rowIndex = 0;
|
||||
for (Object item : connectionTabularData.values()) {
|
||||
CompositeData rowData = (CompositeData) item;
|
||||
Object[] row = new Object[columns.length];
|
||||
row[0] = rowData.get("id");
|
||||
row[1] = rowData.get("connectTime");
|
||||
row[2] = rowData.get("connectTimespan");
|
||||
row[3] = rowData.get("establishTime");
|
||||
row[4] = rowData.get("aliveTimespan");
|
||||
|
||||
row[5] = rowData.get("lastSql");
|
||||
row[6] = rowData.get("lastError");
|
||||
row[7] = rowData.get("lastErrorTime");
|
||||
row[8] = rowData.get("connectStatckTrace");
|
||||
row[9] = rowData.get("lastStatementStackTrace");
|
||||
|
||||
row[10] = rowData.get("dataSource");
|
||||
|
||||
rows[rowIndex++] = row;
|
||||
}
|
||||
|
||||
table = new JTable(rows, columns);
|
||||
|
||||
JScrollPane tableScrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
this.setLayout(new BorderLayout());
|
||||
this.add(tableScrollPane, BorderLayout.CENTER);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public MBeanServerConnection getConnection() {
|
||||
|
||||
@@ -13,6 +13,7 @@ public class NodeInfo {
|
||||
|
||||
public NodeInfo(MBeanServerConnection connection, ObjectInstance objectInstance, NodeType type, Object data, String name){
|
||||
this.connection = connection;
|
||||
this.objectInstance = objectInstance;
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
this.name = name;
|
||||
|
||||
Reference in New Issue
Block a user