karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [1/2] karaf git commit: [KARAF-5075] Use the JDK provided StandardEmitterMBean
Date Thu, 30 Mar 2017 07:29:54 GMT
Repository: karaf
Updated Branches:
  refs/heads/master 94d7b7d7f -> 37827b5f5


[KARAF-5075] Use the JDK provided StandardEmitterMBean

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/8050bdcf
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/8050bdcf
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/8050bdcf

Branch: refs/heads/master
Commit: 8050bdcf7eb948ad6ade78a454337b40a201719d
Parents: 94d7b7d
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Thu Mar 30 08:25:30 2017 +0200
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Thu Mar 30 09:27:37 2017 +0200

----------------------------------------------------------------------
 .../management/FeaturesServiceMBeanImpl.java    |  9 +--
 .../management/StandardEmitterMBean.java        | 77 --------------------
 2 files changed, 4 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/8050bdcf/features/core/src/main/java/org/apache/karaf/features/internal/management/FeaturesServiceMBeanImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/management/FeaturesServiceMBeanImpl.java
b/features/core/src/main/java/org/apache/karaf/features/internal/management/FeaturesServiceMBeanImpl.java
index 93e522f..9f10a84 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/management/FeaturesServiceMBeanImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/management/FeaturesServiceMBeanImpl.java
@@ -26,7 +26,9 @@ import javax.management.MBeanRegistration;
 import javax.management.MBeanServer;
 import javax.management.NotCompliantMBeanException;
 import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
 import javax.management.ObjectName;
+import javax.management.StandardEmitterMBean;
 import javax.management.openmbean.TabularData;
 
 import org.apache.karaf.features.Feature;
@@ -60,7 +62,8 @@ public class FeaturesServiceMBeanImpl extends StandardEmitterMBean implements
     private FeaturesService featuresService;
 
     public FeaturesServiceMBeanImpl() throws NotCompliantMBeanException {
-        super(FeaturesServiceMBean.class);
+        super(FeaturesServiceMBean.class,
+              new NotificationBroadcasterSupport(getBroadcastInfo()));
     }
 
     public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
@@ -319,10 +322,6 @@ public class FeaturesServiceMBeanImpl extends StandardEmitterMBean implements
         };
     }
 
-    public MBeanNotificationInfo[] getNotificationInfo() {
-        return getBroadcastInfo();
-    }
-
     private static MBeanNotificationInfo[] getBroadcastInfo() {
         String type = Notification.class.getCanonicalName();
         MBeanNotificationInfo info1 = new MBeanNotificationInfo(new String[]{FEATURE_EVENT_EVENT_TYPE},

http://git-wip-us.apache.org/repos/asf/karaf/blob/8050bdcf/features/core/src/main/java/org/apache/karaf/features/internal/management/StandardEmitterMBean.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/management/StandardEmitterMBean.java
b/features/core/src/main/java/org/apache/karaf/features/internal/management/StandardEmitterMBean.java
deleted file mode 100644
index 37792f3..0000000
--- a/features/core/src/main/java/org/apache/karaf/features/internal/management/StandardEmitterMBean.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.features.internal.management;
-
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.NotCompliantMBeanException;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.StandardMBean;
-
-public class StandardEmitterMBean extends StandardMBean implements NotificationEmitter {
-
-    private final NotificationBroadcasterSupport emitter;
-
-    @SuppressWarnings("rawtypes")
-    public StandardEmitterMBean(Class mbeanInterface) throws NotCompliantMBeanException {
-        super(mbeanInterface);
-        this.emitter = new NotificationBroadcasterSupport() {
-            @Override
-            public MBeanNotificationInfo[] getNotificationInfo() {
-                return StandardEmitterMBean.this.getNotificationInfo();
-            }
-        };
-    }
-
-    public void sendNotification(Notification notification) {
-        emitter.sendNotification(notification);
-    }
-
-
-    public void removeNotificationListener(NotificationListener listener, NotificationFilter
filter, Object handback) throws ListenerNotFoundException {
-        emitter.removeNotificationListener(listener, filter, handback);
-    }
-
-    public void addNotificationListener(NotificationListener listener, NotificationFilter
filter, Object handback) throws IllegalArgumentException {
-        emitter.addNotificationListener(listener, filter, handback);
-    }
-
-    public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
{
-        emitter.removeNotificationListener(listener);
-    }
-
-    public MBeanNotificationInfo[] getNotificationInfo() {
-        return new MBeanNotificationInfo[0];
-    }
-
-    @Override
-    public MBeanInfo getMBeanInfo() {
-        MBeanInfo mbeanInfo = super.getMBeanInfo();
-        if (mbeanInfo != null) {
-            MBeanNotificationInfo[] notificationInfo = getNotificationInfo();
-            mbeanInfo = new MBeanInfo(mbeanInfo.getClassName(), mbeanInfo.getDescription(),
mbeanInfo.getAttributes(),
-                    mbeanInfo.getConstructors(), mbeanInfo.getOperations(), notificationInfo);
-        }
-        return mbeanInfo;
-    }
-
-}


Mime
View raw message