FELIX-2442: JDK 1.5 build issue - StandardEmitterMBean is JDK 1.6 specific
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@957468 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/FeaturesServiceMBeanImpl.java b/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
index f7b49de..98358f0 100644
--- a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
+++ b/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
@@ -22,10 +22,10 @@
import javax.management.MBeanNotificationInfo;
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.felix.karaf.features.Feature;
@@ -60,29 +60,33 @@
private FeaturesService featuresService;
- public FeaturesServiceMBeanImpl() {
- super(FeaturesServiceMBean.class, new NotificationBroadcasterSupport(
- getBroadcastInfo()));
+ public FeaturesServiceMBeanImpl() throws NotCompliantMBeanException {
+ super(FeaturesServiceMBean.class, new NotificationBroadcasterSupport() {
+ @Override
+ public MBeanNotificationInfo[] getNotificationInfo() {
+ return getBroadcastInfo();
+ }
+ });
}
- @Override
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
objectName = name;
this.server = server;
return name;
}
- @Override
public void postRegister(Boolean registrationDone) {
registration = bundleContext.registerService(FeaturesListener.class.getName(),
getFeaturesListener(), new Hashtable());
}
- @Override
public void preDeregister() throws Exception {
registration.unregister();
}
+ public void postDeregister() {
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/StandardEmitterMBean.java b/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/StandardEmitterMBean.java
new file mode 100644
index 0000000..e999011
--- /dev/null
+++ b/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/StandardEmitterMBean.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed 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.felix.karaf.features.management.internal;
+
+import javax.management.*;
+
+public class StandardEmitterMBean extends StandardMBean implements NotificationEmitter {
+
+ private NotificationBroadcasterSupport emitter;
+
+ public StandardEmitterMBean(Class mbeanInterface, NotificationBroadcasterSupport emitter) throws NotCompliantMBeanException {
+ super(mbeanInterface);
+ this.emitter = emitter;
+ }
+
+ 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 emitter.getNotificationInfo();
+ }
+
+ @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;
+ }
+
+}