Results 1 to 3 of 3

Thread: new feature wanted

  1. #1
    Join Date
    Jul 2007
    Posts
    2

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

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

    Regards,
    Andreas

  3. #3
    Join Date
    Jul 2007
    Posts
    2

    Default

    Quote 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •