// "org.jboss.mx.server.registry.ManagedMBeanRegistry");
ObjectName registry = new ObjectName(ServerConstants.MBEAN_REGISTRY);
MBeanServer server = MBeanServerFactory.createMBeanServer();
MLet mlet = new MLet();
ObjectName name = new ObjectName("test:name=mlet");
server.registerMBean(mlet, name);
// Repeat to call the getMBeansFromURL method
server.invoke(name, "getMBeansFromURL",
new Object[] { MLET_URL1 },
new String[] { String.class.getName() }
);
server.invoke(name, "getMBeansFromURL",
new Object[] { MLET_URL2 },
new String[] { String.class.getName() }
);
try
{
List versions1 =
(List) server.invoke(registry, "getValue",
new Object[]
{
new ObjectName("test:name=Trivial"),
MBeanInstaller.VERSIONS
},
new String[]
{
ObjectName.class.getName(),
String.class.getName()
}
);
List versions2 =
(List) server.invoke(registry, "getValue",
new Object[]
{
new ObjectName("test:name=Trivial2"),
MBeanInstaller.VERSIONS
},
new String[]
{
ObjectName.class.getName(),
String.class.getName()
}
);
assertTrue("Trivial1 version=" + versions1, ((String)versions1.get(0)).equals("1.1"));
assertTrue("Trivial2 version=" + versions2, ((String)versions2.get(0)).equals("2.1"));
}
catch (MBeanException e)
{
e.printStackTrace();
assertTrue(false);
}
try
{
assertTrue(server.isRegistered(new ObjectName("test:name=Trivial")));
assertTrue(server.isRegistered(new ObjectName("test:name=Trivial2")));
}
catch (AssertionFailedError e)
{
URL[] urls = mlet.getURLs();
fail("FAILS IN RI: SUN JMX RI builds a malformed URL from an MLet text file URL '" +
MLET_URL1 + "' resulting into MLET codebase URL '" + urls[0] + "' and therefore fails " +
"to load the required classes from the Java archive (MyMBeans.jar)");
}