You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by sf...@apache.org on 2006/07/21 12:20:03 UTC

svn commit: r424252 - in /incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/felix/ src/main/java/org/apache/felix/mosgi/ s...

Author: sfrenot
Date: Fri Jul 21 03:19:58 2006
New Revision: 424252

URL: http://svn.apache.org/viewvc?rev=424252&view=rev
Log:
A graphical tab that is automatically downloaded and included in the JMX Console


Added:
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/pom.xml
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/org/
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/org/apache/
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/org/apache/felix/
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/org/apache/felix/mosgi/
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/org/apache/felix/mosgi/managedelements/
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/org/apache/felix/mosgi/managedelements/osgiprobes/
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/org/apache/felix/mosgi/managedelements/osgiprobes/tab/
    incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/org/apache/felix/mosgi/managedelements/osgiprobes/tab/OsgiProbesTabUI.java

Added: incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/pom.xml
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/pom.xml?rev=424252&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/pom.xml (added)
+++ incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/pom.xml Fri Jul 21 03:19:58 2006
@@ -0,0 +1,63 @@
+<project>
+  <parent>
+    <groupId>org.apache.felix</groupId>
+    <artifactId>felix</artifactId>
+    <version>0.8.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <packaging>osgi-bundle</packaging>
+  <name>MOSGi OSGi gateway status tab for the JMX console</name>
+  <artifactId>org.apache.felix.mosgi.managedelements.osgiprobes.tab</artifactId>
+  <dependencies>
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <version>${pom.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <version>${pom.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>org.apache.felix.mosgi.console.ifc</artifactId>
+      <version>${pom.version}</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix.plugins</groupId>
+        <artifactId>maven-osgi-plugin</artifactId>
+        <version>${pom.version}</version>
+        <extensions>true</extensions>
+        <configuration>
+          <osgiManifest>
+            <bundleName>MOSGi OSGi gateway status tab for the JMX console</bundleName>
+            <bundleDescription>MOSGi OSGi gateway status tab for the JMX console</bundleDescription>
+            <bundleActivator>auto-detect</bundleActivator>
+            <bundleDocUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/</bundleDocUrl>
+            <bundleUrl>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}.jar</bundleUrl>
+            <bundleSource>http://oscar-osgi.sf.net/obr2/${pom.artifactId}/${pom.artifactId}-${pom.version}-src.jar</bundleSource>
+            <bundleSymbolicName>${pom.artifactId}</bundleSymbolicName>
+            <exportPackage>
+	                   ${pom.artifactId};specification-version="1.0.0"
+            </exportPackage>
+	          <importPackage>
+	            javax.management;specification-version="1.0.0",
+	            org.osgi.framework;specification-version="1.0.0",
+	            javax.swing;specification-version="1.0.0",
+	            javax.swing.table;specification-version="1.0.0",
+	            org.apache.felix.mosgi.console.ifc;specification-version="1.0.0",
+							${pom.artifactId};specification-version="1.0.0"
+	          </importPackage>
+          </osgiManifest>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/org/apache/felix/mosgi/managedelements/osgiprobes/tab/OsgiProbesTabUI.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/org/apache/felix/mosgi/managedelements/osgiprobes/tab/OsgiProbesTabUI.java?rev=424252&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/org/apache/felix/mosgi/managedelements/osgiprobes/tab/OsgiProbesTabUI.java (added)
+++ incubator/felix/trunk/org.apache.felix.mosgi.managedelements.osgiprobes.tab/src/main/java/org/apache/felix/mosgi/managedelements/osgiprobes/tab/OsgiProbesTabUI.java Fri Jul 21 03:19:58 2006
@@ -0,0 +1,115 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   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.mosgi.managedelements.osgiprobes.tab;
+
+import java.awt.Component;
+import java.beans.PropertyChangeEvent;
+import java.util.ArrayList;
+import java.util.Vector;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableModel;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.apache.felix.mosgi.console.ifc.Plugin;
+
+public class OsgiProbesTabUI extends JPanel implements Plugin, BundleActivator {
+
+  private String [] headers = {"Name", "Value"};
+  private JTable innerTable;
+
+  private BundleContext m_context = null;
+  private ServiceRegistration sreg = null;
+
+  public OsgiProbesTabUI(){
+    this.innerTable=new JTable();
+    this.innerTable.setPreferredScrollableViewportSize(new java.awt.Dimension(500,150));
+    JScrollPane table = new JScrollPane(this.innerTable);
+    this.add(table);
+  }
+
+
+  ///////////////////////////////////////////
+  //           BundleActivator             //
+  ///////////////////////////////////////////
+  public void start(BundleContext context) {
+    m_context = context;
+    this.registerServicePlugin();
+  }
+
+  public void stop(BundleContext context) {
+  }
+
+  
+
+  ///////////////////////////////////////////
+  //           Plugin                      //
+  //////////////////////////////////////////
+  public void registerServicePlugin(){
+    sreg = m_context.registerService(Plugin.class.getName(), this, null);
+  }
+  
+  public void unregisterServicePlugin(){
+    sreg.unregister();   
+  }
+  
+  public String pluginLocation(){
+    return m_context.getBundle().getLocation();
+  }
+  
+  public String getName(){return "OSGi Platform";}
+
+  public Component getGUI(){return this;}
+
+  public void propertyChange(PropertyChangeEvent e){
+    /*
+     * This a static tab, each new visit will provide the same
+     * information. A dynamic tab update is provided in LinuxTab
+     *
+     */
+    if (e.getPropertyName().equals(Plugin.NEW_NODE_READY)){
+      this.getProperties((MBeanServerConnection)e.getNewValue());
+    }else if(e.getPropertyName().equals(Plugin.EMPTY_NODE)){
+      this.innerTable.setModel(new DefaultTableModel());
+      this.invalidate();
+      this.validate();
+    }
+  }
+
+  private void getProperties(MBeanServerConnection mbsc){
+    try{
+      ObjectName on=new ObjectName("TabUI:name=OsgiProbes");
+      MBeanAttributeInfo attrInfo[] = mbsc.getMBeanInfo(on).getAttributes();
+      Object content [][]=new String[attrInfo.length][2];
+      for (int k=0;k<attrInfo.length;k++) {
+        content [k][0]=attrInfo[k].getName();
+        content [k][1]=mbsc.getAttribute(on, attrInfo[k].getName());
+      }
+      DefaultTableModel dtm=new DefaultTableModel(content, this.headers);
+      this.innerTable.setModel(dtm);
+      this.invalidate();
+      this.validate();
+    }catch (Exception e){
+      e.printStackTrace();
+    }
+  }
+}