-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
beginning of GUI redesign; JMX client stub for eventual stream input …
…from JMX beans
- Loading branch information
Showing
6 changed files
with
244 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,15 @@ | |
package moa.gui; | ||
|
||
import java.awt.BorderLayout; | ||
import javax.swing.JPanel; | ||
|
||
/** | ||
* This panel allows the user to select and configure a task, and run it. | ||
* | ||
* @author Richard Kirkby ([email protected]) | ||
* @version $Revision: 7 $ | ||
*/ | ||
public class ClassificationTabPanel extends AbstractTabPanel { | ||
public class ClassificationTabPanel extends AbstractTabPanel implements GUI.OptionPanelAware { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
|
@@ -43,6 +44,10 @@ public ClassificationTabPanel() { | |
add(this.taskManagerPanel, BorderLayout.NORTH); | ||
add(this.previewPanel, BorderLayout.CENTER); | ||
} | ||
@Override | ||
public void setOptionsPanel(JPanel p) { | ||
taskManagerPanel.setOptionsPanel(p); | ||
} | ||
|
||
//returns the string to display as title of the tab | ||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package moa.gui; | ||
|
||
/** | ||
* FROM: https://web-gmazza.rhcloud.com/blog/entry/creating-jconsole-alternative | ||
* @author me | ||
*/ | ||
|
||
|
||
|
||
import javax.management.MBeanServerConnection; | ||
import javax.management.ObjectName; | ||
import javax.management.remote.JMXConnector; | ||
import javax.management.remote.JMXConnectorFactory; | ||
import javax.management.remote.JMXServiceURL; | ||
import java.io.IOException; | ||
import java.lang.management.ManagementFactory; | ||
import java.lang.management.MemoryMXBean; | ||
import java.lang.management.MemoryPoolMXBean; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
import javax.management.AttributeChangeNotification; | ||
import javax.management.Notification; | ||
import javax.management.NotificationListener; | ||
import javax.management.ObjectInstance; | ||
|
||
public class JMXClient { | ||
|
||
/** | ||
* Inner class that will handle the notifications. | ||
*/ | ||
public static class ClientListener implements NotificationListener { | ||
public void handleNotification(Notification notification, | ||
Object handback) { | ||
echo("\nReceived notification:"); | ||
echo("\tClassName: " + notification.getClass().getName()); | ||
echo("\tSource: " + notification.getSource()); | ||
echo("\tType: " + notification.getType()); | ||
echo("\tMessage: " + notification.getMessage()); | ||
if (notification instanceof AttributeChangeNotification) { | ||
AttributeChangeNotification acn = | ||
(AttributeChangeNotification) notification; | ||
echo("\tAttributeName: " + acn.getAttributeName()); | ||
echo("\tAttributeType: " + acn.getAttributeType()); | ||
echo("\tNewValue: " + acn.getNewValue()); | ||
echo("\tOldValue: " + acn.getOldValue()); | ||
} | ||
} | ||
} | ||
|
||
/* For simplicity, we declare "throws Exception". | ||
Real programs will usually want finer-grained exception handling. */ | ||
public static void main(String[] args) throws Exception { | ||
|
||
|
||
// Create an RMI connector client and | ||
// connect it to the RMI connector server | ||
// | ||
echo("\nCreate an RMI connector client and " + | ||
"connect it to the RMI connector server"); | ||
JMXServiceURL url = | ||
new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:1617/jmxrmi"); | ||
JMXConnector jmxc = JMXConnectorFactory.connect(url, null); | ||
|
||
// Create listener | ||
// | ||
ClientListener listener = new ClientListener(); | ||
|
||
// Get an MBeanServerConnection | ||
// | ||
echo("\nGet an MBeanServerConnection"); | ||
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); | ||
waitForEnterPressed(); | ||
|
||
// Get domains from MBeanServer | ||
// | ||
echo("\nDomains:"); | ||
String domains[] = mbsc.getDomains(); | ||
Arrays.sort(domains); | ||
for (String domain : domains) { | ||
echo("\tDomain = " + domain); | ||
} | ||
waitForEnterPressed(); | ||
|
||
// Get MBeanServer's default domain | ||
// | ||
echo("\nMBeanServer default domain = " + mbsc.getDefaultDomain()); | ||
|
||
// Get MBean count | ||
// | ||
echo("\nMBean count = " + mbsc.getMBeanCount()); | ||
|
||
// Query MBean names | ||
// | ||
echo("\nQuery MBeanServer MBeans:"); | ||
Set<ObjectName> names = | ||
new TreeSet<ObjectName>(mbsc.queryNames(null, null)); | ||
for (ObjectName name : names) { | ||
echo("\tObjectName = " + name); | ||
} | ||
waitForEnterPressed(); | ||
|
||
// ---------------------- | ||
// Manage the Hello MBean | ||
// ---------------------- | ||
|
||
echo("\n>>> Perform operations on Hello MBean <<<"); | ||
|
||
// Construct the ObjectName for the Hello MBean | ||
// | ||
ObjectName mbeanName = new ObjectName("com.example:type=Hello"); | ||
|
||
// Create a dedicated proxy for the MBean instead of | ||
// going directly through the MBean server connection | ||
// | ||
//HelloMBean mbeanProxy = | ||
// JMX.newMBeanProxy(mbsc, mbeanName, HelloMBean.class, true); | ||
|
||
// Add notification listener on Hello MBean | ||
// | ||
echo("\nAdd notification listener..."); | ||
mbsc.addNotificationListener(mbeanName, listener, null, null); | ||
|
||
|
||
waitForEnterPressed(); | ||
|
||
// Close MBeanServer connection | ||
// | ||
echo("\nClose the connection to the server"); | ||
jmxc.close(); | ||
echo("\nBye! Bye!"); | ||
} | ||
|
||
private static void echo(String msg) { | ||
System.out.println(msg); | ||
} | ||
|
||
private static void sleep(int millis) { | ||
try { | ||
Thread.sleep(millis); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
private static void waitForEnterPressed() { | ||
try { | ||
echo("\nPress <Enter> to continue..."); | ||
System.in.read(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.