You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ge...@apache.org on 2006/08/30 17:03:03 UTC
svn commit: r438510 [3/5] - in
/incubator/harmony/enhanced/tools/trunk/jmx_console: ./ doc/ doc/Images/
make/ src/ src/icons/ src/org/ src/org/apache/ src/org/apache/harmony/
src/org/apache/harmony/x/ src/org/apache/harmony/x/management/
src/org/apache...
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/controller/VMMonitor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/controller/VMMonitor.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/controller/VMMonitor.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/controller/VMMonitor.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,1010 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Sergey A. Krivenko
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.management.console.controller;
+
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.management.Attribute;
+import javax.management.MBeanServerConnection;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.TabularDataSupport;
+
+
+/**
+ * Prepare the data collected by the implementation of java.lang.management.*
+ * package to be shown in GUI.
+ *
+ * @author Sergey A. Krivenko
+ * @version $Revision: 1.3 $
+ */
+public class VMMonitor {
+
+ /**
+ * A reference to MBeanServer where platform MXBeans are registered.
+ */
+ private MBeanServerConnection con = null;
+
+ /**
+ * Construct the object.
+ *
+ * @param con - A reference to MBeanServer where platform MXBeans
+ * are registered.
+ */
+ public VMMonitor(MBeanServerConnection con)
+ throws ServiceNotInstalledException {
+
+ this.con = con;
+ checkMXMBeans();
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public long[] findMonitorDeadlockedThreads()
+ throws ControllerOperationException {
+
+ try {
+ return (long[]) con.invoke(
+ new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME),
+ "findMonitorDeadlockedThreads", null, null);
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public long[] getAllThreadIds() throws ControllerOperationException {
+ try {
+ return (long[]) con.getAttribute(
+ new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME),
+ "AllThreadIds");
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public String[] getBootClassPath() throws ControllerOperationException {
+ try {
+ String cp = (String) con.getAttribute(
+ new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME),
+ "BootClassPath");
+ StringTokenizer st = new StringTokenizer(cp, ";");
+ String[] tokens = new String[st.countTokens()];
+ int i = 0;
+
+ while (st.hasMoreTokens()) {
+ tokens[i] = st.nextToken();
+ i++;
+ }
+
+ return tokens;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Hashtable getClassLoadingInfo() throws ControllerOperationException {
+ try {
+ ObjectName on =
+ new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME);
+ Hashtable table = new Hashtable(4);
+ table.put("Number of classes loaded",
+ con.getAttribute(on, "LoadedClassCount"));
+ table.put("Number of total classes loaded",
+ con.getAttribute(on, "TotalLoadedClassCount"));
+ table.put("Number of unloaded classes",
+ con.getAttribute(on, "UnloadedClassCount"));
+ table.put("Verbose", con.getAttribute(on, "Verbose"));
+ return table;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param on
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Collection getCollectionUsage(ObjectName on)
+ throws ControllerOperationException {
+
+ try {
+ return ((CompositeDataSupport) con.getAttribute(
+ on, "CollectionUsage")).values();
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Hashtable getCompilationInfo() throws ControllerOperationException {
+ try {
+ ObjectName on =
+ new ObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME);
+ Hashtable table = new Hashtable(3);
+ table.put("Name", con.getAttribute(on, "Name"));
+ table.put("Total compilation time",
+ con.getAttribute(on, "TotalCompilationTime"));
+ table.put("Compilation time monitoring supported",
+ con.getAttribute(on, "CompilationTimeMonitoringSupported"));
+ return table;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param on
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Hashtable getGarbageCollectorInfo(ObjectName on)
+ throws ControllerOperationException {
+
+ try {
+ Hashtable table = new Hashtable(2);
+ table.put("Number of collections",
+ con.getAttribute(on, "CollectionCount"));
+ table.put("Collection time", con.getAttribute(on, "CollectionTime"));
+ return table;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Set getGarbageCollectorMBeans() throws ControllerOperationException {
+ try {
+ ObjectName on = new ObjectName(
+ ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
+ return (Set) con.queryNames(on, null);
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Collection getHeapMemoryUsage() throws ControllerOperationException {
+ try {
+
+ CompositeDataSupport hmu = (CompositeDataSupport) con.getAttribute(
+ new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME),
+ "HeapMemoryUsage");
+ return hmu.values();
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public String[] getInputArguments() throws ControllerOperationException {
+ try {
+ return (String[]) con.getAttribute(
+ new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME),
+ "InputArguments");
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public String[] getLibraryPath() throws ControllerOperationException {
+ try {
+ String cp = (String) con.getAttribute(
+ new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME),
+ "LibraryPath");
+ StringTokenizer st = new StringTokenizer(cp, ";");
+ String[] tokens = new String[st.countTokens()];
+ int i = 0;
+
+ while (st.hasMoreTokens()) {
+ tokens[i] = st.nextToken();
+ i++;
+ }
+
+ return tokens;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Hashtable getMemoryInfo() throws ControllerOperationException {
+ try {
+ ObjectName on =
+ new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
+ Hashtable table = new Hashtable(2);
+ table.put("Number of object pending finalization",
+ con.getAttribute(on, "ObjectPendingFinalizationCount"));
+ table.put("Verbose", con.getAttribute(on, "Verbose"));
+ return table;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param on
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Hashtable getMemoryManagerInfo(ObjectName on)
+ throws ControllerOperationException {
+
+ try {
+
+ Hashtable table = new Hashtable(2);
+ table.put("Name", con.getAttribute(on, "Name"));
+ table.put("Valid", con.getAttribute(on, "Valid"));
+ return table;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Set getMemoryManagerMBeans() throws ControllerOperationException {
+ try {
+ ObjectName on = new ObjectName(
+ ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE + ",*");
+ return (Set) con.queryNames(on, null);
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param on
+ * @return
+ * @throws ControllerOperationException
+ */
+ public String[] getMemoryManagerNames(ObjectName on)
+ throws ControllerOperationException {
+
+ try {
+ return (String[]) con.getAttribute(on, "MemoryManagerNames");
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException();
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param on
+ * @return
+ * @throws ControllerOperationException
+ */
+ public String[] getMemoryManagerPoolNames(ObjectName on)
+ throws ControllerOperationException {
+
+ try {
+ return (String[]) con.getAttribute(on, "MemoryPoolNames");
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param on
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Hashtable getMemoryPoolInfo(ObjectName on)
+ throws ControllerOperationException {
+
+ try {
+ Hashtable table = new Hashtable(11);
+ table.put("Collection usage threshold",
+ con.getAttribute(on, "CollectionUsageThreshold"));
+ table.put("Collection usage threshold count",
+ con.getAttribute(on, "CollectionUsageThresholdCount"));
+ table.put("Name", con.getAttribute(on, "Name"));
+ table.put("Type", con.getAttribute(on, "Type"));
+ table.put("Usage threshold", con.getAttribute(on, "UsageThreshold"));
+ table.put("Usage threshold count",
+ con.getAttribute(on, "UsageThresholdCount"));
+ table.put("Collection usage threshold exceeded",
+ con.getAttribute(on, "CollectionUsageThresholdExceeded"));
+ table.put("Collection usage threshold supported",
+ con.getAttribute(on, "CollectionUsageThresholdSupported"));
+ table.put("Usage threshold exceeded",
+ con.getAttribute(on, "UsageThresholdExceeded"));
+ table.put("Usage threshold supported",
+ con.getAttribute(on, "UsageThresholdSupported"));
+ table.put("Valid", con.getAttribute(on, "Valid"));
+ return table;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Set getMemoryPoolMBeans() throws ControllerOperationException {
+ try {
+ ObjectName on = new ObjectName(
+ ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE + ",*");
+ return (Set) con.queryNames(on, null);
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Collection getNonHeapMemoryUsage() throws ControllerOperationException {
+ try {
+
+ CompositeDataSupport nhmu = (CompositeDataSupport) con.getAttribute(
+ new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME),
+ "NonHeapMemoryUsage");
+ return nhmu.values();
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Hashtable getOSInfo() throws ControllerOperationException {
+ try {
+ ObjectName on =
+ new ObjectName(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
+ Hashtable table = new Hashtable(4);
+ table.put("Arch", con.getAttribute(on, "Arch"));
+ table.put("AvailableProcessors",
+ con.getAttribute(on, "AvailableProcessors"));
+ table.put("Name", con.getAttribute(on, "Name"));
+ table.put("Version", con.getAttribute(on, "Version"));
+ return table;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param on
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Collection getPeakUsage(ObjectName on)
+ throws ControllerOperationException {
+
+ try {
+ return ((CompositeDataSupport) con.getAttribute(
+ on, "PeakUsage")).values();
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Hashtable getRuntimeInfo() throws ControllerOperationException {
+ try {
+ ObjectName on =
+ new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
+ Hashtable table = new Hashtable(12);
+ table.put("Classpath", con.getAttribute(on, "ClassPath"));
+ table.put("Management specification version",
+ con.getAttribute(on, "ManagementSpecVersion"));
+ table.put("Name", con.getAttribute(on, "Name"));
+ table.put("Specification name", con.getAttribute(on, "SpecName"));
+ table.put("Specification vendor", con.getAttribute(on, "SpecVendor"));
+ table.put("Specification version",
+ con.getAttribute(on, "SpecVersion"));
+ table.put("Start time", con.getAttribute(on, "StartTime"));
+ table.put("Uptime", con.getAttribute(on, "Uptime"));
+ table.put("VM name", con.getAttribute(on, "VmName"));
+ table.put("VM vendor", con.getAttribute(on, "VmVendor"));
+ table.put("VM version", con.getAttribute(on, "VmVersion"));
+ table.put("Boot classpath supported",
+ con.getAttribute(on, "BootClassPathSupported"));
+ return table;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Hashtable getSystemProperties() throws ControllerOperationException {
+ try {
+ Hashtable table = new Hashtable();
+ TabularDataSupport tds = (TabularDataSupport) con.getAttribute(
+ new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME),
+ "SystemProperties");
+
+ for (Iterator it = tds.values().iterator(); it.hasNext(); ) {
+ CompositeDataSupport cds = (CompositeDataSupport) it.next();
+ Collection col = (Collection) cds.values();
+
+ for (Iterator iter = col.iterator(); iter.hasNext(); ) {
+ table.put(iter.next(), iter.next());
+ }
+ }
+
+ return table;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param id
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Object getThreadCpuTime(long id) throws ControllerOperationException {
+
+ try {
+ return con.invoke(
+ new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME),
+ "getThreadCpuTime",
+ new Object[] { new Long(id) },
+ new String[] { "long" });
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Hashtable getThreadInfo() throws ControllerOperationException {
+ try {
+ ObjectName on =
+ new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME);
+ Hashtable table = new Hashtable(11);
+ table.put("Thread count", con.getAttribute(on, "ThreadCount"));
+ table.put("Peak thread count",
+ con.getAttribute(on, "PeakThreadCount"));
+ table.put("Total started thread count",
+ con.getAttribute(on, "TotalStartedThreadCount"));
+ table.put("Daemon thread count",
+ con.getAttribute(on, "DaemonThreadCount"));
+ table.put("Thread contention monitoring supported",
+ con.getAttribute(on, "ThreadContentionMonitoringSupported"));
+ table.put("Thread contention monitoring enabled",
+ con.getAttribute(on, "ThreadContentionMonitoringEnabled"));
+ table.put("Current thread CPU time",
+ con.getAttribute(on, "CurrentThreadCpuTime"));
+ table.put("Current thread user time",
+ con.getAttribute(on, "CurrentThreadUserTime"));
+ table.put("Thread CPU time supported",
+ con.getAttribute(on, "ThreadCpuTimeSupported"));
+ table.put("Current thread CPU time supported",
+ con.getAttribute(on, "CurrentThreadCpuTimeSupported"));
+ table.put("Thread CPU time enabled",
+ con.getAttribute(on, "ThreadCpuTimeEnabled"));
+ return table;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param id
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Collection getThreadInfo(long id) throws ControllerOperationException {
+ try {
+ return ((CompositeDataSupport) con.invoke(
+ new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME),
+ "getThreadInfo",
+ new Object[] { new Long(id) },
+ new String[] { "long" })).values();
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param id
+ * @param maxDepth
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Collection getThreadInfo(long id, int maxDepth)
+ throws ControllerOperationException {
+
+ try {
+ return ((CompositeDataSupport) con.invoke(
+ new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME),
+ "getThreadInfo",
+ new Object[] { new Long(id), new Integer(maxDepth) },
+ new String[] { "long", "int" })).values();
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param ids
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Collection[] getThreadInfo(long[] ids) throws ControllerOperationException {
+ try {
+ CompositeData[] cd = (CompositeData[]) con.invoke(
+ new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME),
+ "getThreadInfo",
+ new Object[] { ids },
+ new String[] { "[J" });
+ Collection[] cols = new Collection[cd.length];
+
+ for (int i = 0; i < cd.length; i++) {
+ cols[i] = cd[i].values();
+ }
+
+ return cols;
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param ids
+ * @param maxDepth
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Object getThreadInfo(long[] ids, int maxDepth)
+ throws ControllerOperationException {
+
+ try {
+ return con.invoke(
+ new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME),
+ "getThreadInfo",
+ new Object[] { ids, new Integer(maxDepth) },
+ new String[] { "[J", "int" });
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param id
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Object getThreadUserTime(long id) throws ControllerOperationException {
+
+ try {
+ return con.invoke(
+ new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME),
+ "getThreadUserTime",
+ new Object[] { new Long(id) },
+ new String[] { "long" });
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param on
+ * @return
+ * @throws ControllerOperationException
+ */
+ public Collection getUsage(ObjectName on)
+ throws ControllerOperationException {
+
+ try {
+ return ((CompositeDataSupport) con.getAttribute(
+ on, "Usage")).values();
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @throws ControllerOperationException
+ */
+ public void resetPeakThreadCount() throws ControllerOperationException {
+
+ try {
+ con.invoke(
+ new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME),
+ "resetPeakThreadCount", null, null);
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+
+ /**
+ *
+ * @param on
+ * @throws ControllerOperationException
+ */
+ public void resetPeakUsage(ObjectName on)
+ throws ControllerOperationException {
+
+ try {
+ con.invoke(on, "resetPeakUsage", null, null);
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @throws ControllerOperationException
+ */
+ public void runGC() throws ControllerOperationException {
+ try {
+ con.invoke(new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME),
+ "gc", null, null);
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param on
+ * @param threhsold
+ * @throws ControllerOperationException
+ */
+ public void setCollectionUsageThreshold(ObjectName on, long threhsold)
+ throws ControllerOperationException {
+
+ try {
+ con.setAttribute(on, new Attribute(
+ "CollectionUsageThreshold", new Long(threhsold)));
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param enable
+ * @throws ControllerOperationException
+ */
+ public void setThreadContentionMonitoringEnabled(boolean enable)
+ throws ControllerOperationException {
+
+ try {
+ con.setAttribute(
+ new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME),
+ new Attribute(
+ "ThreadContentionMonitoringEnabled",
+ new Boolean(enable)));
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param enable
+ * @throws ControllerOperationException
+ */
+ public void setThreadCpuTimeEnabled(boolean enable)
+ throws ControllerOperationException {
+
+ try {
+ con.setAttribute(
+ new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME),
+ new Attribute(
+ "ThreadCpuTimeEnabled",
+ new Boolean(enable)));
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param on
+ * @param threhsold
+ * @throws ControllerOperationException
+ */
+ public void setUsageThreshold(ObjectName on, long threhsold)
+ throws ControllerOperationException {
+
+ try {
+ con.setAttribute(on, new Attribute(
+ "UsageThreshold", new Long(threhsold)));
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param value
+ */
+ public void setVerboseCL(boolean value) throws ControllerOperationException {
+ try {
+ con.setAttribute(
+ new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME),
+ new Attribute("Verbose", new Boolean(value)));
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /**
+ *
+ * @param value
+ */
+ public void setVerboseM(boolean value) throws ControllerOperationException {
+ try {
+ con.setAttribute(
+ new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME),
+ new Attribute("Verbose", new Boolean(value)));
+ } catch(Exception e) {
+ ControllerOperationException coe = new ControllerOperationException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+
+ /*
+ *
+ */
+ private void checkMXMBean(String on)
+ throws IOException, MalformedObjectNameException {
+
+ if (!con.isRegistered(new ObjectName(on))) {
+ throw new IllegalStateException(
+ "The specified MBeanServer reference is not valid. " +
+ "MXMBean " + on + " is not registerd.");
+ }
+ }
+
+ /*
+ * Further work with this class becomes useless if MXMBeans are
+ * not registerd with MBeanServer reference specified in the constructor.
+ */
+ private void checkMXMBeans() throws ServiceNotInstalledException {
+ try {
+ checkMXMBean(ManagementFactory.CLASS_LOADING_MXBEAN_NAME);
+ checkMXMBean(ManagementFactory.COMPILATION_MXBEAN_NAME);
+ checkMXMBean(ManagementFactory.MEMORY_MXBEAN_NAME);
+ checkMXMBean(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
+ checkMXMBean(ManagementFactory.RUNTIME_MXBEAN_NAME);
+ checkMXMBean(ManagementFactory.THREAD_MXBEAN_NAME);
+
+ if (getGarbageCollectorMBeans().size() == 0) {
+ throw new IllegalStateException(
+ "Garbage collector MBeans are not registered");
+ }
+
+ if (getMemoryManagerMBeans().size() == 0) {
+ throw new IllegalStateException(
+ "Memory manager MBeans are not registered");
+ }
+
+ if (getMemoryPoolMBeans().size() == 0) {
+ throw new IllegalStateException(
+ "Memory poools MBeans are not registered");
+ }
+ } catch(Exception e) {
+ ServiceNotInstalledException coe = new ServiceNotInstalledException(
+ e.getMessage());
+ coe.initCause(e);
+ throw coe;
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/controller/VMMonitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/Application.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/Application.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/Application.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/Application.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,44 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.management.console.plugin;
+
+import org.eclipse.core.runtime.IPlatformRunnable;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * This class controls all aspects of the application's execution
+ */
+public class Application implements IPlatformRunnable {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Object)
+ */
+ public Object run(Object args) throws Exception {
+ Display display = PlatformUI.createDisplay();
+ try {
+ int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
+ if (returnCode == PlatformUI.RETURN_RESTART) {
+ return IPlatformRunnable.EXIT_RESTART;
+ }
+ return IPlatformRunnable.EXIT_OK;
+ } finally {
+ display.dispose();
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/Application.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationActionBarAdvisor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationActionBarAdvisor.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationActionBarAdvisor.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationActionBarAdvisor.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,76 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.management.console.plugin;
+
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.ICoolBarManager;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.ToolBarContributionItem;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+
+public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
+
+ private IWorkbenchAction exitAction;
+ private IWorkbenchAction aboutAction;
+ private IWorkbenchAction newWindowAction;
+
+ public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
+ super(configurer);
+ }
+
+ protected void makeActions(IWorkbenchWindow window) {
+ exitAction = ActionFactory.QUIT.create(window);
+ register(exitAction);
+
+ aboutAction = ActionFactory.ABOUT.create(window);
+ register(aboutAction);
+
+ newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window);
+ register(newWindowAction);
+ }
+
+ protected void fillMenuBar(IMenuManager menuBar) {
+ MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
+ MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);
+
+ menuBar.add(fileMenu);
+ menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ menuBar.add(helpMenu);
+
+ fileMenu.add(new Separator());
+ helpMenu.add(new Separator());
+ }
+
+ protected void fillCoolBar(ICoolBarManager coolBar) {
+ IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
+ coolBar.add(new ToolBarContributionItem(toolbar, "main"));
+ //toolbar.add(openViewAction);
+ //toolbar.add(messagePopupAction);
+ }
+
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationActionBarAdvisor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationWorkbenchAdvisor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationWorkbenchAdvisor.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationWorkbenchAdvisor.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationWorkbenchAdvisor.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,35 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.management.console.plugin;
+
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchAdvisor;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
+
+ private static final String PERSPECTIVE_ID = "org.apache.harmony.x.management.console.plugin.perspective";
+
+ public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
+ return new ApplicationWorkbenchWindowAdvisor(configurer);
+ }
+
+ public String getInitialWindowPerspectiveId() {
+ return PERSPECTIVE_ID;
+ }
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationWorkbenchAdvisor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationWorkbenchWindowAdvisor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationWorkbenchWindowAdvisor.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationWorkbenchWindowAdvisor.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationWorkbenchWindowAdvisor.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,43 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.management.console.plugin;
+
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
+
+ public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
+ super(configurer);
+ }
+
+ public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
+ return new ApplicationActionBarAdvisor(configurer);
+ }
+
+ public void preWindowOpen() {
+ IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+ configurer.setInitialSize(new Point(400, 300));
+ configurer.setShowCoolBar(false);
+ configurer.setShowStatusLine(false);
+ configurer.setTitle("JMX Console");
+ }
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ApplicationWorkbenchWindowAdvisor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/AttributeView.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/AttributeView.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/AttributeView.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/AttributeView.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,259 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.management.console.plugin;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.apache.harmony.x.management.console.controller.AttributeInfo;
+import org.apache.harmony.x.management.console.plugin.editor.AbstractEditor;
+import org.apache.harmony.x.management.console.plugin.editor.EditorFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.part.ViewPart;
+
+
+/**
+ * <code>AttributeView</code> is responsible for visualizing of the attributes
+ * of MBean selected in <code>MbeanTreeView</code>. Because the contents of
+ * this view depends on the selection in <code>MbeanTreeView</code> this class
+ * implements <code>IMBeanTreeDependant</code> interface. The visualization of
+ * each attribute is defined according to its type. The type of attribute
+ * defines which successor of <code>AbstractEditor</code> will be responsible
+ * for its visuzlization.
+ *
+ *
+ * @see IMBeanTreeDependant
+ * @see org.apache.harmony.x.management.console.plugin.editor.AbstractEditor
+ * @author Victor A. Martynov
+ */
+public class AttributeView extends ViewPart implements IMBeanTreeDependant {
+
+ /**
+ * ID of this view in Eclipse runtime.
+ */
+ public static final String ID = "org.apache.harmony.x.management.console.plugin.view.attribute";
+
+ /**
+ * The delay between two consecutive refreshes of the attribute values.
+ */
+ public static final long REFRESH_RATE = 1000L;
+
+ private ScrolledComposite attrs_SCROLLCOMPOSITE = null;
+ private Composite attrs_table_COMPOSITE = null;
+ private Composite parent = null;
+ private boolean subscribed;
+
+ /**
+ * Refreshes the values of the attribute.
+ */
+ private Timer timer;
+
+ /**
+ *
+ */
+ private Hashtable attributeHashtable = null;
+
+ private MBeanTreeListener listener;
+
+ /**
+ * Calls the default constructor of the superclass.
+ */
+ public AttributeView() {
+ super();
+ }
+
+
+ /**
+ * Associates attributes and their editors.
+ */
+ public void createPartControl(final Composite parent) {
+
+ this.parent = parent;
+ Conn.addView(this);
+ listener = new MBeanTreeListener(this);
+
+ attrs_SCROLLCOMPOSITE = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+ attrs_SCROLLCOMPOSITE.setExpandHorizontal(true);
+
+ attrs_SCROLLCOMPOSITE.setExpandVertical(true);
+
+ attrs_table_COMPOSITE = new Composite(attrs_SCROLLCOMPOSITE, SWT.NONE);
+ attrs_table_COMPOSITE.setLayout(new GridLayout(1, false));
+ attrs_SCROLLCOMPOSITE.setContent(attrs_table_COMPOSITE);
+
+ redraw(Conn.getActiveNode());
+
+ parent.layout(true);
+ }
+
+
+ /**
+ * Redraws the view.
+ */
+ public void redraw(final MBeanTreeNode activeNode) {
+
+ if(Conn.DEBUG) {
+ OutputView.print("AttributeView.redraw("+activeNode+")");
+ }
+
+ Tools.cleanComposite(attrs_table_COMPOSITE);
+
+ attributeHashtable = new Hashtable(); // Cleaning old Hashtable
+
+ if(Conn.getMode() == Conn.NOT_CONNECTED) {
+ new Label(attrs_table_COMPOSITE, SWT.NONE).setText(Conn.getStatus());
+ attrs_table_COMPOSITE.layout(true);
+ return;
+ }
+
+ if(activeNode.getName() == null) {
+ new Label(attrs_table_COMPOSITE, SWT.NONE).setText("No attributes available.");
+ attrs_table_COMPOSITE.layout(true);
+ return;
+ }
+
+ if(timer != null) {
+ timer.cancel();
+ timer = null;
+ }
+
+ timer = new Timer(true);
+ timer.schedule(new TimerTask() {
+
+ public void run() {
+ if(parent.isDisposed()) {
+ this.cancel();
+ return;
+ }
+ parent.getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ refreshValues(activeNode);
+ }
+
+ });
+ }
+ }, REFRESH_RATE, REFRESH_RATE);
+
+ List list = null;
+
+ try {
+ list = Conn.getMBeanOperations().listAttributes(activeNode.getName());
+ } catch (Exception e) {
+ Tools.fireErrorDialog(parent, e);
+ return;
+ }
+
+ final AttributeInfo attrs[] = (AttributeInfo[]) list.toArray(new AttributeInfo[0]);
+
+ if (attrs.length == 0) {
+ new Label(attrs_table_COMPOSITE, SWT.NONE).setText("No attributes available.");
+ attrs_table_COMPOSITE.layout(true);
+ return;
+ }
+
+ for (int i = 0; i < attrs.length; i++) {
+ String attr_name = attrs[i].getName();
+ String attr_type = attrs[i].getType();
+
+
+ AbstractEditor editor = EditorFactory.create(attrs_table_COMPOSITE,
+ activeNode.getName(),
+ attr_name,
+ attr_type,
+ attrs[i].isWritable());
+
+ attributeHashtable.put(attr_name, editor);
+
+ String[] attr_key_type = new String[2];
+
+ attr_key_type[0] = attr_name;
+ attr_key_type[1] = attr_type;
+
+ editor.setData(attr_key_type);
+ editor.layout(true);
+ }
+
+ Point preferredSize = attrs_table_COMPOSITE.computeSize(parent.getSize().x, SWT.DEFAULT);
+ attrs_SCROLLCOMPOSITE.setMinSize(preferredSize);
+ refreshValues(activeNode);
+ attrs_table_COMPOSITE.layout(true);
+ attrs_SCROLLCOMPOSITE.layout(true);
+
+ parent.layout(true);
+ }
+
+ /**
+ * Refreshes the values in all attribute editors of this view.
+ */
+ private void refreshValues(MBeanTreeNode activeNode) {
+ Enumeration enumeration = attributeHashtable.keys();
+
+ while(enumeration.hasMoreElements()) {
+ String attrName = (String) enumeration.nextElement();
+
+ AbstractEditor editor = (AbstractEditor) attributeHashtable.get(attrName);
+
+ if(editor.isDisposed()) {
+ return;
+ }
+
+ if(editor.isFocused()) {
+ continue;
+ }
+
+ try {
+ editor.setValue(Conn.getMBeanOperations().getAttribute(activeNode.getName(), attrName));
+ editor.layout(true);
+ } catch (Exception e) {
+ Tools.fireErrorDialog(parent, e);
+ OutputView.print(e);
+ timer.cancel();
+ return;
+ }
+ }
+ }
+
+ public void setFocus() {
+ // This method was intentionally left empty.
+ }
+
+ public Composite getParent() {
+ return parent;
+ }
+
+ public MBeanTreeListener getMBeanTreeListener() {
+ return listener;
+ }
+
+ public boolean getSubscribed() {
+ return subscribed;
+ }
+
+ public void setSubscribed(boolean val) {
+ subscribed = val;
+ }
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/AttributeView.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/Conn.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/Conn.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/Conn.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/Conn.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,238 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.4 $
+ */
+package org.apache.harmony.x.management.console.plugin;
+
+import java.net.MalformedURLException;
+import java.util.Vector;
+
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.harmony.x.management.console.controller.Controller;
+import org.apache.harmony.x.management.console.controller.ControllerFactory;
+import org.apache.harmony.x.management.console.controller.MBeanOperations;
+import org.apache.harmony.x.management.console.controller.NotificationHandler;
+import org.apache.harmony.x.management.console.controller.VMMonitor;
+
+
+public class Conn {
+
+ public static final int NOT_CONNECTED = 0;
+ public static final int VM_MODE = 1;
+ public static final int NEW_SERVER_MODE = 2;
+ public static final int URL_MODE = 3;
+ public static final boolean DEBUG = true;
+
+ private static int mode = 0;
+ private static int port;
+ private static boolean startJMXConnector;
+ private static String defaultDomain;
+ private static String url;
+ private static String user;
+ private static String pass;
+ private static MBeanTreeNode node;
+
+ private static Controller controller;
+
+ private static MBeanOperations mbo;
+
+ private static VMMonitor vmmon = null;
+
+ private static NotificationHandler notificationHandler = null;
+
+ private static MBeanTreeView mbeanTreeView = null;
+
+ private static Vector views = new Vector();
+
+ /*
+ * Setters
+ */
+ static void setMode(int value) {
+ mode = value;
+ }
+
+ static void setPort(int value) {
+ port=value;
+ }
+
+ static void setStartJMXConnector(boolean value) {
+ startJMXConnector = value;
+ }
+
+ static void setDefaultDomain(String value) {
+ defaultDomain = value;
+ }
+
+ static void setUrl(String value) {
+ url=value;
+ }
+
+ static void setUser(String value) {
+ user=value;
+
+ }
+
+ static void setPass(String value) {
+ pass=value;
+
+ }
+
+ /*
+ * Getters
+ */
+ static int getMode() {
+ return mode;
+ }
+
+
+ static int getPort() {
+ return port;
+ }
+
+ static boolean getStartJMXConnector() {
+ return startJMXConnector;
+ }
+
+ static String getDefaultDomain() {
+ return defaultDomain;
+ }
+
+ static String getUrl() {
+ return url;
+ }
+
+ static String getUser() {
+ return user;
+
+ }
+
+ static String getPass() {
+ return pass;
+ }
+
+ static void printConnection() {
+ }
+
+ static Controller getController() {
+ if(controller == null) {
+ controller = ControllerFactory.getController();
+ }
+ return controller;
+ }
+
+ public static MBeanOperations getMBeanOperations() {
+ if(mbo == null) {
+ mbo = getController().getMBeanOperations();
+ }
+ return mbo;
+ }
+
+ static NotificationHandler getNotificationHandler() {
+ if(notificationHandler == null) {
+ notificationHandler = getController().getNotificationService();
+ }
+ return notificationHandler;
+ }
+
+ static VMMonitor getVMMonitor() {
+ if(vmmon == null) {
+ try {
+ vmmon = Conn.getController().getVMMonitor();
+ } catch(Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+ return vmmon;
+ }
+
+/* public static void setMBeanTree(Tree tree) {
+ mbeanTree = tree;
+ }
+
+ public static Tree getMBeanTree() {
+ return mbeanTree;
+ }*/
+
+ public static String getStatus() {
+ switch(mode) {
+ case NOT_CONNECTED:
+ return "Not Connected";
+ case VM_MODE:
+ return "Local VM";
+ case NEW_SERVER_MODE:
+ String s = startJMXConnector ? defaultDomain + ", port=" + port : defaultDomain;
+
+ return s;
+ case URL_MODE:
+ try {
+ JMXServiceURL surl = new JMXServiceURL(url);
+ return surl.getHost() + ":" + surl.getPort();
+ }
+ catch(MalformedURLException mue) {
+ mue.printStackTrace();
+ return "Exception: "+mue;
+ }
+ default:
+ return "Unrecognized Mode";
+ }
+ }
+
+ public static void setMBeanTreeView(MBeanTreeView view) {
+ mbeanTreeView = view;
+ }
+
+ public static MBeanTreeView getMBeanTreeView() {
+ return mbeanTreeView;
+ }
+
+ public static void resetController() {
+ controller = null;
+ mbo = null;
+ vmmon = null;
+ notificationHandler = null;
+ }
+
+ public static void addView(IMBeanTreeDependant view) {
+ views.add(view);
+ }
+
+ public static void removeView(IMBeanTreeDependant view) {
+ views.remove(view);
+ }
+
+ public static IMBeanTreeDependant[] getViews() {
+ return (IMBeanTreeDependant[])views.toArray(new IMBeanTreeDependant[0]);
+ }
+
+
+//public static String getMBeanName() {
+// return mbeanName;
+//}
+
+// public static void setMBeanName(String mbeanName) {
+// Conn.mbeanName = mbeanName;
+// }
+
+ public static void setActiveNode(MBeanTreeNode newNode) {
+ node = newNode;
+ }
+
+ public static MBeanTreeNode getActiveNode() {
+ return node;
+ }
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/Conn.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectDialog.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectDialog.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectDialog.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectDialog.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,244 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.5 $
+ */
+package org.apache.harmony.x.management.console.plugin;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.5 $
+ */
+public class ConnectDialog {
+
+ Composite dialog;
+ TabFolder connect_TABFOLDER = null;
+
+ TabItem vm_TI = null;
+ TabItem create_server_TI = null;
+ TabItem url_TI = null;
+
+ private Composite vm_COMPOSITE = null;
+ private Composite create_server_COMPOSITE = null;
+ private Composite url_COMPOSITE = null;
+
+ private Label user_name_LABEL = null;
+ private Label password_LABEL = null;
+
+ Text jmx_url_TEXT = null;
+ Text user_name_TEXT = null;
+ Text password_TEXT = null;
+
+ private Label jmx_url_LABEL = null;
+
+ private Text default_domain_TEXT = null;
+ private Label default_domain_LABEL = null;
+
+ private Label JMXConnectorPort_LABEL = null;
+ private Text JMXConnectorPort_TEXT = null;
+
+ private static int WIDTH = 400;
+ private static int HEIGHT = 250;
+
+ private static int LW = 100; //Label width
+ private static int H = 20; //Label width
+
+ private static int TW = 200; //Text width
+ private static int SP = 10; // Space between components
+
+ private Button startJMXConnector_BUTTON = null;
+
+
+ public ConnectDialog(Composite parent) {
+ if(Conn.DEBUG) OutputView.print("ConnectWizardPage.createControl(Composite)");
+
+ connect_TABFOLDER = new TabFolder(parent, SWT.NONE);
+ connect_TABFOLDER.setBounds(0, 0, WIDTH, HEIGHT);
+
+ url_TI = new TabItem(connect_TABFOLDER, SWT.NONE);
+
+ create_server_TI = new TabItem(connect_TABFOLDER, SWT.NONE);
+
+ vm_TI = new TabItem(connect_TABFOLDER, SWT.NONE);
+
+ vm_TI.setText("Local VM");
+
+ create_server_TI.setText("New Server");
+
+ url_TI.setText("Remote URL");
+
+ vm_TI.setToolTipText("Connect to VM locally");
+ create_server_TI.setToolTipText("Create new MBean server");
+
+ url_TI.setToolTipText("Connect to MBean Server using full URL and user credentials");
+
+ vm_COMPOSITE = new Composite(connect_TABFOLDER, SWT.NONE);
+
+ create_server_COMPOSITE = new Composite(connect_TABFOLDER, SWT.NONE);
+
+ url_COMPOSITE = new Composite(connect_TABFOLDER, SWT.NONE);
+
+ vm_TI.setControl(vm_COMPOSITE);
+ create_server_TI.setControl(create_server_COMPOSITE);
+ url_TI.setControl(url_COMPOSITE);
+
+ fill_create_server_COMPOSITE();
+ fill_url_COMPOSITE();
+ fill_vm_COMPOSITE();
+
+ if(Conn.DEBUG) OutputView.print("ConnectWizardPage.createControl(Composite) finished.");
+ }
+
+ /* ************************************************************************
+ * Private methods.
+ * ***********************************************************************/
+
+ /*
+ * Filling URL composite.
+ *
+ */
+ private void fill_url_COMPOSITE() {
+
+
+ jmx_url_LABEL = new Label(url_COMPOSITE, SWT.NONE);
+ jmx_url_LABEL.setText("JMX URL:");
+ jmx_url_TEXT = new Text(url_COMPOSITE, SWT.BORDER);
+ jmx_url_LABEL.setBounds(SP, SP, LW, H);
+ jmx_url_TEXT.setBounds(LW+2*SP, SP, TW, H);
+
+ user_name_LABEL = new Label(url_COMPOSITE, SWT.NONE);
+ user_name_LABEL.setText("User Name:");
+ user_name_TEXT = new Text(url_COMPOSITE, SWT.BORDER);
+ user_name_LABEL.setBounds(SP, H+2*SP, LW, H);
+ user_name_TEXT.setBounds(LW+2*SP, H+2*SP, TW, H);
+
+
+ password_LABEL = new Label(url_COMPOSITE, SWT.NONE);
+ password_LABEL.setText("Password:");
+ password_TEXT = new Text(url_COMPOSITE, SWT.BORDER);
+ password_LABEL.setBounds(SP, 2*H+3*SP, LW, H);
+ password_TEXT.setBounds(LW+2*SP, 2*H+3*SP, TW, H);
+ }
+
+ /*
+ * Filling server composite
+ */
+ void fill_create_server_COMPOSITE() {
+
+ GridLayout gridLayout = new GridLayout(2, false);
+
+ gridLayout.horizontalSpacing = 20;
+ gridLayout.verticalSpacing = 10;
+
+ create_server_COMPOSITE.setLayout(gridLayout);
+
+ default_domain_LABEL = new Label(create_server_COMPOSITE, SWT.NONE);
+ default_domain_LABEL.setText("Default Domain: ");
+
+ default_domain_TEXT = new Text(create_server_COMPOSITE, SWT.BORDER);
+ default_domain_TEXT.setText("DefaultDomain");
+ default_domain_TEXT.setToolTipText("The default domain of a newly created JMX server");
+
+ new Label(create_server_COMPOSITE, SWT.SEPARATOR | SWT.HORIZONTAL);
+ new Label(create_server_COMPOSITE, SWT.NONE); //Placeholder
+
+ startJMXConnector_BUTTON = new Button(create_server_COMPOSITE, SWT.CHECK);
+ startJMXConnector_BUTTON.setText("Start JMX Connector");
+ startJMXConnector_BUTTON.setSelection(false);
+ startJMXConnector_BUTTON.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ if(startJMXConnector_BUTTON.getSelection()) {
+ JMXConnectorPort_LABEL.setEnabled(true);
+ JMXConnectorPort_TEXT.setEnabled(true);
+ } else {
+ JMXConnectorPort_LABEL.setEnabled(false);
+ JMXConnectorPort_TEXT.setEnabled(false);
+ JMXConnectorPort_TEXT.setText("");
+ }
+ }
+ });
+
+ new Label(create_server_COMPOSITE, SWT.NONE); //Placeholder
+
+ JMXConnectorPort_LABEL = new Label(create_server_COMPOSITE, SWT.NONE);
+ JMXConnectorPort_LABEL.setText("Port: ");
+
+ JMXConnectorPort_TEXT = new Text(create_server_COMPOSITE, SWT.BORDER);
+ JMXConnectorPort_TEXT.setText("");
+ JMXConnectorPort_TEXT.setToolTipText("The port on which JMX connector will start");
+
+ JMXConnectorPort_LABEL.setEnabled(false);
+ JMXConnectorPort_TEXT.setEnabled(false);
+ }
+
+ private void fill_vm_COMPOSITE() {
+ vm_COMPOSITE.setLayout(new FillLayout());
+ new Label(vm_COMPOSITE, SWT.NONE).setText("Manages the local JVM");
+ }
+
+ void saveConnection() throws Exception {
+ TabItem selectedTab = connect_TABFOLDER.getSelection()[0];
+
+ Conn.resetController();
+
+ /*
+ * VM tab selected.
+ */
+ if(selectedTab.equals(vm_TI)) {
+ Conn.setMode(Conn.VM_MODE);
+ Conn.getController().connect();
+
+ } else if (selectedTab.equals(create_server_TI)) { //New Server tab
+ int port;
+
+ Conn.setMode(Conn.NEW_SERVER_MODE);
+
+ String portS = JMXConnectorPort_TEXT.getText();
+ if(portS.equals("")) {
+ portS = "0";
+ }
+
+ port = new Integer(portS).intValue();
+ Conn.setPort(port);
+ Conn.setStartJMXConnector(startJMXConnector_BUTTON.getSelection());
+ Conn.setDefaultDomain(default_domain_TEXT.getText());
+ Conn.getController().connect(default_domain_TEXT.getText());
+
+ } else if(selectedTab.equals(url_TI)) { //URL tab selected
+ Conn.setMode(Conn.URL_MODE);
+ Conn.setUrl(jmx_url_TEXT.getText());
+ Conn.setUser(user_name_TEXT.getText());
+ Conn.setPass(password_TEXT.getText());
+
+ Conn.getController().connect(jmx_url_TEXT.getText(),
+ user_name_TEXT.getText(),
+ password_TEXT.getText());
+ }
+ }
+
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectWizard.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectWizard.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectWizard.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectWizard.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,70 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.management.console.plugin;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+public class ConnectWizard extends Wizard implements INewWizard {
+
+ private static final boolean DEBUG = true;
+ ConnectWizardPage page = new ConnectWizardPage("New Connection");
+
+ public ConnectWizard() {
+ super();
+ this.setWindowTitle("Connect Wizard Title");
+ }
+
+ public boolean performFinish() {
+ OutputView.print("performFinish");
+ try {
+ page.saveConnection();
+
+ MBeanTreeView mbeanTreeView = Conn.getMBeanTreeView();
+
+ if(mbeanTreeView != null) {
+ mbeanTreeView.fill();
+ }
+
+ Conn.printConnection();
+ }
+ catch(Throwable t) {
+ Tools.fireErrorDialog(getShell(), t);
+ OutputView.print(t);
+ return false;
+ }
+
+ return true;
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ OutputView.print("init");
+ }
+
+ public void addPages() {
+ if(DEBUG) OutputView.print("ConnectWizard.addPages");
+ addPage(page);
+ if(DEBUG) OutputView.print("ConnectWizard.addPages completed.");
+ }
+
+ public boolean needsPreviousAndNextButtons() {
+ return false;
+ }
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectWizard.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectWizardPage.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectWizardPage.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectWizardPage.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectWizardPage.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,48 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.management.console.plugin;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Composite;
+
+public class ConnectWizardPage extends WizardPage {
+
+ ConnectDialog cd;
+
+ public ConnectWizardPage() {
+ super("Default Page Name");
+ if(Conn.DEBUG) OutputView.print("ConnectWizardPage.<init>()");
+ }
+
+ protected ConnectWizardPage(String pageName) {
+ super(pageName);
+ if(Conn.DEBUG) OutputView.print("ConnectWizardPage.<init>(String)");
+ }
+
+ public void createControl(Composite parent) {
+
+ if(Conn.DEBUG) OutputView.print("ConnectWizardPage.createControl("+parent+")");
+
+ cd = new ConnectDialog(parent);
+ setControl(parent);
+ }
+
+ void saveConnection() throws Exception {
+ cd.saveConnection();
+ }
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ConnectWizardPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ErrorDialog.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ErrorDialog.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ErrorDialog.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ErrorDialog.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,116 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.management.console.plugin;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * The visualization of Error Dialog.
+ * @author Victor A. Martynov
+ * @version $Revision: 1.3 $
+ */
+class ErrorDialog {
+
+ public static final int BUTTON_WIDTH = 100;
+ public static final int BUTTON_HEIGHT = 25;
+
+ private Shell error_SHELL = null;
+ private Label error_LABEL = null;
+ private Button ok_BUTTON;
+ private Text details_TEXT;
+ private Button openDetails_BUTTON;
+ private boolean isDetailsOpen = false;
+
+ /**
+ * This method initializes error_SHELL
+ *
+ */
+ ErrorDialog(Shell parent, Throwable exception) {
+
+ /*
+ * Printing the stack trace into byte array, in order to visualize it.
+ */
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream(baos);
+ exception.printStackTrace(ps);
+ final String stackTrace = new String(baos.toByteArray());
+
+ error_SHELL = new Shell(parent, SWT.APPLICATION_MODAL | SWT.CLOSE | SWT.RESIZE);
+ error_SHELL.setText("Error");
+ error_SHELL.setMinimumSize(500, 100);
+ error_SHELL.setImage(parent.getDisplay().getSystemImage(SWT.ICON_ERROR));
+ error_SHELL.setLayout(new GridLayout(2, false));
+
+ error_LABEL = new Label(error_SHELL, SWT.NONE);
+ error_LABEL.setText(exception.getMessage());
+ new Label(error_SHELL, SWT.NONE);
+
+ ok_BUTTON = new Button(error_SHELL, SWT.NONE);
+ ok_BUTTON.setBounds(250, 0, 100, 25);
+ ok_BUTTON.setText(" OK ");
+
+ ok_BUTTON.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ error_SHELL.close();
+ error_SHELL.dispose();
+ error_SHELL = null;
+ }
+ });
+
+ openDetails_BUTTON = new Button(error_SHELL, SWT.NONE);
+
+ openDetails_BUTTON.setBounds(390, 0, 100, 25);
+
+ openDetails_BUTTON.setText("Details >>");
+
+ openDetails_BUTTON.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+
+ if(isDetailsOpen) {
+ isDetailsOpen = false;
+ openDetails_BUTTON.setText("Details >>");
+ details_TEXT.setText("");
+ } else {
+ isDetailsOpen = true;
+ openDetails_BUTTON.setText("Details <<");
+ details_TEXT.setText(stackTrace);
+ }
+ details_TEXT.setVisible(isDetailsOpen);
+ error_SHELL.pack();
+ }
+ });
+
+ details_TEXT = new Text(error_SHELL, SWT.V_SCROLL | SWT.H_SCROLL);
+ details_TEXT.setText("");
+ details_TEXT.setVisible(false);
+
+ error_SHELL.pack();
+ error_SHELL.open();
+ }
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/ErrorDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/IMBeanTreeDependant.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/IMBeanTreeDependant.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/IMBeanTreeDependant.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/IMBeanTreeDependant.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,35 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.3 $
+ */
+package org.apache.harmony.x.management.console.plugin;
+
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Describes the interface of all views which depend upon MBean Tree View.
+ *
+ *
+ * @author Victor A. Martynov
+ */
+public interface IMBeanTreeDependant {
+
+ public void redraw(MBeanTreeNode activeNode);
+ public Composite getParent();
+ public MBeanTreeListener getMBeanTreeListener();
+ public boolean getSubscribed();
+ public void setSubscribed(boolean val);
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/IMBeanTreeDependant.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/IndicatorView.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/IndicatorView.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/IndicatorView.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/IndicatorView.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,55 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.3 $
+ */
+
+package org.apache.harmony.x.management.console.plugin;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.part.ViewPart;
+
+public class IndicatorView extends ViewPart {
+
+ public IndicatorView() {
+ super();
+ }
+
+ public void createPartControl(Composite parent) {
+ parent.setLayout(new FillLayout());
+
+ Button disconnectButton = new Button(parent, SWT.NONE);
+ disconnectButton.setText("Disconnect");
+ disconnectButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+
+ }
+ });
+
+ Label statusLabel = new Label(parent, SWT.NONE);
+ statusLabel.setText("Status: "+Conn.getStatus());
+ }
+
+ public void setFocus() {
+ }
+
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/IndicatorView.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/JMXConsolePlugin.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/JMXConsolePlugin.java?rev=438510&view=auto
==============================================================================
--- incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/JMXConsolePlugin.java (added)
+++ incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/JMXConsolePlugin.java Wed Aug 30 08:02:59 2006
@@ -0,0 +1,72 @@
+/* Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * @author Victor A. Martynov
+ * @version $Revision: 1.3 $
+ */
+
+package org.apache.harmony.x.management.console.plugin;
+
+import org.eclipse.ui.plugin.*;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class JMXConsolePlugin extends AbstractUIPlugin {
+
+ //The shared instance.
+ private static JMXConsolePlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public JMXConsolePlugin() {
+ plugin = this;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static JMXConsolePlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path.
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin("JMXConsole", path);
+ }
+}
Propchange: incubator/harmony/enhanced/tools/trunk/jmx_console/src/org/apache/harmony/x/management/console/plugin/JMXConsolePlugin.java
------------------------------------------------------------------------------
svn:eol-style = native