Author: thomas.diesler(a)jboss.com
Date: 2010-03-04 23:37:23 -0500 (Thu, 04 Mar 2010)
New Revision: 101931
Modified:
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
Log:
Cache MBeanServer
Modified:
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
===================================================================
---
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-03-05
04:37:07 UTC (rev 101930)
+++
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-03-05
04:37:23 UTC (rev 101931)
@@ -57,6 +57,8 @@
{
// Provide logging
private static final Logger log = Logger.getLogger(EmbeddedRuntime.class);
+
+ private MBeanServer server;
public EmbeddedRuntime(OSGiTestHelper helper)
{
@@ -163,17 +165,18 @@
public MBeanServerConnection getMBeanServer()
{
- ArrayList<MBeanServer> serverArr = MBeanServerFactory.findMBeanServer(null);
- if (serverArr.size() > 1)
- throw new IllegalStateException("Multiple MBeanServer instances not
supported");
+ if (server == null)
+ {
+ ArrayList<MBeanServer> serverArr =
MBeanServerFactory.findMBeanServer(null);
+ if (serverArr.size() > 1)
+ throw new IllegalStateException("Multiple MBeanServer instances not
supported");
- MBeanServer server = null;
- if (serverArr.size() == 1)
- server = serverArr.get(0);
+ if (serverArr.size() == 1)
+ server = serverArr.get(0);
- if (server == null)
- server = MBeanServerFactory.createMBeanServer();
-
+ if (server == null)
+ server = MBeanServerFactory.createMBeanServer();
+ }
return server;
}