Announcement Announcement Module
Collapse
No announcement yet.
new feature wanted Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • new feature wanted

    Hi all,
    I want this feature, when I add notificationListenerMappings, MBeanExporter can support ObjectName wildcard characters.
    For example
    HTML Code:
    <property name="notificationListenerMappings">
      <map>
        <entry key="com.taobao.jmx:type=en*">
            <bean class="com.taobao.jmx.spring.notification.EnglishListen" />
        </entry>
      </map>
    </property>
    MBeanExporter will add EnglishListen to all MBeans that ObjectName match com.toabao.jmx:type=en*

    the code of registerNotificationListeners method now is:
    Code:
    private void registerNotificationListeners() throws MBeanExportException {
      for (int i = 0; i < this.notificationListeners.length; i++) {
        NotificationListenerBean bean = this.notificationListeners[i];
        NotificationListener listener = bean.getNotificationListener();
        NotificationFilter filter = bean.getNotificationFilter();
        Object handback = bean.getHandback();
        ObjectName[] namesToRegisterWith = getObjectNamesForNotificationListener(bean);
        for (int j = 0; j < namesToRegisterWith.length; j++) {
          ObjectName objectName = namesToRegisterWith[j];
          try {
            this.server.addNotificationListener(objectName, listener, filter, handback);
          }
          catch (InstanceNotFoundException ex) {
            throw new MBeanExportException("Unable to register NotificationListener for MBean [" + objectName + "] because that MBean instance does not exist", ex);
    	  }
    	}
      }
    }
    just change these to
    Code:
    
      for (int i = 0; i < this.notificationListeners.length; i++) {
        NotificationListenerBean bean = this.notificationListeners[i];
        NotificationListener listener = bean.getNotificationListener();
        NotificationFilter filter = bean.getNotificationFilter();
        Object handback = bean.getHandback();
        ObjectName[] namesToRegisterWith = getObjectNamesForNotificationListener(bean);
        for (int j = 0; j < namesToRegisterWith.length; j++) {
          ObjectName objectName = namesToRegisterWith[j];
          try {
    
            Set<ObjectName> objectNameList = server.queryNames(objectName, null);
            if(objectNameList != null && objectNameList.size() > 0) {
              for(ObjectName oname : ObjectName) {
                this.server.addNotificationListener(oname, listener, filter, handback);
              }
            }
    
          }
          catch (InstanceNotFoundException ex) {
            throw new MBeanExportException("Unable to register NotificationListener for MBean [" + objectName + "] because that MBean instance does not exist", ex);
    	  }
    	}
      }
    }

  • #2
    I suggest you post a request to Jira. That way it won't get lost.

    Regards,
    Andreas

    Comment


    • #3
      Originally posted by Andreas Senft View Post
      I suggest you post a request to Jira. That way it won't get lost.

      Regards,
      Andreas
      Nice suggest, already done!
      see http://opensource.atlassian.com/proj...rowse/SPR-4055

      Comment

      Working...
      X