Author: rob.stryker(a)jboss.com
Date: 2012-05-03 08:21:47 -0400 (Thu, 03 May 2012)
New Revision: 40750
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss71ServerConnection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBossServerConnection.java
Log:
JBIDE-11064 to trunk
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss71ServerConnection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss71ServerConnection.java 2012-05-03
11:59:59 UTC (rev 40749)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBoss71ServerConnection.java 2012-05-03
12:21:47 UTC (rev 40750)
@@ -42,9 +42,11 @@
private String user;
private String pass;
+ private Map<MBeanServerConnection, JMXConnector> connectionToConnector;
protected void initializeEnvironment(IServer s, String user, String pass) throws
CredentialException {
this.user = user;
this.pass = pass;
+ this.connectionToConnector = new HashMap<MBeanServerConnection, JMXConnector>();
}
protected MBeanServerConnection createConnection(IServer s) throws Exception {
@@ -64,6 +66,7 @@
try {
connector = JMXConnectorFactory.connect(new JMXServiceURL(url), environment);
MBeanServerConnection connection = connector.getMBeanServerConnection();
+ this.connectionToConnector.put(connection, connector);
return connection;
} catch(IOException ioe) {
return null;
@@ -71,12 +74,17 @@
IStatus stat = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Runtime Exception contacting JBoss instance. Please ensure your server is up
and exposes its management ports via the -Djboss.bind.address.management=yourwebsite.com
system property", re);
throw new JMXException(stat);
- } finally {
- if( connector != null ) {
- try {
- connector.close();
- } catch(Exception e) { /* Ignore */ }
- }
}
}
+
+ protected void cleanupConnection(IServer server, MBeanServerConnection connection) {
+ super.cleanupConnection(server, connection);
+ if( connectionToConnector.get(connection) != null ) {
+ try {
+ connectionToConnector.remove(connection);
+ connectionToConnector.get(connection).close();
+ } catch(Exception e) { /* Ignore */ }
+ }
+ }
+
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBossServerConnection.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBossServerConnection.java 2012-05-03
11:59:59 UTC (rev 40749)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JBossServerConnection.java 2012-05-03
12:21:47 UTC (rev 40750)
@@ -132,9 +132,10 @@
.getContextClassLoader();
ClassLoader newLoader = getProvider2().getClassloaderRepository().getClassLoader(s);
Thread.currentThread().setContextClassLoader(newLoader);
+ MBeanServerConnection connection = null;
try {
initializeEnvironment(s, user, pass);
- MBeanServerConnection connection = createConnection(s);
+ connection = createConnection(s);
if( connection != null ) {
r.run(connection);
}
@@ -146,6 +147,7 @@
throw new JMXException(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
"Error connecting to remote JMX. Please ensure your server is properly
configured for JMX access.", e));
} finally {
+ cleanupConnection(s, connection);
getProvider2().getClassloaderRepository().removeConcerned(s, r);
Thread.currentThread().setContextClassLoader(currentLoader);
}
@@ -162,6 +164,10 @@
return null;
}
+ protected void cleanupConnection(IServer server, MBeanServerConnection connection) {
+ // Do nothing, provide subclasses ability
+ }
+
protected void initializeEnvironment(IServer s, String user, String pass) throws
CredentialException {
JMXUtil.setCredentials(s,user,pass);
}
Show replies by date