add jconsole plugin

This commit is contained in:
wenshao
2012-08-07 14:52:46 +08:00
parent f2aaa6add5
commit 6c20ff1122
7 changed files with 135 additions and 1 deletions
+44
View File
@@ -170,6 +170,50 @@
</plugins>
</build>
<profiles>
<profile>
<id>default-profile</id>
<activation>
<activeByDefault>true</activeByDefault>
<file>
<exists>${java.home}/../lib/jconsole.jar</exists>
</file>
</activation>
<properties>
<jconsolejar>${java.home}/../lib/jconsole.jar</jconsolejar>
</properties>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>jconsole</artifactId>
<version>1.6.0</version>
<scope>system</scope>
<systemPath>${jconsolejar}</systemPath>
<optional>true</optional>
</dependency>
</dependencies>
</profile>
<profile>
<id>mac-profile</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<exists>${java.home}/../Classes/jconsole.jar</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>jconsole</artifactId>
<version>1.6.0</version>
<scope>system</scope>
<systemPath>${java.home}/../Classes/jconsole.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
@@ -0,0 +1,7 @@
package com.alibaba.druid.support.jconsole;
public class DruidDataSourcePanel extends DruidPanel {
private static final long serialVersionUID = 1L;
}
@@ -0,0 +1,7 @@
package com.alibaba.druid.support.jconsole;
public class DruidDriverPanel extends DruidPanel {
private static final long serialVersionUID = 1L;
}
@@ -0,0 +1,21 @@
package com.alibaba.druid.support.jconsole;
import javax.management.MBeanServerConnection;
import javax.swing.JPanel;
import com.sun.tools.jconsole.JConsoleContext;
public class DruidPanel extends JPanel {
private static final long serialVersionUID = 1L;
protected Object doInBackground(JConsoleContext context) throws Exception {
doInBackground(context.getMBeanServerConnection());
return null;
}
protected void doInBackground(MBeanServerConnection conn) throws Exception {
System.out.println("doInBackground");
}
}
@@ -0,0 +1,47 @@
package com.alibaba.druid.support.jconsole;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.swing.JPanel;
import javax.swing.SwingWorker;
import com.sun.tools.jconsole.JConsolePlugin;
public class DruidPlugin extends JConsolePlugin {
private final Map<String, JPanel> tabs = new LinkedHashMap<String, JPanel>();
public DruidPlugin(){
tabs.put("Druid-Driver", new DruidDriverPanel());
tabs.put("Druid-DataSource", new DruidDataSourcePanel());
tabs.put("Druid-SQL", new DruidSQLPanel());
}
@Override
public Map<String, JPanel> getTabs() {
return tabs;
}
@Override
public SwingWorker<?, ?> newSwingWorker() {
SwingWorker<?, ?> worer = new SwingWorker<Object, Object>() {
@Override
protected Object doInBackground() throws Exception {
return DruidPlugin.this.doInBackground();
}
};
return worer;
}
protected Object doInBackground() throws Exception {
for (JPanel panel : tabs.values()) {
((DruidPanel) panel).doInBackground(this.getContext());
}
return null;
}
}
@@ -0,0 +1,8 @@
package com.alibaba.druid.support.jconsole;
public class DruidSQLPanel extends DruidPanel {
private static final long serialVersionUID = 1L;
}
@@ -1 +1 @@
com.alibaba.druid.jconsole.DruidPlugin
com.alibaba.druid.support.jconsole.DruidPlugin