Author: rob.stryker(a)jboss.com
Date: 2008-11-18 19:11:48 -0500 (Tue, 18 Nov 2008)
New Revision: 11873
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JBossServerConnection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JBossServerConnectionProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JMXSafeRunner.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/jmx/
trunk/jmx/plugins/org.jboss.tools.jmx.core/bin/
trunk/jmx/plugins/org.jboss.tools.jmx.ui/bin/
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JMXModel.java
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/JMXException.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/IJMXRunnable.java
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/DefaultConnectionWrapper.java
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/tree/NodeUtils.java
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/tree/ObjectNameNode.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/plugin.xml
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/ActionProvider.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/QueryContribution.java
Log:
JBIDE-2760 - commit with 90%. Rest is bug-fixes and tuning.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2008-11-18
23:36:14 UTC (rev 11872)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2008-11-19
00:11:48 UTC (rev 11873)
@@ -20,7 +20,8 @@
org.eclipse.wst.xml.core,
org.apache.ant,
org.eclipse.jst.server.tomcat.core,
- org.eclipse.wst.web
+ org.eclipse.wst.web,
+ org.jboss.tools.jmx.core;bundle-version="0.2.1"
Eclipse-LazyStart: true
Export-Package: org.jboss.ide.eclipse.as.core,
org.jboss.ide.eclipse.as.core.extensions.descriptors,
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JBossServerConnection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JBossServerConnection.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JBossServerConnection.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -0,0 +1,152 @@
+package org.jboss.ide.eclipse.as.core.extensions.jmx;
+
+import java.io.IOException;
+
+import javax.management.MBeanServerConnection;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerListener;
+import org.eclipse.wst.server.core.ServerEvent;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.tools.jmx.core.ExtensionManager;
+import org.jboss.tools.jmx.core.IConnectionProvider;
+import org.jboss.tools.jmx.core.IConnectionProviderListener;
+import org.jboss.tools.jmx.core.IConnectionWrapper;
+import org.jboss.tools.jmx.core.IJMXRunnable;
+import org.jboss.tools.jmx.core.tree.NodeUtils;
+import org.jboss.tools.jmx.core.tree.Root;
+
+public class JBossServerConnection implements IConnectionWrapper, IServerListener,
IConnectionProviderListener {
+ private IServer server;
+ private Root root;
+ private boolean isConnected;
+ public JBossServerConnection(IServer server) {
+ this.server = server;
+ this.isConnected = false;
+ checkState(); // prime the state
+ ((JBossServerConnectionProvider)getProvider()).addListener(this);
+ server.addServerListener(this);
+ }
+
+ public void connect() throws IOException {
+ // Not supported
+ }
+
+ public void disconnect() throws IOException {
+ // Not supported
+ }
+
+ public IConnectionProvider getProvider() {
+ return ExtensionManager.getProvider(JBossServerConnectionProvider.PROVIDER_ID);
+ }
+
+ public Root getRoot() {
+ return root;
+ }
+
+ public void loadRoot() {
+ if( isConnected()) {
+ // saferunner just adds itself as a concern and then removes, after each call.
+ // This will ensure the classloader does not need to make multiple loads
+ JMXClassLoaderRepository.getDefault().addConcerned(server, this);
+ try {
+ if( root == null ) {
+ root = NodeUtils.createObjectNameTree(this);
+ }
+ } catch( CoreException ce ) {
+ IStatus status = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
ce.getMessage(), ce);
+ JBossServerCorePlugin.getDefault().getLog().log(status);
+ } finally {
+ JMXClassLoaderRepository.getDefault().removeConcerned(server, this);
+ }
+ }
+ }
+
+ public boolean isConnected() {
+ return isConnected;
+ }
+
+ public void run(IJMXRunnable runnable) throws CoreException {
+ // do nothing if the server is down.
+ if( server.getServerState() != IServer.STATE_STARTED )
+ return;
+ JMXSafeRunner.run(server, runnable);
+ }
+
+ public String getName() {
+ return server.getName();
+ }
+
+
+ /* **************
+ * If there's a change in teh server state, then set my connection
+ * state properly. If there's been a change then fire to teh listeners
+ */
+
+ public void serverChanged(ServerEvent event) {
+ int eventKind = event.getKind();
+ IServer server = event.getServer();
+ if ((eventKind & ServerEvent.SERVER_CHANGE) != 0) {
+ // server change event
+ if ((eventKind & ServerEvent.STATE_CHANGE) != 0) {
+ checkState();
+ }
+ }
+ }
+
+ protected void checkState() {
+ if( server.getServerState() == IServer.STATE_STARTED ) {
+ try {
+ JMXSafeRunner.run(server, new IJMXRunnable() {
+ public void run(MBeanServerConnection connection)
+ throws Exception {
+ // Do nothing, just see if the connection worked
+ }
+ });
+ if( !isConnected ) {
+ isConnected = true;
+ ((JBossServerConnectionProvider)getProvider()).fireChanged(JBossServerConnection.this);
+ }
+ } catch( Exception jmxe ) {
+ // I thought i was connected but I'm not.
+ if( isConnected ) {
+ isConnected = false;
+ ((JBossServerConnectionProvider)getProvider()).fireChanged(JBossServerConnection.this);
+ }
+ }
+ } else {
+ root = null;
+ if( isConnected ) {
+ // server is not in STATE_STARTED, but thinks its connected
+ isConnected = false;
+ ((JBossServerConnectionProvider)getProvider()).fireChanged(JBossServerConnection.this);
+ }
+ }
+ }
+
+
+
+ /* *************
+ * The following three methods are just here so that this class
+ * is removed as a listener to the server if it is removed
+ */
+
+ public void connectionAdded(IConnectionWrapper connection) {
+ // ignore
+ }
+
+ public void connectionChanged(IConnectionWrapper connection) {
+ // ignore
+ }
+
+ public void connectionRemoved(IConnectionWrapper connection) {
+ server.removeServerListener(this);
+ }
+
+ public boolean canControl() {
+ return false;
+ }
+}
\ No newline at end of file
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JBossServerConnectionProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JBossServerConnectionProvider.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JBossServerConnectionProvider.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -0,0 +1,182 @@
+package org.jboss.ide.eclipse.as.core.extensions.jmx;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerLifecycleListener;
+import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.tools.jmx.core.ExtensionManager;
+import org.jboss.tools.jmx.core.IConnectionProvider;
+import org.jboss.tools.jmx.core.IConnectionProviderListener;
+import org.jboss.tools.jmx.core.IConnectionWrapper;
+import org.jboss.tools.jmx.core.IJMXRunnable;
+
+public class JBossServerConnectionProvider implements IConnectionProvider,
IServerLifecycleListener {
+ public static final String PROVIDER_ID =
"org.jboss.ide.eclipse.as.core.extensions.jmx.JBossServerConnectionProvider";
//$NON-NLS-1$
+
+ public static JBossServerConnectionProvider getProvider() {
+ return (JBossServerConnectionProvider)ExtensionManager.getProvider(PROVIDER_ID);
+ }
+
+ public static JBossServerConnection getConnection(IServer s) {
+ return (JBossServerConnection)getProvider().findConnection(s);
+ }
+
+ // Run this action on the server.
+ // If the connection doesn't exist, make a new one
+ public static void run(IServer s, IJMXRunnable r) throws CoreException {
+ JBossServerConnection c = getConnection(s);
+ if( c == null )
+ c = getConnection(s);
+ c.run(r);
+ }
+
+
+ private ArrayList<IConnectionProviderListener> listeners =
+ new ArrayList<IConnectionProviderListener>();
+
+ private HashMap<String, JBossServerConnection> idToConnection;
+ public JBossServerConnectionProvider() {
+ ServerCore.addServerLifecycleListener(this);
+ }
+
+ protected boolean belongsHere(IServer server) {
+ return ServerConverter.getJBossServer(server) != null;
+ }
+
+ protected JBossServerConnection createConnection(IServer server) {
+ return new JBossServerConnection(server);
+ }
+
+ public void serverAdded(IServer server) {
+ if( belongsHere(server)) {
+ getConnections();
+ if( !idToConnection.containsKey(server.getId())) {
+ JBossServerConnection connection = createConnection(server);
+ idToConnection.put(server.getId(), connection);
+ }
+ fireAdded(idToConnection.get(server.getId()));
+ }
+ }
+
+ public void serverChanged(IServer server) {
+ if( belongsHere(server)) {
+ getConnections();
+ if( !idToConnection.containsKey(server.getId())) {
+ JBossServerConnection connection = createConnection(server);
+ idToConnection.put(server.getId(), connection);
+ }
+ fireAdded(idToConnection.get(server.getId()));
+ }
+ }
+
+ public void serverRemoved(IServer server) {
+ if( belongsHere(server)) {
+ JBossServerConnection connection;
+ if( idToConnection != null ) {
+ connection = idToConnection.get(server.getId());
+ if( connection != null ) {
+ idToConnection.remove(server.getId());
+ fireRemoved(connection);
+ }
+ } else {
+ // hasn't been initialized yet
+ getConnections();
+
+ // but now its missing from the collection, so make one up
+ fireRemoved(createConnection(server));
+ }
+ }
+ }
+
+ public IConnectionWrapper findConnection(IServer s) {
+ return idToConnection.get(s.getId());
+ }
+
+ public IConnectionWrapper[] getConnections() {
+ // do it all on demand right now
+ if( idToConnection == null ) {
+ // load them all
+ idToConnection = new HashMap<String, JBossServerConnection>();
+ IServer[] allServers = ServerCore.getServers();
+ JBossServerConnection c;
+ for( int i = 0; i < allServers.length; i++ ) {
+ if( belongsHere(allServers[i])) {
+ c = createConnection(allServers[i]);
+ if( c != null )
+ idToConnection.put(allServers[i].getId(), c);
+ }
+ }
+ }
+ ArrayList<JBossServerConnection> list = new
ArrayList<JBossServerConnection>();
+ list.addAll(idToConnection.values());
+ return list.toArray(new JBossServerConnection[list.size()]);
+ }
+
+ public String getName(IConnectionWrapper wrapper) {
+ if( wrapper instanceof JBossServerConnection) {
+ return ((JBossServerConnection)wrapper).getName();
+ }
+ return null;
+ }
+
+ public String getId() {
+ return PROVIDER_ID;
+ }
+
+ public void addListener(IConnectionProviderListener listener) {
+ if( !listeners.contains(listener))
+ listeners.add(listener);
+ }
+
+ public void removeListener(IConnectionProviderListener listener) {
+ listeners.remove(listener);
+ }
+
+ void fireAdded(IConnectionWrapper wrapper) {
+ for(Iterator<IConnectionProviderListener> i = listeners.iterator();
i.hasNext();)
+ try {
+ i.next().connectionAdded(wrapper);
+ } catch(RuntimeException re) {}
+ }
+
+ void fireChanged(IConnectionWrapper wrapper) {
+ for(Iterator<IConnectionProviderListener> i = listeners.iterator();
i.hasNext();)
+ try {
+ i.next().connectionChanged(wrapper);
+ } catch(RuntimeException re) {}
+ }
+
+ void fireRemoved(IConnectionWrapper wrapper) {
+ for(Iterator<IConnectionProviderListener> i = listeners.iterator();
i.hasNext();)
+ try {
+ i.next().connectionRemoved(wrapper);
+ } catch(RuntimeException re) {}
+ }
+ public boolean canCreate() {
+ return false;
+ }
+
+ @SuppressWarnings(value={"unchecked"})
+ public IConnectionWrapper createConnection(Map map) throws CoreException {
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Not Supported", null));
+ }
+
+ public void addConnection(IConnectionWrapper connection) {
+ // Not Supported
+ }
+ public void removeConnection(IConnectionWrapper connection) {
+ // Not Supported
+ }
+ public boolean canDelete(IConnectionWrapper wrapper) {
+ return false;
+ }
+}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JMXModel.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JMXModel.java 2008-11-18
23:36:14 UTC (rev 11872)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JMXModel.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -1,475 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.core.extensions.jmx;
-
-import java.io.IOException;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.naming.InitialContext;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-
-/**
- * Model and objects related to JMX
- * @author rob.stryker(a)redhat.com
- *
- */
-public class JMXModel {
- /* Singleton */
- protected static JMXModel instance;
- public static JMXModel getDefault() {
- if( instance == null )
- instance = new JMXModel();
- return instance;
- }
-
-
- protected HashMap<String, JMXModelRoot> root;
- /* constructor */
- protected JMXModel() {
- root = new HashMap<String, JMXModelRoot>();
- }
-
- /**
- * Get the Model Root for one particular server
- * @param server
- * @return that server's model
- */
- public JMXModelRoot getModel(IServer server) {
- if (root.get(server.getId()) == null) {
- JMXModelRoot serverRoot = new JMXModelRoot(server);
- root.put(server.getId(), serverRoot);
- }
- return root.get(server.getId());
- }
-
- /**
- * Clear the server's model
- * @param server
- */
- public void clearModel(IServer server) {
- root.remove(server.getId());
- }
-
- /**
- * The model for one server
- */
- public static class JMXModelRoot {
- protected IServer server;
- protected JMXDomain[] domains = null;
- protected JMXException exception = null;
-
- public JMXModelRoot(IServer server) {
- this.server = server;
- }
-
- public JMXDomain[] getDomains() {
- return domains;
- }
-
- public JMXException getException() {
- return exception;
- }
-
- /**
- * Lazily load the domains
- */
- public void loadDomains() {
- exception = null;
- JMXRunnable run = new JMXRunnable() {
- public void run(MBeanServerConnection connection) {
- try {
- String[] domainNames = connection.getDomains();
- JMXDomain[] domains = new JMXDomain[domainNames.length];
- for (int i = 0; i < domainNames.length; i++) {
- domains[i] = new JMXDomain(server, domainNames[i]);
- }
- JMXModelRoot.this.domains = domains;
- } catch (IOException ioe) {
- exception = new JMXException(ioe);
- }
- }
- };
- JMXSafeRunner.run(server, run);
- }
- }
-
- /**
- * A JMX Domain
- */
- public static class JMXDomain {
- protected String name;
- protected IServer server;
- protected JMXBean[] mbeans = null;
- protected JMXException exception = null;
-
- public JMXDomain(IServer server, String name) {
- this.server = server;
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public JMXException getException() {
- return exception;
- }
-
- public JMXBean[] getBeans() {
- return mbeans;
- }
-
- public void resetChildren() {
- mbeans = null;
- exception = null;
- }
-
- /**
- * Lazily load the beans for this domain
- */
- public void loadBeans() {
- exception = null;
- JMXRunnable run = new JMXRunnable() {
- public void run(MBeanServerConnection connection) {
- try {
- Set<?> s = connection.queryMBeans(new ObjectName(name
- + ":*"), null);
- Iterator<?> i = s.iterator();
- JMXBean[] beans = new JMXBean[s.size()];
- int count = 0;
- while (i.hasNext()) {
- ObjectInstance tmp = (ObjectInstance) i.next();
- beans[count++] = new JMXBean(server, tmp);
- }
- mbeans = beans;
- } catch (MalformedObjectNameException mone) {
- exception = new JMXException(mone);
- } catch (IOException ioe) {
- exception = new JMXException(ioe);
- }
- }
- };
- JMXSafeRunner.run(server, run);
- }
- }
-
- /**
- * The JMX Bean Object
- */
- public static class JMXBean {
- protected String domain;
- protected String name;
- protected String clazz;
- protected IServer server;
- protected ObjectName objectName;
- protected MBeanInfo info;
- protected WrappedMBeanOperationInfo[] operations;
- protected WrappedMBeanAttributeInfo[] attributes;
-
- protected JMXException exception;
-
- public JMXBean(IServer server, ObjectInstance instance) {
- this.server = server;
- this.domain = instance.getObjectName().getDomain();
- this.clazz = instance.getClassName();
- this.objectName = instance.getObjectName();
- this.name = instance.getObjectName().getCanonicalName();
- }
-
- public String getDomain() {
- return domain;
- }
-
- public String getName() {
- return name;
- }
-
- public String getClazz() {
- return clazz;
- }
-
- public IServer getServer() {
- return server;
- }
-
- public void resetChildren() {
- info = null;
- exception = null;
- }
-
- public WrappedMBeanOperationInfo[] getOperations() {
- return operations;
- }
-
-
- public WrappedMBeanAttributeInfo[] getAttributes() {
- return attributes;
- }
-
- public JMXException getException() {
- return this.exception;
- }
-
- /**
- * Load the child operations and attributes
- */
- public void loadInfo() {
- exception = null;
- JMXRunnable run = new JMXRunnable() {
- public void run(MBeanServerConnection connection) {
- Exception tmp = null;
- try {
- info = connection.getMBeanInfo(new ObjectName(name));
- loadAttributes(connection);
- loadOperations(connection);
- } catch (InstanceNotFoundException e) {
- tmp = e;
- } catch (IntrospectionException e) {
- tmp = e;
- } catch (MalformedObjectNameException e) {
- tmp = e;
- } catch (ReflectionException e) {
- tmp = e;
- } catch (NullPointerException e) {
- tmp = e;
- } catch (IOException e) {
- tmp = e;
- } catch( UndeclaredThrowableException e) {
- tmp = e;
- }
- if (tmp != null) {
- exception = new JMXException(tmp);
- }
- }
- };
- JMXSafeRunner.run(server, run);
- }
-
-
- protected void loadOperations(MBeanServerConnection connection) {
- if (info == null)
- return;
- MBeanOperationInfo[] ops = info.getOperations();
- WrappedMBeanOperationInfo[] wrappedOps = new WrappedMBeanOperationInfo[ops.length];
- for (int i = 0; i < ops.length; i++) {
- wrappedOps[i] = new WrappedMBeanOperationInfo(server, this,
- ops[i]);
- }
- operations = wrappedOps;
- }
-
- protected void loadAttributes(MBeanServerConnection connection) {
- if (info == null)
- return;
- MBeanAttributeInfo[] atts = info.getAttributes();
- ArrayList wrapped = new ArrayList();
- WrappedMBeanAttributeInfo tmp;
- for (int i = 0; i < atts.length; i++) {
- try {
- tmp = new WrappedMBeanAttributeInfo(server, this, atts[i]);
- tmp.loadValue(connection);
- wrapped.add(tmp);
- } catch( Exception e ) {
- // some attributes may not load because the result is not serializable.
- // no need to report every error
- }
- }
- attributes = (WrappedMBeanAttributeInfo[]) wrapped.toArray(new
WrappedMBeanAttributeInfo[wrapped.size()]);
- }
-
- public ObjectName getObjectName() {
- return objectName;
- }
-
-
-
- }
-
- public static class WrappedMBeanOperationInfo {
- protected IServer server;
- protected JMXBean bean;
- protected MBeanOperationInfo info;
- protected WrappedMBeanOperationParameter[] params;
-
- public WrappedMBeanOperationInfo(IServer server, JMXBean bean,
- MBeanOperationInfo info) {
- this.server = server;
- this.bean = bean;
- this.info = info;
- }
- public MBeanOperationInfo getInfo() {
- return info;
- }
- public JMXBean getBean() {
- return bean;
- }
-
- public WrappedMBeanOperationParameter[] getParameters() {
- if( params == null ) {
- MBeanParameterInfo[] paramInfo = info.getSignature();
- params = new WrappedMBeanOperationParameter[paramInfo.length];
- for( int i = 0; i < paramInfo.length; i++ ) {
- params[i] = new WrappedMBeanOperationParameter(this, paramInfo[i]);
- }
- }
- return params;
- }
-
- public void clearParamValues() {
- if( params != null ) {
- for( int i = 0; i < params.length; i++ )
- params[i].setValue(null);
- }
- }
- }
-
- public static class WrappedMBeanOperationParameter {
- protected WrappedMBeanOperationInfo operation;
- protected MBeanParameterInfo parameterInfo;
- protected Object value;
-
- public WrappedMBeanOperationParameter(WrappedMBeanOperationInfo operation,
MBeanParameterInfo param) {
- this.parameterInfo = param;
- this.operation = operation;
- }
-
- public IServer getServer() { return operation.server; }
- public JMXBean getBean() { return operation.bean; }
-
- public Object getValue() { return value; }
- public void setValue(Object o) { this.value = o; }
- public MBeanParameterInfo getInfo() { return this.parameterInfo; }
- }
-
- public static class WrappedMBeanAttributeInfo {
- protected IServer server;
- protected JMXBean bean;
- protected MBeanAttributeInfo info;
- protected Object value;
-
- public WrappedMBeanAttributeInfo(IServer server, JMXBean bean,
- MBeanAttributeInfo info) {
- this.server = server;
- this.bean = bean;
- this.info = info;
- }
- public MBeanAttributeInfo getInfo() {
- return info;
- }
- public JMXBean getBean() {
- return bean;
- }
- public void loadValue(MBeanServerConnection connection) throws Exception {
- value = connection.getAttribute(
- new ObjectName(bean.getName()), info.getName());
- }
- public Object getValue() {
- return value;
- }
- }
-
-
- public static class JMXException extends Exception {
- private static final long serialVersionUID = 1L;
- private Exception exception;
-
- public JMXException(Exception e) {
- this.exception = e;
- }
-
- public Exception getException() {
- return this.exception;
- }
- }
-
- public interface JMXRunnable {
- public void run(MBeanServerConnection connection) throws Exception;
- }
-
- public static class JMXSafeRunner {
- public static void run(IServer s, JMXRunnable r) {
- // do nothing if the server is down.
- if( s.getServerState() != IServer.STATE_STARTED ) return;
-
- JMXClassLoaderRepository.getDefault().addConcerned(s, r);
- ClassLoader currentLoader = Thread.currentThread()
- .getContextClassLoader();
- ClassLoader newLoader = JMXClassLoaderRepository.getDefault()
- .getClassLoader(s);
- Thread.currentThread().setContextClassLoader(newLoader);
- InitialContext ic = null;
- try {
- JMXUtil.setCredentials(s);
- Properties p = JMXUtil.getDefaultProperties(s);
- ic = new InitialContext(p);
- Object obj = ic.lookup("jmx/invoker/RMIAdaptor");
- ic.close();
- if (obj instanceof MBeanServerConnection) {
- MBeanServerConnection connection = (MBeanServerConnection) obj;
- r.run(connection);
- }
- } catch (Exception e) {
- // only if the server *IS* started should we log the error
- if( s.getServerState() == IServer.STATE_STARTED ) {
- JBossServerCorePlugin.getDefault().getLog().log(
- new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- "Error while running JMX-safe code", e));
- }
- }
- JMXClassLoaderRepository.getDefault().removeConcerned(s, r);
- Thread.currentThread().setContextClassLoader(currentLoader);
- }
- }
-
- public static class JMXAttributesWrapper {
- protected JMXBean bean;
-
- public JMXAttributesWrapper(JMXBean bean) {
- this.bean = bean;
- }
-
- public JMXBean getBean() {
- return bean;
- }
- }
-
-}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JMXSafeRunner.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JMXSafeRunner.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/jmx/JMXSafeRunner.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -0,0 +1,68 @@
+package org.jboss.ide.eclipse.as.core.extensions.jmx;
+
+import java.util.Properties;
+
+import javax.management.MBeanServerConnection;
+import javax.naming.InitialContext;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.tools.jmx.core.IJMXRunnable;
+
+public class JMXSafeRunner {
+ private String user, pass;
+ private IServer server;
+
+ public JMXSafeRunner(IServer s) {
+ this.server = s;
+ String user = ServerConverter.getJBossServer(s).getUsername();
+ String pass = ServerConverter.getJBossServer(s).getPassword();
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+ public void setPass(String pass) {
+ this.pass = pass;
+ }
+
+ public void run(IJMXRunnable r) throws CoreException {
+ run(server,r,user,pass);
+ }
+
+ public static void run(IServer s, IJMXRunnable r) throws CoreException {
+ String user = ServerConverter.getJBossServer(s).getUsername();
+ String pass = ServerConverter.getJBossServer(s).getPassword();
+ run(s,r,user,pass);
+ }
+
+ public static void run(IServer s, IJMXRunnable r, String user, String pass) throws
CoreException {
+ JMXClassLoaderRepository.getDefault().addConcerned(s, r);
+ ClassLoader currentLoader = Thread.currentThread()
+ .getContextClassLoader();
+ ClassLoader newLoader = JMXClassLoaderRepository.getDefault()
+ .getClassLoader(s);
+ Thread.currentThread().setContextClassLoader(newLoader);
+ InitialContext ic = null;
+ try {
+ JMXUtil.setCredentials(s,user,pass);
+ Properties p = JMXUtil.getDefaultProperties(s);
+ ic = new InitialContext(p);
+ Object obj = ic.lookup("jmx/invoker/RMIAdaptor"); //$NON-NLS-1$
+ ic.close();
+ if (obj instanceof MBeanServerConnection) {
+ MBeanServerConnection connection = (MBeanServerConnection) obj;
+ r.run(connection);
+ }
+ } catch( Exception e ) {
+ throw new CoreException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
e.getMessage(), e));
+ } finally {
+ JMXClassLoaderRepository.getDefault().removeConcerned(s, r);
+ Thread.currentThread().setContextClassLoader(currentLoader);
+ }
+ }
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java 2008-11-18
23:36:14 UTC (rev 11872)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/polling/JMXPoller.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -21,31 +21,27 @@
*/
package org.jboss.ide.eclipse.as.core.extensions.polling;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
-import javax.management.MBeanException;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
-import javax.management.OperationsException;
-import javax.management.ReflectionException;
import javax.naming.CommunicationException;
-import javax.naming.InitialContext;
import javax.naming.NamingException;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXClassLoaderRepository;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXUtil;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXUtil.CredentialException;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXSafeRunner;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import org.jboss.ide.eclipse.as.core.server.internal.PollThread;
import org.jboss.ide.eclipse.as.core.server.internal.ServerStatePollerType;
+import org.jboss.tools.jmx.core.IJMXRunnable;
/**
* A poller dedicated to server startup, checks via JMX
@@ -78,6 +74,9 @@
private RequiresInfoException requiresInfoException = null;
private Properties requiredPropertiesReturned = null;
+ private JMXPollerRunnable runnable;
+ private JMXSafeRunner runner;
+
public void beginPolling(IServer server, boolean expectedState,
PollThread pt) {
ceFound = nnfeFound = startingFound = canceled = done = false;
@@ -85,119 +84,91 @@
launchJMXPoller();
}
+ private class JMXPollerRunnable implements IJMXRunnable {
+ public void run(MBeanServerConnection connection) throws Exception {
+ Object attInfo = connection.getAttribute(
+ new ObjectName("jboss.system:type=Server"),
+ "Started");
+ boolean b = ((Boolean) attInfo).booleanValue();
+ started = b ? STATE_STARTED : STATE_TRANSITION;
+ done = b;
+ if( !startingFound ) {
+ startingFound = true;
+ IStatus s = new Status(IStatus.INFO, JBossServerCorePlugin.PLUGIN_ID, CODE|started,
"Server is starting", null);
+ log(s);
+ }
+ }
+ }
+
private class PollerRunnable implements Runnable {
public void run() {
JMXClassLoaderRepository.getDefault().addConcerned(server, this);
- ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader twiddleLoader =
JMXClassLoaderRepository.getDefault().getClassLoader(server);
- if( pollingException != null ) {done = true; return;}
- if (twiddleLoader != null) {
+ runnable = new JMXPollerRunnable();
+ runner = new JMXSafeRunner(server);
+ while( !done && !canceled) {
+ try {
+ runner.run(runnable);
+ } catch(CoreException ce) {
+ handleException(ce.getCause());
+ }
- Thread.currentThread().setContextClassLoader(twiddleLoader);
- Properties props = JMXUtil.getDefaultProperties(server);
- setCredentials();
- if( pollingException != null ) {done = true; return;}
-
- Exception failingException = null;
- while (!done && !canceled) {
- InitialContext ic;
- try {
- ic = new InitialContext(props);
- Object obj = ic.lookup("jmx/invoker/RMIAdaptor");
- ic.close();
- if (obj instanceof MBeanServerConnection) {
- MBeanServerConnection connection = (MBeanServerConnection) obj;
- Object attInfo = connection.getAttribute(
- new ObjectName("jboss.system:type=Server"),
- "Started");
- boolean b = ((Boolean) attInfo).booleanValue();
- started = b ? STATE_STARTED : STATE_TRANSITION;
- done = b;
- if( !startingFound ) {
- startingFound = true;
- IStatus s = new Status(IStatus.INFO, JBossServerCorePlugin.PLUGIN_ID,
CODE|started, "Server is starting", null);
- log(s);
- }
- }
- } catch (SecurityException se) {
- synchronized(this) {
- if( !waitingForCredentials ) {
- waitingForCredentials = true;
- requiresInfoException = new PollingSecurityException(
- "Security Exception: " + se.getMessage());
- } else {
- // we're waiting. are they back yet?
- if( requiredPropertiesReturned != null ) {
- requiresInfoException = null;
- String user, pass;
- user = (String)requiredPropertiesReturned.get(REQUIRED_USER);
- pass = (String)requiredPropertiesReturned.get(REQUIRED_PASS);
- requiredPropertiesReturned = null;
- setCredentials(user, pass);
- waitingForCredentials = false;
- }
- }
- }
- } catch (CommunicationException ce) {
- started = STATE_STOPPED;
- if( !ceFound ) {
- ceFound = true;
- IStatus s = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
CODE|started, ce.getMessage(), ce);
- log(s);
- }
- } catch (NamingException nnfe) {
- started = STATE_STOPPED;
- if( !nnfeFound ) {
- nnfeFound = true;
- IStatus s = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
CODE|started, nnfe.getMessage(), nnfe);
- log(s);
- }
- } catch( OperationsException e ) {
- failingException = e;
- } catch (MBeanException e) {
- failingException = e;
- } catch (ReflectionException e) {
- failingException = e;
- } catch (NullPointerException e) {
- failingException = e;
- } catch (IOException e) {
- failingException = e;
- }
-
- if( failingException != null ) {
- pollingException = new PollingException(failingException.getMessage());
- done = true;
- }
-
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- }
- } // end while
+ try { Thread.sleep(500);}
+ catch (InterruptedException e) {}
}
-
- Thread.currentThread().setContextClassLoader(currentLoader);
JMXClassLoaderRepository.getDefault().removeConcerned(server, this);
}
- protected void setCredentials() {
- try {
- JMXUtil.setCredentials(server);
- } catch( CredentialException ce ) {
- pollingException = new PollingException(ce.getWrapped().getMessage());
+ protected void handleException(Throwable t) {
+ if( t instanceof SecurityException ) {
+ synchronized(this) {
+ if( !waitingForCredentials ) {
+ waitingForCredentials = true;
+ requiresInfoException = new PollingSecurityException(
+ "Security Exception: " + t.getMessage());
+ } else {
+ // we're waiting. are they back yet?
+ if( requiredPropertiesReturned != null ) {
+ requiresInfoException = null;
+ String user, pass;
+ user = (String)requiredPropertiesReturned.get(REQUIRED_USER);
+ pass = (String)requiredPropertiesReturned.get(REQUIRED_PASS);
+ requiredPropertiesReturned = null;
+ runner.setUser(user);
+ runner.setPass(pass);
+ waitingForCredentials = false;
+ }
+ }
+ }
+ return;
}
- }
+
+ if( t instanceof CommunicationException ) {
+ started = STATE_STOPPED;
+ if( !ceFound ) {
+ ceFound = true;
+ IStatus s = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
CODE|started, t.getMessage(), t);
+ log(s);
+ }
+ return;
+ }
+
+ if( t instanceof NamingException ) {
+ started = STATE_STOPPED;
+ if( !nnfeFound ) {
+ nnfeFound = true;
+ IStatus s = new Status(IStatus.WARNING, JBossServerCorePlugin.PLUGIN_ID,
CODE|started, t.getMessage(), t);
+ log(s);
+ }
+ return;
+ }
- protected void setCredentials(String user, String pass) {
- try {
- JMXUtil.setCredentials(server, user, pass);
- } catch( CredentialException ce ) {
- pollingException = new PollingException(ce.getWrapped().getMessage());
+ if( t != null ) {
+ pollingException = new PollingException(t.getMessage());
+ done = true;
}
}
}
-
private void launchJMXPoller() {
PollerRunnable run = new PollerRunnable();
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2008-11-18
23:36:14 UTC (rev 11872)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/JBossServerBehavior.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -37,11 +37,11 @@
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.events.ServerLogger;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXRunnable;
-import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXSafeRunner;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JBossServerConnectionProvider;
import org.jboss.ide.eclipse.as.core.server.IServerStatePoller;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.server.internal.launch.StopLaunchConfiguration;
+import org.jboss.tools.jmx.core.IJMXRunnable;
/**
*
@@ -208,23 +208,27 @@
}
protected void suspendDeployment() {
- JMXRunnable r = new JMXRunnable() {
+ IJMXRunnable r = new IJMXRunnable() {
public void run(MBeanServerConnection connection) throws Exception {
ObjectName name = new
ObjectName("jboss.deployment:flavor=URL,type=DeploymentScanner");
connection.invoke(name, "stop", new Object[] { }, new String[] {});
}
};
- JMXSafeRunner.run(getServer(), r);
+ try {
+ JBossServerConnectionProvider.run(getServer(), r);
+ } catch( CoreException ce) {} // ignore
}
protected void resumeDeployment() {
- JMXRunnable r = new JMXRunnable() {
+ IJMXRunnable r = new IJMXRunnable() {
public void run(MBeanServerConnection connection) throws Exception {
ObjectName name = new
ObjectName("jboss.deployment:flavor=URL,type=DeploymentScanner");
connection.invoke(name, "start", new Object[] { }, new String[] {});
}
};
- JMXSafeRunner.run(getServer(), r);
+ try {
+ JBossServerConnectionProvider.run(getServer(), r);
+ } catch( CoreException ce) {} // ignore
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2008-11-18 23:36:14 UTC (rev
11872)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2008-11-19 00:11:48 UTC (rev
11873)
@@ -569,4 +569,10 @@
priority="0">
</publisher>
</extension>
+ <extension
+ point="org.jboss.tools.jmx.core.MBeanServerConnectionProvider">
+ <connectionProvider
+
class="org.jboss.ide.eclipse.as.core.extensions.jmx.JBossServerConnectionProvider">
+ </connectionProvider>
+ </extension>
</plugin>
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java 2008-11-18
23:36:14 UTC (rev 11872)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/ServerLogView.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -21,6 +21,7 @@
public void createPartControl(Composite parent) {
super.createPartControl(parent);
+ Platform.removeLogListener(this);
setLogFile(ServerLogger.getDefault().getServerLogFile(null));
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-11-18 23:36:14 UTC (rev
11872)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-11-19 00:11:48 UTC (rev
11873)
@@ -476,6 +476,17 @@
</decorator>
</extension>
+ <!-- JMX Stuff -->
+ <extension
+ point="org.jboss.tools.jmx.ui.providerUI">
+ <providerUI
+ icon="icons/jboss.gif"
+
id="org.jboss.ide.eclipse.as.core.extensions.jmx.JBossServerConnectionProvider"
+ name="JBoss Server">
+ <wizardPage
+
class="org.jboss.tools.jmx.ui.internal.wizards.DefaultConnectionWizardPage">
+ </wizardPage>
+ </providerUI>
+ </extension>
-
</plugin>
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/IJMXRunnable.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/IJMXRunnable.java 2008-11-18
23:36:14 UTC (rev 11872)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/IJMXRunnable.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -17,5 +17,5 @@
*/
public interface IJMXRunnable {
public void run(MBeanServerConnection connection)
- throws JMXException;
+ throws Exception;
}
Deleted:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/JMXException.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/JMXException.java 2008-11-18
23:36:14 UTC (rev 11872)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/JMXException.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -1,19 +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;
-
-/**
- * An exception occurring during a JMX query
- */
-public class JMXException extends Exception {
- private static final long serialVersionUID = 1L;
-
- public JMXException(Exception e) {
- super(e);
- }
-}
\ No newline at end of file
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/DefaultConnectionWrapper.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/DefaultConnectionWrapper.java 2008-11-18
23:36:14 UTC (rev 11872)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/providers/DefaultConnectionWrapper.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -20,7 +20,6 @@
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -30,7 +29,6 @@
import org.jboss.tools.jmx.core.IJMXRunnable;
import org.jboss.tools.jmx.core.JMXActivator;
import org.jboss.tools.jmx.core.JMXCoreMessages;
-import org.jboss.tools.jmx.core.JMXException;
import org.jboss.tools.jmx.core.tree.NodeUtils;
import org.jboss.tools.jmx.core.tree.Root;
@@ -116,8 +114,8 @@
public void run(IJMXRunnable runnable) throws CoreException {
try {
runnable.run(connection);
- } catch( JMXException ce ) {
- IStatus s = new Status(IStatus.ERROR, JMXActivator.PLUGIN_ID,
JMXCoreMessages.DefaultConnection_ErrorRunningJMXCode, ce);
+ } catch( Exception e ) {
+ IStatus s = new Status(IStatus.ERROR, JMXActivator.PLUGIN_ID,
JMXCoreMessages.DefaultConnection_ErrorRunningJMXCode, e);
throw new CoreException(s);
}
}
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/tree/NodeUtils.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/tree/NodeUtils.java 2008-11-18
23:36:14 UTC (rev 11872)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/tree/NodeUtils.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -7,20 +7,16 @@
*******************************************************************************/
package org.jboss.tools.jmx.core.tree;
-import java.io.IOException;
import java.util.Iterator;
import java.util.Set;
import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.jboss.tools.jmx.core.IConnectionWrapper;
import org.jboss.tools.jmx.core.IJMXRunnable;
-import org.jboss.tools.jmx.core.JMXException;
public class NodeUtils {
@@ -50,20 +46,14 @@
throws CoreException {
final Root[] _root = new Root[1];
connectionWrapper.run(new IJMXRunnable() {
- public void run(MBeanServerConnection connection) throws JMXException {
- try {
- Set beanInfo = connection.queryNames(new ObjectName("*:*"), null);
//$NON-NLS-1$
- _root[0] = NodeBuilder.createRoot(connectionWrapper);
- Iterator iter = beanInfo.iterator();
- while (iter.hasNext()) {
- ObjectName on = (ObjectName) iter.next();
- NodeBuilder.addToTree(_root[0], on);
- }
- } catch( IOException ioe ) {
- // TODO throw coreexception
- } catch( MalformedObjectNameException mone) {
- // TODO throw coreexception
- }
+ public void run(MBeanServerConnection connection) throws Exception {
+ Set beanInfo = connection.queryNames(new ObjectName("*:*"), null);
//$NON-NLS-1$
+ _root[0] = NodeBuilder.createRoot(connectionWrapper);
+ Iterator iter = beanInfo.iterator();
+ while (iter.hasNext()) {
+ ObjectName on = (ObjectName) iter.next();
+ NodeBuilder.addToTree(_root[0], on);
+ }
}
});
return _root[0];
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/tree/ObjectNameNode.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/tree/ObjectNameNode.java 2008-11-18
23:36:14 UTC (rev 11872)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.core/src/org/jboss/tools/jmx/core/tree/ObjectNameNode.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -7,19 +7,12 @@
*******************************************************************************/
package org.jboss.tools.jmx.core.tree;
-import java.io.IOException;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
import org.eclipse.core.runtime.CoreException;
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.MBeanInfoWrapper;
public class ObjectNameNode extends PropertyNode {
@@ -37,22 +30,8 @@
final ObjectName on2 = on;
try {
connectionWrapper.run(new IJMXRunnable() {
- public void run(MBeanServerConnection mbsc) throws JMXException {
- try {
- array[0] = new MBeanInfoWrapper(on2, mbsc.getMBeanInfo(on2), mbsc);
- } catch (InstanceNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IntrospectionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ReflectionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ public void run(MBeanServerConnection mbsc) throws Exception {
+ array[0] = new MBeanInfoWrapper(on2, mbsc.getMBeanInfo(on2), mbsc);
}
});
} catch( CoreException ce ) {
Modified: trunk/jmx/plugins/org.jboss.tools.jmx.ui/plugin.xml
===================================================================
--- trunk/jmx/plugins/org.jboss.tools.jmx.ui/plugin.xml 2008-11-18 23:36:14 UTC (rev
11872)
+++ trunk/jmx/plugins/org.jboss.tools.jmx.ui/plugin.xml 2008-11-19 00:11:48 UTC (rev
11873)
@@ -14,7 +14,7 @@
<view
category="org.jboss.tools.jmx.ui.views"
class="org.jboss.tools.jmx.ui.internal.views.navigator.Navigator"
- icon="icons/sample.gif"
+ icon="icons/full/obj16/jmeth_obj.gif"
id="org.jboss.tools.jmx.ui.internal.views.navigator.MBeanExplorer"
name="%MBeanExplorer.name"
restorable="true">
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/ActionProvider.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/ActionProvider.java 2008-11-18
23:36:14 UTC (rev 11872)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/ActionProvider.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -55,7 +55,7 @@
public void fillContextMenu(IMenuManager menu) {
IConnectionWrapper[] connections = getWrappersFromSelection();
- if( connections != null ) {
+ if( connections != null && connections.length > 0) {
if( !anyConnected(connections) && allControlable(connections))
menu.add(new MBeanServerConnectAction(connections));
else if( allControlable(connections))
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/QueryContribution.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/QueryContribution.java 2008-11-18
23:36:14 UTC (rev 11872)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/views/navigator/QueryContribution.java 2008-11-19
00:11:48 UTC (rev 11873)
@@ -13,11 +13,11 @@
import java.util.HashMap;
import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Display;
public class QueryContribution {
@@ -54,6 +54,7 @@
private HashMap<Object, Boolean> cache = new HashMap<Object, Boolean>();
private Navigator navigator;
private boolean requiresRefine;
+ private RefineThread refineThread = null;
public QueryContribution(final Navigator navigator) {
this.navigator = navigator;
map.put(navigator.getCommonViewer(), this);
@@ -73,60 +74,83 @@
} else if(neww.startsWith(old) && !neww.equals(old)) {
requiresRefine = true;
}
- cacheEntry(requiresRefine,
(ITreeContentProvider)navigator.getCommonViewer().getContentProvider());
- navigator.getCommonViewer().refresh();
+ if( refineThread != null )
+ refineThread.cancel();
+ refineThread = new RefineThread();
+ refineThread.start();
}
});
}
- protected void clearCache() {
- cache = new HashMap<Object,Boolean>();
- requiresRefine = false;
- }
-
- protected void cacheEntry(boolean refine, ITreeContentProvider provider) {
- Object[] elements = provider.getElements(navigator.getCommonViewer().getInput());
- for( int i = 0; i < elements.length; i++ )
- cache(elements[i], refine, provider);
- }
- protected boolean cache(Object o, boolean refine, ITreeContentProvider provider) {
- if( !refine ) {
- if( cache.get(o) != null ) {
- return cache.get(o).booleanValue();
- }
+ protected class RefineThread extends Thread {
+ private boolean canceled = false;
+ public void run() {
+ cacheEntry(requiresRefine,
(ITreeContentProvider)navigator.getCommonViewer().getContentProvider());
+ refineThread = null;
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ navigator.getCommonViewer().refresh();
+ }
+ } );
}
- // If I match, all my children and grandchildren must match
- String elementAsString = MBeanExplorerLabelProvider.getText2(o);
- if( elementAsString.contains(filterText)) {
- recurseTrue(o, provider);
- return true;
+ public void cancel() {
+ canceled = true;
}
+
+ protected void cacheEntry(boolean refine, ITreeContentProvider provider) {
+ Object[] elements = provider.getElements(navigator.getCommonViewer().getInput());
+ for( int i = 0; i < elements.length; i++ )
+ if( !canceled )
+ cache(elements[i], refine, provider);
+ }
- // if I don't match, then if ANY of my children match, I also match
- boolean belongs = false;
- Object tmp;
- Object[] children = provider.getChildren(o);
- for( int i = 0; i < children.length; i++ ) {
- tmp = cache.get(children[i]);
- if( !refine || (tmp != null && ((Boolean)tmp).booleanValue())) {
- belongs |= cache(children[i], refine, provider);
+ protected boolean cache(Object o, boolean refine, ITreeContentProvider provider) {
+ if( !refine ) {
+ if( cache.get(o) != null ) {
+ return cache.get(o).booleanValue();
+ }
}
+
+ // If I match, all my children and grandchildren must match
+ String elementAsString = MBeanExplorerLabelProvider.getText2(o);
+ if( elementAsString.contains(filterText)) {
+ recurseTrue(o, provider);
+ return true;
+ }
+
+ // if I don't match, then if ANY of my children match, I also match
+ boolean belongs = false;
+ Object tmp;
+ Object[] children = provider.getChildren(o);
+ for( int i = 0; i < children.length; i++ ) {
+ if( !canceled ) {
+ tmp = cache.get(children[i]);
+ if( !refine || (tmp != null && ((Boolean)tmp).booleanValue())) {
+ belongs |= cache(children[i], refine, provider);
+ }
+ }
+ }
+ cache.put(o, new Boolean(canceled || belongs));
+ return belongs;
}
- cache.put(o, new Boolean(belongs));
- return belongs;
+
+ protected void recurseTrue(Object o, ITreeContentProvider provider) {
+ cache.put(o, new Boolean(true));
+ Object[] children = provider.getChildren(o);
+ for( int i = 0; i < children.length; i++ )
+ recurseTrue(children[i], provider);
+ }
}
-
- protected void recurseTrue(Object o, ITreeContentProvider provider) {
- cache.put(o, new Boolean(true));
- Object[] children = provider.getChildren(o);
- for( int i = 0; i < children.length; i++ )
- recurseTrue(children[i], provider);
+
+ protected void clearCache() {
+ cache = new HashMap<Object,Boolean>();
+ requiresRefine = false;
}
public boolean shouldShow(Object element, Object parentElement) {
String filterText = this.filterText;
- if( filterText != null && !("".equals(filterText))) {
+ if( filterText != null && filterText.length() > 0 ) {
boolean tmp = cache.get(element) != null &&
cache.get(element).booleanValue();
return tmp;
}