FlagJMXProxy.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:Pogamut3 作者:
public FlagJMXProxy(final ObjectName source, final MBeanServerConnection mbsc, final String flagName) throws MalformedObjectNameException {
    ObjectName name = PogamutJMX.getObjectName(source, flagName, PogamutJMX.FLAGS_SUBTYPE);
    try {
        listener = new NotificationListener() {

            @Override
            public void handleNotification(Notification notification, Object handback) {
                if (notification.getSource().equals(source) && notification.getType().equals(flagName)) {
                    setFlag((T) notification.getUserData());
                }
            }
        };
        // get current value of the flag
        T val = (T) mbsc.getAttribute(name, "Flag");
        setFlag(val);

        /* NOTE filters are send over RMI to the server !!! it is better to
         handle filtering in the listener itself.

        NotificationFilter nf = new NotificationFilter() {

        @Override
        public boolean isNotificationEnabled(Notification notification) {
        return notification.getSource().equals(source) && notification.getType().equals(flagName);
        }
        };
         */
        mbsc.addNotificationListener(name, listener, null, mbsc);
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号