Author: rob.stryker(a)jboss.com
Date: 2009-02-05 05:15:58 -0500 (Thu, 05 Feb 2009)
New Revision: 13482
Removed:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/DomainWrapper.java
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanInfoWrapper.java
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/tree/Node.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/JMXUIActivator.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/adapters/JMXAdapterFactory.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/OperationDetails.java
Log:
JBIDE-3276 - editor attribute changes / operation invocations now use connections api
Deleted:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/DomainWrapper.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/DomainWrapper.java 2009-02-05
08:30:56 UTC (rev 13481)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/DomainWrapper.java 2009-02-05
10:15:58 UTC (rev 13482)
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Jeff Mesnil
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- *
http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-package org.jboss.tools.jmx.core;
-
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.management.MBeanInfo;
-import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.eclipse.core.runtime.Assert;
-
-public class DomainWrapper {
-
- private final String name;
-
- private final MBeanServerConnection mbsc;
-
- public DomainWrapper(String name, MBeanServerConnection mbsc) {
- Assert.isNotNull(name);
- Assert.isNotNull(mbsc);
- this.name = name;
- this.mbsc = mbsc;
- }
-
- private ObjectName getPattern() throws MalformedObjectNameException {
- return new ObjectName(name + ":*"); //$NON-NLS-1$
- }
-
- public String getName() {
- return name;
- }
-
- public MBeanInfoWrapper[] getMBeanInfos() {
- try {
- Set set = mbsc.queryNames(getPattern(), null);
- MBeanInfoWrapper[] instances = new MBeanInfoWrapper[set.size()];
- int i = 0;
- for (Iterator iter = set.iterator(); iter.hasNext();) {
- ObjectName on = (ObjectName) iter.next();
- MBeanInfo info = mbsc.getMBeanInfo(on);
- instances[i] = new MBeanInfoWrapper(on, info, mbsc, this);
- i++;
- }
- return instances;
- } catch (Exception e) {
- e.printStackTrace();
- return new MBeanInfoWrapper[0];
- }
- }
-}
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanInfoWrapper.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanInfoWrapper.java 2009-02-05
08:30:56 UTC (rev 13481)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/MBeanInfoWrapper.java 2009-02-05
10:15:58 UTC (rev 13482)
@@ -8,8 +8,6 @@
package org.jboss.tools.jmx.core;
-import java.util.Arrays;
-
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanInfo;
import javax.management.MBeanNotificationInfo;
@@ -19,16 +17,17 @@
import javax.management.ObjectName;
import org.eclipse.core.runtime.Assert;
+import org.jboss.tools.jmx.core.tree.ObjectNameNode;
import org.jboss.tools.jmx.core.util.EqualsUtil;
public class MBeanInfoWrapper implements Comparable {
private final ObjectName on;
private final MBeanInfo info;
private final MBeanServerConnection mbsc;
- private final Object parent;
+ private final ObjectNameNode parent;
public MBeanInfoWrapper(ObjectName on, MBeanInfo info,
- MBeanServerConnection mbsc, Object parent) {
+ MBeanServerConnection mbsc, ObjectNameNode parent) {
Assert.isNotNull(on);
Assert.isNotNull(info);
Assert.isNotNull(mbsc);
@@ -38,7 +37,7 @@
this.parent = parent;
}
- public Object getParent() {
+ public ObjectNameNode getParent() {
return parent;
}
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/tree/Node.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/tree/Node.java 2009-02-05
08:30:56 UTC (rev 13481)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/tree/Node.java 2009-02-05
10:15:58 UTC (rev 13482)
@@ -11,6 +11,8 @@
import java.util.Collections;
import java.util.List;
+import org.jboss.tools.jmx.core.IConnectionWrapper;
+
@SuppressWarnings("unchecked")
public abstract class Node implements Comparable {
@@ -49,5 +51,10 @@
}
return getRoot(parent.getParent());
}
+
+ public IConnectionWrapper getConnection() {
+ Root r = getRoot(this);
+ return r.getConnection();
+ }
}
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/JMXUIActivator.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/JMXUIActivator.java 2009-02-05
08:30:56 UTC (rev 13481)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/JMXUIActivator.java 2009-02-05
10:15:58 UTC (rev 13482)
@@ -9,7 +9,6 @@
import javax.management.MBeanServerConnection;
-
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
@@ -17,7 +16,6 @@
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.jboss.tools.jmx.core.DomainWrapper;
import org.jboss.tools.jmx.core.MBeanAttributeInfoWrapper;
import org.jboss.tools.jmx.core.MBeanInfoWrapper;
import org.jboss.tools.jmx.core.MBeanOperationInfoWrapper;
@@ -115,8 +113,6 @@
private void registerAdapters() {
adapterFactory = new JMXAdapterFactory();
Platform.getAdapterManager().registerAdapters(adapterFactory,
- DomainWrapper.class);
- Platform.getAdapterManager().registerAdapters(adapterFactory,
MBeanInfoWrapper.class);
Platform.getAdapterManager().registerAdapters(adapterFactory,
MBeanAttributeInfoWrapper.class);
@@ -126,8 +122,6 @@
private void unregisterAdapters() {
Platform.getAdapterManager().unregisterAdapters(adapterFactory,
- DomainWrapper.class);
- Platform.getAdapterManager().unregisterAdapters(adapterFactory,
MBeanInfoWrapper.class);
Platform.getAdapterManager().unregisterAdapters(adapterFactory,
MBeanAttributeInfoWrapper.class);
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/adapters/JMXAdapterFactory.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/adapters/JMXAdapterFactory.java 2009-02-05
08:30:56 UTC (rev 13481)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/adapters/JMXAdapterFactory.java 2009-02-05
10:15:58 UTC (rev 13482)
@@ -11,7 +11,6 @@
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ui.views.properties.IPropertySource;
-import org.jboss.tools.jmx.core.DomainWrapper;
import org.jboss.tools.jmx.core.MBeanAttributeInfoWrapper;
import org.jboss.tools.jmx.core.MBeanInfoWrapper;
import org.jboss.tools.jmx.core.MBeanOperationInfoWrapper;
@@ -39,10 +38,6 @@
}
private IPropertySource adaptToPropertySource(Object adaptableObject) {
- if (adaptableObject instanceof DomainWrapper) {
- DomainWrapper domain = (DomainWrapper) adaptableObject;
- return new DomainPropertySourceAdapter(domain.getName());
- }
if (adaptableObject instanceof MBeanInfoWrapper) {
MBeanInfoWrapper wrapper = (MBeanInfoWrapper) adaptableObject;
return new MBeanInfoPropertySourceAdapter(wrapper.getObjectName(),
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java 2009-02-05
08:30:56 UTC (rev 13481)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java 2009-02-05
10:15:58 UTC (rev 13482)
@@ -38,6 +38,9 @@
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
+import org.jboss.tools.jmx.core.IConnectionWrapper;
+import org.jboss.tools.jmx.core.IJMXRunnable;
+import org.jboss.tools.jmx.core.JMXException;
import org.jboss.tools.jmx.core.MBeanAttributeInfoWrapper;
import org.jboss.tools.jmx.ui.Messages;
import org.jboss.tools.jmx.ui.extensions.IWritableAttributeHandler;
@@ -67,27 +70,38 @@
public void write(final Object newValue) {
new Thread() {
public void run() {
- try {
- MBeanServerConnection mbsc = wrapper.getMBeanServerConnection();
- String attrName = wrapper.getMBeanAttributeInfo().getName();
- Attribute attr = new Attribute(attrName, newValue);
- mbsc.setAttribute(wrapper.getObjectName(), attr);
- Display.getDefault().asyncExec(new Runnable() { public void run() {
- masterSection.refresh();
- }});
- } catch (final Exception e) {
- Display.getDefault().asyncExec(new Runnable() { public void run() {
- MessageDialog.openError(getManagedForm().getForm().getDisplay()
- .getActiveShell(),
- Messages.AttributeDetailsSection_errorTitle, e
- .getLocalizedMessage());
- }});
- }
+ IConnectionWrapper connection =
wrapper.getMBeanInfoWrapper().getParent().getConnection();
+ try {
+ connection.run(new IJMXRunnable() {
+ public void run(MBeanServerConnection connection)
+ throws Exception {
+ execAttributeUpdate(connection, newValue);
+ } });
+ } catch(JMXException jmxe) {
+ }
}
}.start();
}
};
+ protected void execAttributeUpdate(MBeanServerConnection connection, Object newValue)
{
+ try {
+ String attrName = wrapper.getMBeanAttributeInfo().getName();
+ Attribute attr = new Attribute(attrName, newValue);
+ connection.setAttribute(wrapper.getObjectName(), attr);
+ Display.getDefault().asyncExec(new Runnable() { public void run() {
+ masterSection.refresh();
+ }});
+ } catch (final Exception e) {
+ Display.getDefault().asyncExec(new Runnable() { public void run() {
+ MessageDialog.openError(getManagedForm().getForm().getDisplay()
+ .getActiveShell(),
+ Messages.AttributeDetailsSection_errorTitle, e
+ .getLocalizedMessage());
+ }});
+ }
+ }
+
public AttributeDetails(IFormPart masterSection) {
this.masterSection = masterSection;
}
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/OperationDetails.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/OperationDetails.java 2009-02-05
08:30:56 UTC (rev 13481)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/OperationDetails.java 2009-02-05
10:15:58 UTC (rev 13482)
@@ -35,6 +35,9 @@
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
+import org.jboss.tools.jmx.core.IConnectionWrapper;
+import org.jboss.tools.jmx.core.IJMXRunnable;
+import org.jboss.tools.jmx.core.JMXException;
import org.jboss.tools.jmx.core.MBeanOperationInfoWrapper;
import org.jboss.tools.jmx.ui.JMXUIActivator;
import org.jboss.tools.jmx.ui.Messages;
@@ -194,12 +197,20 @@
}
new Thread() {
public void run() {
- widgetSelected2(strs);
+ IConnectionWrapper connection =
opInfoWrapper.getMBeanInfoWrapper().getParent().getConnection();
+ try {
+ connection.run(new IJMXRunnable() {
+ public void run(MBeanServerConnection connection)
+ throws Exception {
+ widgetSelected2(connection, strs);
+ } });
+ } catch( JMXException jmxe) {
+ }
}
}.start();
}
- protected void widgetSelected2(String[] strs) {
+ protected void widgetSelected2(MBeanServerConnection connection, String[] strs)
{
try {
MBeanParameterInfo[] paramInfos = opInfoWrapper
.getMBeanOperationInfo().getSignature();
@@ -207,8 +218,6 @@
if (textParams != null) {
paramList = MBeanUtils.getParameters(strs, paramInfos);
}
- MBeanServerConnection mbsc = opInfoWrapper
- .getMBeanServerConnection();
ObjectName objectName = opInfoWrapper.getObjectName();
String methodName = opInfoWrapper.getMBeanOperationInfo()
.getName();
@@ -218,10 +227,10 @@
for (int i = 0; i < paramSig.length; i++) {
paramSig[i] = paramInfos[i].getType();
}
- result = mbsc.invoke(objectName, methodName, paramList,
+ result = connection.invoke(objectName, methodName, paramList,
paramSig);
} else {
- result = mbsc.invoke(objectName, methodName, new Object[0],
+ result = connection.invoke(objectName, methodName, new Object[0],
new String[0]);
}
if ("void".equals(opInfoWrapper.getMBeanOperationInfo()
//$NON-NLS-1$