felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r952712 - in /felix/trunk/karaf: admin/management/ admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/ admin/management/src/main/resources/OSGI-INF/blueprint/ admin/management/src/test/java/org/apache/felix/kara...
Date Tue, 08 Jun 2010 16:05:24 GMT
Author: gnodet
Date: Tue Jun  8 16:05:24 2010
New Revision: 952712

URL: http://svn.apache.org/viewvc?rev=952712&view=rev
Log:
FELIX-2349: JMX notifications

Added:
    felix/trunk/karaf/management/src/main/java/org/apache/felix/karaf/management/MBeanRegistrer.java
      - copied, changed from r952663, felix/trunk/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/MBeanRegistrer.java
    felix/trunk/karaf/management/src/test/java/
    felix/trunk/karaf/management/src/test/java/org/
    felix/trunk/karaf/management/src/test/java/org/apache/
    felix/trunk/karaf/management/src/test/java/org/apache/felix/
    felix/trunk/karaf/management/src/test/java/org/apache/felix/karaf/
    felix/trunk/karaf/management/src/test/java/org/apache/felix/karaf/management/
    felix/trunk/karaf/management/src/test/java/org/apache/felix/karaf/management/MBeanRegistererTest.java
      - copied, changed from r952663, felix/trunk/karaf/admin/management/src/test/java/org/apache/felix/karaf/admin/management/internal/MBeanRegistererTest.java
Removed:
    felix/trunk/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/MBeanRegistrer.java
    felix/trunk/karaf/admin/management/src/test/java/org/apache/felix/karaf/admin/management/internal/MBeanRegistererTest.java
    felix/trunk/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/MBeanRegistrer.java
Modified:
    felix/trunk/karaf/admin/management/pom.xml
    felix/trunk/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/AdminServiceMBeanImpl.java
    felix/trunk/karaf/admin/management/src/main/resources/OSGI-INF/blueprint/admin-management.xml
    felix/trunk/karaf/features/management/pom.xml
    felix/trunk/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
    felix/trunk/karaf/features/management/src/main/resources/OSGI-INF/blueprint/features-management.xml
    felix/trunk/karaf/management/pom.xml

Modified: felix/trunk/karaf/admin/management/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/admin/management/pom.xml?rev=952712&r1=952711&r2=952712&view=diff
==============================================================================
--- felix/trunk/karaf/admin/management/pom.xml (original)
+++ felix/trunk/karaf/admin/management/pom.xml Tue Jun  8 16:05:24 2010
@@ -55,6 +55,11 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.felix.karaf</groupId>
+            <artifactId>org.apache.felix.karaf.management</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>org.easymock</groupId>
             <artifactId>easymockclassextension</artifactId>
             <version>${easymock.version}</version>

Modified: felix/trunk/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/AdminServiceMBeanImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/AdminServiceMBeanImpl.java?rev=952712&r1=952711&r2=952712&view=diff
==============================================================================
--- felix/trunk/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/AdminServiceMBeanImpl.java
(original)
+++ felix/trunk/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/AdminServiceMBeanImpl.java
Tue Jun  8 16:05:24 2010
@@ -20,6 +20,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
+import javax.management.StandardMBean;
 import javax.management.openmbean.TabularData;
 
 import org.apache.felix.karaf.admin.management.AdminServiceMBean;
@@ -28,10 +29,14 @@ import org.apache.felix.karaf.admin.Inst
 import org.apache.felix.karaf.admin.InstanceSettings;
 import org.apache.felix.karaf.admin.management.codec.JmxInstance;
 
-public class AdminServiceMBeanImpl implements AdminServiceMBean {
+public class AdminServiceMBeanImpl extends StandardMBean implements AdminServiceMBean {
 
     private AdminService adminService;
 
+    public AdminServiceMBeanImpl() {
+        super(AdminServiceMBean.class, false);
+    }
+
     public AdminService getAdminService() {
         return adminService;
     }

Modified: felix/trunk/karaf/admin/management/src/main/resources/OSGI-INF/blueprint/admin-management.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/admin/management/src/main/resources/OSGI-INF/blueprint/admin-management.xml?rev=952712&r1=952711&r2=952712&view=diff
==============================================================================
--- felix/trunk/karaf/admin/management/src/main/resources/OSGI-INF/blueprint/admin-management.xml
(original)
+++ felix/trunk/karaf/admin/management/src/main/resources/OSGI-INF/blueprint/admin-management.xml
Tue Jun  8 16:05:24 2010
@@ -29,18 +29,11 @@
         <property name="adminService" ref="adminService" />
     </bean>
 
-    <bean id="mbeanRegister" class="org.apache.felix.karaf.admin.management.internal.MBeanRegistrer">
+    <bean id="mbeanRegister" class="org.apache.felix.karaf.management.MBeanRegistrer">
         <property name="mbeans">
             <map>
-                <entry>
-                    <key>
-                        <bean class="javax.management.StandardMBean">
-                            <argument ref="mbeanImpl" />
-                            <argument value="org.apache.felix.karaf.admin.management.AdminServiceMBean"/>
-                        </bean>
-                    </key>
-                    <value>org.apache.felix.karaf:type=admin,name=${karaf.name}</value>
-                </entry>
+                <entry value="org.apache.felix.karaf:type=admin,name=${karaf.name}"
+                    key-ref="mbeanImpl" />
             </map>
         </property>
     </bean>

Modified: felix/trunk/karaf/features/management/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/features/management/pom.xml?rev=952712&r1=952711&r2=952712&view=diff
==============================================================================
--- felix/trunk/karaf/features/management/pom.xml (original)
+++ felix/trunk/karaf/features/management/pom.xml Tue Jun  8 16:05:24 2010
@@ -70,6 +70,11 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.felix.karaf</groupId>
+            <artifactId>org.apache.felix.karaf.management</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>org.springframework.osgi</groupId>
             <artifactId>spring-osgi-core</artifactId>
             <scope>test</scope>

Modified: felix/trunk/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/FeaturesServiceMBeanImpl.java?rev=952712&r1=952711&r2=952712&view=diff
==============================================================================
--- felix/trunk/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
(original)
+++ felix/trunk/karaf/features/management/src/main/java/org/apache/felix/karaf/features/management/internal/FeaturesServiceMBeanImpl.java
Tue Jun  8 16:05:24 2010
@@ -13,39 +13,40 @@
  */
 package org.apache.felix.karaf.features.management.internal;
 
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Hashtable;
 import java.util.List;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.net.URI;
 
+import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanRegistration;
 import javax.management.MBeanServer;
+import javax.management.Notification;
 import javax.management.NotificationBroadcasterSupport;
 import javax.management.ObjectName;
-import javax.management.Notification;
+import javax.management.StandardEmitterMBean;
 import javax.management.openmbean.TabularData;
 
+import org.apache.felix.karaf.features.Feature;
+import org.apache.felix.karaf.features.FeatureEvent;
+import org.apache.felix.karaf.features.FeaturesListener;
+import org.apache.felix.karaf.features.FeaturesService;
+import org.apache.felix.karaf.features.Repository;
+import org.apache.felix.karaf.features.RepositoryEvent;
 import org.apache.felix.karaf.features.management.FeaturesServiceMBean;
 import org.apache.felix.karaf.features.management.codec.JmxFeature;
 import org.apache.felix.karaf.features.management.codec.JmxFeatureEvent;
 import org.apache.felix.karaf.features.management.codec.JmxRepository;
 import org.apache.felix.karaf.features.management.codec.JmxRepositoryEvent;
-import org.apache.felix.karaf.features.FeaturesListener;
-import org.apache.felix.karaf.features.FeatureEvent;
-import org.apache.felix.karaf.features.RepositoryEvent;
-import org.apache.felix.karaf.features.FeaturesService;
-import org.apache.felix.karaf.features.Feature;
-import org.apache.felix.karaf.features.Repository;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
 /**
- *
+ * Implementation of {@link FeaturesServiceMBean}.
  */
-
-public class FeaturesServiceMBeanImpl extends NotificationBroadcasterSupport
-                                      implements MBeanRegistration, FeaturesServiceMBean
{
+public class FeaturesServiceMBeanImpl extends StandardEmitterMBean implements
+    MBeanRegistration, FeaturesServiceMBean {
 
     private ServiceRegistration registration;
 
@@ -59,50 +60,31 @@ public class FeaturesServiceMBeanImpl ex
 
     private FeaturesService featuresService;
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see javax.management.MBeanRegistration#preRegister(javax.manamement.MBeanServer,
javax.management.ObjectName)
-     */
-	public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
-		objectName = name;
-		this.server = server;
-		return name;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 *
-	 * @see javax.management.MBeanRegistration#postRegister(java.lang.Boolean)
-	 */
-	public void postRegister(Boolean registrationDone) {
-        registration = bundleContext.registerService(
-                            FeaturesListener.class.getName(),
-                            getFeaturesListener(),
-                            new Hashtable());
-	}
-
-	/*
-	 * (non-Javadoc)
-	 *
-	 * @see javax.management.MBeanRegistration#preDeregister()
-	 */
-	public void preDeregister() throws Exception {
-        registration.unregister();
-	}
+    public FeaturesServiceMBeanImpl() {
+        super(FeaturesServiceMBean.class, new NotificationBroadcasterSupport(
+            getBroadcastInfo()));
+    }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see javax.management.MBeanRegistration#postDeregister()
-     */
-    public void postDeregister() {
+    @Override
+    public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
+        objectName = name;
+        this.server = server;
+        return name;
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.apache.felix.karaf.features.management.FeaturesServiceMBean#getFeatures()
+    @Override
+    public void postRegister(Boolean registrationDone) {
+        registration = bundleContext.registerService(FeaturesListener.class.getName(),
+            getFeaturesListener(), new Hashtable());
+    }
+
+    @Override
+    public void preDeregister() throws Exception {
+        registration.unregister();
+    }
+
+    /**
+     * {@inheritDoc}
      */
     public TabularData getFeatures() throws Exception {
         try {
@@ -120,10 +102,8 @@ public class FeaturesServiceMBeanImpl ex
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.apache.felix.karaf.features.management.FeaturesServiceMBean#getRepositories()
+    /**
+     * {@inheritDoc}
      */
     public TabularData getRepositories() throws Exception {
         try {
@@ -191,4 +171,14 @@ public class FeaturesServiceMBeanImpl ex
         };
     }
 
+
+    private static MBeanNotificationInfo[] getBroadcastInfo() {
+        String type = Notification.class.getCanonicalName();
+        MBeanNotificationInfo info1 = new MBeanNotificationInfo(new String[] {FEATURE_EVENT_EVENT_TYPE},
+            type, "Some features notification");
+        MBeanNotificationInfo info2 = new MBeanNotificationInfo(new String[] {REPOSITORY_EVENT_EVENT_TYPE},
+            type, "Some repository notification");
+        return new MBeanNotificationInfo[] {info1, info2};
+    }
+
 }
\ No newline at end of file

Modified: felix/trunk/karaf/features/management/src/main/resources/OSGI-INF/blueprint/features-management.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/features/management/src/main/resources/OSGI-INF/blueprint/features-management.xml?rev=952712&r1=952711&r2=952712&view=diff
==============================================================================
--- felix/trunk/karaf/features/management/src/main/resources/OSGI-INF/blueprint/features-management.xml
(original)
+++ felix/trunk/karaf/features/management/src/main/resources/OSGI-INF/blueprint/features-management.xml
Tue Jun  8 16:05:24 2010
@@ -31,18 +31,11 @@
         <property name="featuresService" ref="featuresService" />
     </bean>
 
-    <bean id="mbeanRegister" class="org.apache.felix.karaf.features.management.internal.MBeanRegistrer">
+    <bean id="mbeanRegister" class="org.apache.felix.karaf.management.MBeanRegistrer">
         <property name="mbeans">
             <map>
-                <entry>
-                    <key>
-                        <bean class="javax.management.StandardMBean">
-                            <argument ref="mbeanImpl" />
-                            <argument value="org.apache.felix.karaf.features.management.FeaturesServiceMBean"/>
-                        </bean>
-                    </key>
-                    <value>org.apache.felix.karaf:type=features,name=${karaf.name}</value>
-                </entry>
+                <entry value="org.apache.felix.karaf:type=features,name=${karaf.name}"
+                    key-ref="mbeanImpl" />
             </map>
         </property>
     </bean>

Modified: felix/trunk/karaf/management/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/management/pom.xml?rev=952712&r1=952711&r2=952712&view=diff
==============================================================================
--- felix/trunk/karaf/management/pom.xml (original)
+++ felix/trunk/karaf/management/pom.xml Tue Jun  8 16:05:24 2010
@@ -58,6 +58,17 @@
             <artifactId>commons-logging</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymockclassextension</artifactId>
+            <version>${easymock.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

Copied: felix/trunk/karaf/management/src/main/java/org/apache/felix/karaf/management/MBeanRegistrer.java
(from r952663, felix/trunk/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/MBeanRegistrer.java)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/management/src/main/java/org/apache/felix/karaf/management/MBeanRegistrer.java?p2=felix/trunk/karaf/management/src/main/java/org/apache/felix/karaf/management/MBeanRegistrer.java&p1=felix/trunk/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/MBeanRegistrer.java&r1=952663&r2=952712&rev=952712&view=diff
==============================================================================
--- felix/trunk/karaf/admin/management/src/main/java/org/apache/felix/karaf/admin/management/internal/MBeanRegistrer.java
(original)
+++ felix/trunk/karaf/management/src/main/java/org/apache/felix/karaf/management/MBeanRegistrer.java
Tue Jun  8 16:05:24 2010
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.karaf.admin.management.internal;
+package org.apache.felix.karaf.management;
 
 import java.util.Map;
 

Copied: felix/trunk/karaf/management/src/test/java/org/apache/felix/karaf/management/MBeanRegistererTest.java
(from r952663, felix/trunk/karaf/admin/management/src/test/java/org/apache/felix/karaf/admin/management/internal/MBeanRegistererTest.java)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/management/src/test/java/org/apache/felix/karaf/management/MBeanRegistererTest.java?p2=felix/trunk/karaf/management/src/test/java/org/apache/felix/karaf/management/MBeanRegistererTest.java&p1=felix/trunk/karaf/admin/management/src/test/java/org/apache/felix/karaf/admin/management/internal/MBeanRegistererTest.java&r1=952663&r2=952712&rev=952712&view=diff
==============================================================================
--- felix/trunk/karaf/admin/management/src/test/java/org/apache/felix/karaf/admin/management/internal/MBeanRegistererTest.java
(original)
+++ felix/trunk/karaf/management/src/test/java/org/apache/felix/karaf/management/MBeanRegistererTest.java
Tue Jun  8 16:05:24 2010
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.karaf.admin.management.internal;
+package org.apache.felix.karaf.management;
 
 import java.util.Map;
 import java.util.HashMap;
@@ -22,8 +22,6 @@ import java.util.HashMap;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
-import org.apache.felix.karaf.admin.management.AdminServiceMBean;
-
 import static org.easymock.classextension.EasyMock.*;
 import org.easymock.classextension.IMocksControl;
 
@@ -62,4 +60,8 @@ public class MBeanRegistererTest extends
            System.getProperties().remove("karaf.name");
         }
     }
+
+	public static interface AdminServiceMBean {
+	    int createInstance(String name) throws Exception;
+	}
 }



Mime
View raw message