*/
public SampleJMXListener(Properties properties, Identity owner,
ComponentRegistry registry)
{
// Find the MBean which collects our overall task statistics
ProfileCollector collector =
registry.getComponent(ProfileCollector.class);
taskBean = (TaskAggregateMXBean)
collector.getRegisteredMBean(TaskAggregateMXBean.MXBEAN_NAME);
if (taskBean == null) {
// The bean hasn't been registerd yet. This is unexpected,
// so throw an exception to indicate we're in a bad state.
throw
new IllegalStateException("Could not find task aggregate mbean");
}
// Ensure that the taskBean statistics are being generated.
// This means we don't have to enable a default profiling level
// through a property at start-up.
// Because consumer names aren't publically declared in a way that
// makes them easy to find programmatically, we make a best guess
// search here.
Map<String, ProfileConsumer> consumers = collector.getConsumers();
for (Map.Entry<String, ProfileConsumer> entry : consumers.entrySet()) {
if (entry.getKey().contains("TaskAggregate")) {
ProfileConsumer taskConsumer = entry.getValue();
taskConsumer.setProfileLevel(ProfileLevel.MAX);
break;