Permalink
Browse files

tab2spaces,

cleanups
  • Loading branch information...
1 parent cc485d9 commit 9bd4ac8ec76ef061fe744597c499716fa662a348 @tcurdt committed Mar 21, 2011
@@ -5,45 +5,45 @@
import javax.management.ObjectName;
/**
- * Represents a property exposed through the MBeanServer
- *
+ * Represents a property exposed through the MBeanServer
+ *
* @threadsafe yes
*/
public final class JmxAttribute {
-
- private final String attributeName;
- private final String type;
- private final ObjectName objectName;
- private final MBeanServer mbeanServer;
- private final String path;
-
- public JmxAttribute(String pAttributeName, String pType, ObjectName pObjectName, MBeanServer pMbeanServer) {
- attributeName = pAttributeName;
- type = pType;
- objectName = pObjectName;
- mbeanServer = pMbeanServer;
-
- String beanName = pObjectName.getKeyProperty("name");
- if (beanName == null) {
- beanName = pObjectName.getKeyProperty("type");
- }
- path = "<oid>." + beanName + "." + attributeName;
- }
-
- public String getPath() {
- return path;
- }
-
- public String getName() {
- return attributeName;
- }
-
- public String getType() {
- return type;
- }
-
- public Object getValue() throws JMException {
- final Object attributeValue = mbeanServer.getAttribute(objectName, attributeName);
- return attributeValue;
- }
+
+ private final String attributeName;
+ private final String type;
+ private final ObjectName objectName;
+ private final MBeanServer mbeanServer;
+ private final String path;
+
+ public JmxAttribute(String pAttributeName, String pType, ObjectName pObjectName, MBeanServer pMbeanServer) {
+ attributeName = pAttributeName;
+ type = pType;
+ objectName = pObjectName;
+ mbeanServer = pMbeanServer;
+
+ String beanName = pObjectName.getKeyProperty("name");
+ if (beanName == null) {
+ beanName = pObjectName.getKeyProperty("type");
+ }
+ path = "<oid>." + beanName + "." + attributeName;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getName() {
+ return attributeName;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public Object getValue() throws JMException {
+ final Object attributeValue = mbeanServer.getAttribute(objectName, attributeName);
+ return attributeValue;
+ }
}
@@ -24,61 +24,61 @@
*/
public final class JmxIndex {
- private final AtomicReference<Map<String, JmxAttribute>> attributesRef = new AtomicReference<Map<String, JmxAttribute>>(Collections.unmodifiableMap(new HashMap<String, JmxAttribute>()));
- private final MBeanServer mbeanServer;
- private final String expression;
-
- public JmxIndex() throws Exception {
- this(ManagementFactory.getPlatformMBeanServer(), "bean:*");
- }
-
- public JmxIndex(MBeanServer pMbeanServer, String pExpression) throws Exception {
- mbeanServer = pMbeanServer;
- expression = pExpression;
-
- update();
- }
-
- public void update() throws Exception {
-
- final HashMap<String, JmxAttribute> newAttributes = new HashMap<String, JmxAttribute>();
- final Collection<ObjectInstance> mbeans = mbeanServer.queryMBeans(new ObjectName(expression), null);
-
- for (Iterator<ObjectInstance> it = mbeans.iterator(); it.hasNext();) {
- final ObjectInstance mbean = it.next();
-
- final MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(mbean.getObjectName());
-
- final MBeanAttributeInfo[] attributes = mbeanInfo.getAttributes();
- for (final MBeanAttributeInfo attribute : attributes) {
-
- if (attribute.isReadable()) {
- final String attributeName = attribute.getName();
-
- final JmxAttribute jmxAttribute = new JmxAttribute(attributeName, attribute.getType(), mbean.getObjectName(), mbeanServer);
-
- newAttributes.put(jmxAttribute.getPath(), jmxAttribute);
- }
- }
- }
-
- attributesRef.set(Collections.unmodifiableMap(newAttributes));
- }
-
- public Set<String> getAttributePaths() {
- final Map<String, JmxAttribute> mapping = attributesRef.get();
- return Collections.unmodifiableSet(mapping.keySet());
- }
-
- public JmxAttribute getAttributeAtPath(String pPath) {
- final Map<String, JmxAttribute> attributes = attributesRef.get();
- return attributes.get(pPath);
- }
-
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append(super.toString());
- sb.append('{').append(attributesRef.get()).append('}');
- return sb.toString();
- }
+ private final AtomicReference<Map<String, JmxAttribute>> attributesRef = new AtomicReference<Map<String, JmxAttribute>>(Collections.unmodifiableMap(new HashMap<String, JmxAttribute>()));
+ private final MBeanServer mbeanServer;
+ private final String expression;
+
+ public JmxIndex() throws Exception {
+ this(ManagementFactory.getPlatformMBeanServer(), "bean:*");
+ }
+
+ public JmxIndex(MBeanServer pMbeanServer, String pExpression) throws Exception {
+ mbeanServer = pMbeanServer;
+ expression = pExpression;
+
+ update();
+ }
+
+ public void update() throws Exception {
+
+ final HashMap<String, JmxAttribute> newAttributes = new HashMap<String, JmxAttribute>();
+ final Collection<ObjectInstance> mbeans = mbeanServer.queryMBeans(new ObjectName(expression), null);
+
+ for (Iterator<ObjectInstance> it = mbeans.iterator(); it.hasNext();) {
+ final ObjectInstance mbean = it.next();
+
+ final MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(mbean.getObjectName());
+
+ final MBeanAttributeInfo[] attributes = mbeanInfo.getAttributes();
+ for (final MBeanAttributeInfo attribute : attributes) {
+
+ if (attribute.isReadable()) {
+ final String attributeName = attribute.getName();
+
+ final JmxAttribute jmxAttribute = new JmxAttribute(attributeName, attribute.getType(), mbean.getObjectName(), mbeanServer);
+
+ newAttributes.put(jmxAttribute.getPath(), jmxAttribute);
+ }
+ }
+ }
+
+ attributesRef.set(Collections.unmodifiableMap(newAttributes));
+ }
+
+ public Set<String> getAttributePaths() {
+ final Map<String, JmxAttribute> mapping = attributesRef.get();
+ return Collections.unmodifiableSet(mapping.keySet());
+ }
+
+ public JmxAttribute getAttributeAtPath(String pPath) {
+ final Map<String, JmxAttribute> attributes = attributesRef.get();
+ return attributes.get(pPath);
+ }
+
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(super.toString());
+ sb.append('{').append(attributesRef.get()).append('}');
+ return sb.toString();
+ }
}
Oops, something went wrong.

0 comments on commit 9bd4ac8

Please sign in to comment.