From e1f64cfe2d512bbc987f2c7947aa4dd4ea9d833d Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 9 Feb 2009 14:11:16 -0800 Subject: [PATCH] dos2unix --- .../java/src/org/hyperic/sigar/cmd/Mx.java | 240 +++++----- .../org/hyperic/sigar/jmx/ReflectedMBean.java | 414 +++++++++--------- 2 files changed, 327 insertions(+), 327 deletions(-) diff --git a/bindings/java/src/org/hyperic/sigar/cmd/Mx.java b/bindings/java/src/org/hyperic/sigar/cmd/Mx.java index 78e0dafb..554fddf9 100644 --- a/bindings/java/src/org/hyperic/sigar/cmd/Mx.java +++ b/bindings/java/src/org/hyperic/sigar/cmd/Mx.java @@ -1,120 +1,120 @@ -/* Copyright (C) [2004, 2005, 2006], Hyperic, Inc. - * This file is part of SIGAR. - * - * SIGAR is free software; you can redistribute it and/or modify - * it under the terms version 2 of the GNU General Public License as - * published by the Free Software Foundation. This program is distributed - * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - -package org.hyperic.sigar.cmd; - -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import javax.management.MBeanAttributeInfo; -import javax.management.MBeanInfo; -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; -import javax.management.ObjectName; - -import org.hyperic.sigar.SigarException; -import org.hyperic.sigar.jmx.SigarProcess; -import org.hyperic.sigar.jmx.SigarRegistry; - -public class Mx extends SigarCommandBase { - - private boolean isRegistered; - - public Mx(Shell shell) { - super(shell); - } - - public Mx() { - super(); - } - //java -Dcom.sun.management.jmxremote -jar sigar.jar - public String getUsageShort() { - return "Register MBeans for use via jconsole, etc."; - } - - protected boolean validateArgs(String[] args) { - return args.length <= 1; - } - - public static MBeanServer getMBeanServer() - throws SigarException { - List servers = - MBeanServerFactory.findMBeanServer(null); - - if (servers.size() == 0) { - throw new SigarException("No MBeanServers available"); - } - else { - return (MBeanServer)servers.get(0); - } - } - - private void register(MBeanServer server) throws SigarException { - if (isRegistered) { - return; - } - SigarRegistry registry = new SigarRegistry(); - try { - server.registerMBean(registry, null); - SigarProcess proc = new SigarProcess(); - server.registerMBean(proc, new ObjectName(proc.getObjectName())); - isRegistered = true; - } catch (Exception e) { - throw new SigarException(e.getMessage()); - } - } - - public void output(String[] args) throws SigarException { - MBeanServer server = getMBeanServer(); - register(server); - boolean hasQuery = args.length != 0; - try { - String query; - if (hasQuery) { - query = args[0]; - } - else { - query = "sigar:*"; - } - Set beans = - server.queryNames(new ObjectName(query), null); - println(beans.size() + " MBeans are registered..."); - for (Iterator it=beans.iterator(); it.hasNext();) { - ObjectName name = (ObjectName)it.next(); - if (hasQuery) { - MBeanInfo info = server.getMBeanInfo(name); - MBeanAttributeInfo[] attrs = info.getAttributes(); - for (int i=0; i