Search |
||
Mustang Beta and the JMX APIPosted by emcmanus on February 15, 2006 at 8:52 AM PST
As you'll no doubt have read elsewhere, the Mustang Beta Release is now available. There are plenty of improvements in plenty of areas, including the JMX API. The improvements to the JMX API are incremental changes to existing functionality, rather than entirely new features. The new features will arrive in Dolphin (Java SE 7), as defined by JSR 255. (The members of the JSR 255 Expert Group were also closely involved in the JMX API changes made in Mustang.) We don't expect there to be any significant changes to the JMX
API beyond the Beta. If you felt that the weekly
Mustang snapshots from
What's changed?The two biggest changes to the JMX API in Mustang concern MXBeans and Descriptors. I wrote about
MXBeans
recently. MXBeans provide a way to package related
information together in an MBean without requiring any special
configuration for clients that interact with that MBean. This
is an incremental change, because MXBeans already existed in
J2SE 5.0, in the package
I also wrote about Descriptors a while back. Descriptors give you a convenient way to attach arbitrary extra metadata to your MBeans. This is an incremental change because Descriptors have always existed in the JMX API, but only in conjunction with Model MBeans. In Mustang, Descriptors are available with all types of MBeans. This helps to erase the somewhat arbitrary distinctions between different sorts of MBeans, notably Open MBeans and Model MBeans. Here are a few of the other improvements that Mustang brings to the JMX API. GenerificationFor obscure compatibility reasons, we weren't able to generify
the JMX API in Tiger. This has been fixed in Mustang. So
One nice effect of generification is that you no longer need a cast in the following assignment: SomeMBean proxy = (SomeMBean) MBeanServerInvocationHandler.newProxyInstance( mbeanServer, objectName, SomeMBean.class, false); As a side-note, this can now be replaced by the much easier-to-remember:
SomeMBean proxy =
JMX.newMBeanProxy(mbeanServer, objectName, SomeMBean.class);
More powerful wildcards in ObjectNameThe
ObjectName implements Comparable<ObjectName>
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
Set<ObjectName> names = mbs.queryNames(null, null);
System.out.println(names.toString().replace(", ",
System.getProperty("line.separator")));
...then I'll get this rather random output: [java.lang:type=MemoryManager,name=CodeCacheManager java.lang:type=Compilation java.lang:type=GarbageCollector,name=Copy com.sun.management:type=HotSpotDiagnostic java.lang:type=MemoryPool,name=Eden Space java.lang:type=Runtime java.lang:type=ClassLoading java.lang:type=MemoryPool,name=Survivor Space java.lang:type=Threading java.lang:type=GarbageCollector,name=MarkSweepCompact java.util.logging:type=Logging java.lang:type=Memory java.lang:type=OperatingSystem java.lang:type=MemoryPool,name=Code Cache java.lang:type=MemoryPool,name=Tenured Gen java.lang:type=MemoryPool,name=Perm Gen JMImplementation:type=MBeanServerDelegate] On the other hand, if I add the following line after the
assignment to names = new TreeSet(names); // a TreeSet is a SortedSet ...then I get this reasonable ordering: [JMImplementation:type=MBeanServerDelegate com.sun.management:type=HotSpotDiagnostic java.lang:type=ClassLoading java.lang:type=Compilation java.lang:type=GarbageCollector,name=Copy java.lang:type=GarbageCollector,name=MarkSweepCompact java.lang:type=Memory java.lang:type=MemoryManager,name=CodeCacheManager java.lang:type=MemoryPool,name=Code Cache java.lang:type=MemoryPool,name=Eden Space java.lang:type=MemoryPool,name=Perm Gen java.lang:type=MemoryPool,name=Survivor Space java.lang:type=MemoryPool,name=Tenured Gen java.lang:type=OperatingSystem java.lang:type=Runtime java.lang:type=Threading java.util.logging:type=Logging] NotificationsNotificationBroadcasterSupport constructor with MBeanInfo[]If you have an MBean that emits notifications, it must
implement the
New StandardEmitterMBean classSpeaking of MBeans that emit notifications, if you're writing a
Standard MBean but you can't subclass
New Query.isInstanceOfYou can now query for MBeans that are an instance of a
particular class or interface. For example, to find all Monitor
MBeans in the
QueryExp isMonitor =
Query.isInstanceOf("javax.management.monitor.MonitorMBean");
Set<ObjectName> monitorNames =
mbeanServer.queryNames(new ObjectName("domesne:*"), isMonitor);
Actually, I should warn you that this will change after the Beta, and the first line will become this instead:
QueryExp isMonitor =
Query.isInstanceOf(Query.value("javax.management.monitor.MonitorMBean"));
Alert readers will deduce that either I was lying when I said there would be no significant API changes after the Beta, or I don't consider this a significant change. Either way, this is likely to be about as significant as it will get. Monitor Service supports complex typesPreviously, the Monitor Service defined by
The ability to pick out values like this is confined to the
Monitor Service. You cannot call
Address of a JMXConnectorIf you have an RMI connector client obtained with code something like this...
JMXServiceURL jurl =
new JMXServiceURL("service:jmx:rmi://blah);
JMXConnector jc = JMXConnectorFactory.connect(jurl);
...then you can now retrieve the address from JMXServiceURL jurl2 = ((JMXAddressable) jc).getAddress(); Here, So there it isAs usual, if you have comments on these new features or the way
they are specified, feel free to drop me a line at »
Related Topics >>
Open JDK Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|