felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfre...@apache.org
Subject svn commit: r669139 - in /felix/trunk/mosgi: console.gui/src/main/java/org/apache/felix/mosgi/console/gui/ doc/ jmx.agent/src/main/java/org/apache/felix/mosgi/jmx/agent/
Date Wed, 18 Jun 2008 11:33:33 GMT
Author: sfrenot
Date: Wed Jun 18 04:33:32 2008
New Revision: 669139

URL: http://svn.apache.org/viewvc?rev=669139&view=rev
Log:
Properties from config.properties.<profilName> used to build remote gateways address
changed. There is no more hard coded part into the remote gateway construction.

Instead of :
 - mosgi.jmxconsole.id.1.profile=core
 - mosgi.jmxconsole.id.1.host=127.0.0.1
 - mosgi.jmxconsole.id.1.protocol=rmi
 - mosgi.jmxconsole.id.1.port=1099

Use :
 - mosgi.jmxconsole.id.1.jmxsurl=service:jmx:rmi:///jndi/rmi://127.0.0.1:1099/core

The new property value must look like this:
  "service:jmx:<protocol>:<sap>"

More information on what this new property value must look like are available on the javax.management.remote.JMXServiceURL
class javadoc.


Modified:
    felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/Gateway.java
    felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodeCellRenderer.java
    felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodesTree.java
    felix/trunk/mosgi/doc/config.properties.jmxconsole
    felix/trunk/mosgi/doc/core.sh
    felix/trunk/mosgi/doc/jmxconsole.sh
    felix/trunk/mosgi/jmx.agent/src/main/java/org/apache/felix/mosgi/jmx/agent/AgentActivator.java

Modified: felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/Gateway.java
URL: http://svn.apache.org/viewvc/felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/Gateway.java?rev=669139&r1=669138&r2=669139&view=diff
==============================================================================
--- felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/Gateway.java
(original)
+++ felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/Gateway.java
Wed Jun 18 04:33:32 2008
@@ -34,25 +34,20 @@
 public class Gateway extends JMXServiceURL {
 
   private static final String JMX_SERVICE = "service:jmx:";
+  private static final String DEFAULT_JMXSURL = JMX_SERVICE+"rmi:///jndi/rmi://127.0.0.1:1099/core";
 
-  private static final String DEFAULT_PROFILE  = "core";
-  private static final String DEFAULT_HOST     = "127.0.0.1";
-  private static final String DEFAULT_PROTOCOL = "rmi";
-  private static final String DEFAULT_PORT     = "1099";
-
-  private static Hashtable HT_GATEWAY = new Hashtable(); // used to manage virtuals gateways
+  private static Hashtable HT_GATEWAY = new Hashtable();
 
   private JMXConnector jmxc;
   private MBeanServerConnection mbsc;
 
-  private String nickname; // used to manage virtuals gateways
-  private String name; // name for the GUI = this.nickname+" : "+this.toString()
+  private String nickname;
   private Gateway parentGateway;
   private String toolTipText;
   private boolean isConnected;
   
-  public String getName() {
-    return this.name;
+  public String getNickname() {
+    return this.nickname;
   }
 
   public MBeanServerConnection getMbsc() {
@@ -72,11 +67,10 @@
   }
 
   // The constructor (private)
-  private Gateway(String nickname, String surl, Gateway vosgi) throws MalformedURLException
{
+  private Gateway(String nickname, String surl, Gateway parent) throws MalformedURLException
{
     super(surl);
     this.nickname = nickname;
-    this.name = nickname+" : \""+this.toString().substring(JMX_SERVICE.length())+"\"";
-    this.parentGateway = vosgi;
+    this.parentGateway = parent;
     this.isConnected = false;
     this.toolTipText = "<html><B>\""+nickname+"\" JMXServiceURL =<br>"+
       "- protocol=</B>"+this.getProtocol()+"<br><B>"+
@@ -88,6 +82,9 @@
 
   // Intermediate private Gateway creator
   private static Gateway newGateway(String nickname, String serviceURL, String parent_gateway)
throws Exception {
+    if ( !serviceURL.startsWith(JMX_SERVICE) ) {
+      serviceURL = JMX_SERVICE+serviceURL;
+    }
     if ( serviceURL.contains("null") ) {
       throw new Exception("Invalid service URL \""+serviceURL+"\"");
     }
@@ -100,81 +97,56 @@
       }
     }
 
-    Gateway newGateway = new Gateway(nickname, serviceURL, vosgiGateway);
-    return newGateway;
+    return new Gateway(nickname, serviceURL, vosgiGateway);
   }
 
   // Creation of Gateways from the config properties file
   public static Gateway[] newGateways(BundleContext bc) {
+    String str_jmxsurl, nickname, str_parent;
     Vector v_gateways = new Vector();
-    String protocol, host, profile, port, nickname, parent_gateway;
-    int port_int;
 
     int i = 1;
-    profile = bc.getProperty("mosgi.jmxconsole.id."+i+".profile");
-    if ( profile == null) { profile = DEFAULT_PROFILE; }
-  
-    while ( profile != null ) {
-      host = bc.getProperty("mosgi.jmxconsole.id."+i+".host");
-      if ( host == null ) { host = DEFAULT_HOST; }
-      protocol = bc.getProperty("mosgi.jmxconsole.id."+i+".protocol");
-      if ( protocol == null ) { protocol = DEFAULT_PROTOCOL; }
-      port = bc.getProperty("mosgi.jmxconsole.id."+i+".port");
-      if ( port == null ) { port = DEFAULT_PORT; }
-      try {
-        port_int = Integer.parseInt(port);
-      } catch (Exception exep) { try { port_int = Integer.parseInt(DEFAULT_PORT); } catch
(Exception e) {} }
-      String serviceURL = JMX_SERVICE+protocol+":///jndi/"+"rmi"+"://"+host+":"+port+"/"+profile;
-      parent_gateway = bc.getProperty("mosgi.jmxconsole.id."+i+".virtual");
-      Gateway g = null;
-      nickname =  bc.getProperty("mosgi.jmxconsole.id."+i+".nickname");
+    str_jmxsurl = bc.getProperty("mosgi.jmxconsole.id."+i+".jmxsurl");
+    if ( str_jmxsurl == null ) { str_jmxsurl = DEFAULT_JMXSURL; }
+
+    while ( str_jmxsurl != null) {
+      nickname = bc.getProperty("mosgi.jmxconsole.id."+i+".nickname");
       if (nickname == null ) { nickname = ""+i; };
+      str_parent = bc.getProperty("mosgi.jmxconsole.id."+i+".parent");
+      Gateway g = null;
       try {
-        g = Gateway.newGateway(nickname, serviceURL, parent_gateway);
+        g = Gateway.newGateway(nickname, str_jmxsurl, str_parent);
         if ( g != null ) {
           v_gateways.addElement(g);
         }
       } catch (Exception exep) {
-        System.out.println(""+exep);
+        System.out.println("Gateway creation error:\n "+exep.toString());
       }
-      i++;
-      profile = bc.getProperty("mosgi.jmxconsole.id."+i+".profile");
+      str_jmxsurl = bc.getProperty("mosgi.jmxconsole.id."+(++i)+".jmxsurl");
     }
+
     Gateway[] gateways=new Gateway[v_gateways.size()];
     v_gateways.toArray(gateways);
     return gateways;
   }
 
   // GUI gateway creator
-  public static Gateway newGateway() {
+  public static Gateway newGateway(Gateway ref) throws Exception {
     String nickname = JOptionPane.showInputDialog("Profil nickname", "");
-    if ( nickname == null) return null; // should check nickname is unique
-    String host = JOptionPane.showInputDialog("Host", DEFAULT_HOST);
-    if ( host == null ) return null;
-    String protocol = JOptionPane.showInputDialog("Protocol", DEFAULT_PROTOCOL);
-    if ( protocol==null ) return null;
-    String port = JOptionPane.showInputDialog("Port", DEFAULT_PORT);
-    try { Integer.parseInt(port); } catch (Exception ex) { return null; }
-    String profile = JOptionPane.showInputDialog("OSGi profil name", "");
-    if (profile==null) return null;
+    if ( nickname == null) return null;
+    String gateway_ref = ref!=null?ref+"":"";
+    String str_jmxsurl = JOptionPane.showInputDialog("JMX service URL", gateway_ref);
+    if ( str_jmxsurl == null) return null;
     Object gateway_list[] = HT_GATEWAY.keySet().toArray();
     Object gateway_list2[] = new Object[gateway_list.length+1];
     System.arraycopy(gateway_list, 0, gateway_list2, 1, gateway_list.length);
     gateway_list2[0] = "None";
     java.util.Arrays.sort(gateway_list);
-    int val = JOptionPane.showOptionDialog(new javax.swing.JFrame(), "Virtual of", "Is it
a virtual gateway ?", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, gateway_list2,
gateway_list2[0]);
-    String virtual = "";
-    if ( val != JOptionPane.CLOSED_OPTION ) { virtual = ""+gateway_list2[val]; }
-    if ( val == 0 ) { virtual = ""; }
-    String serviceURL = JMX_SERVICE+protocol+":///jndi/"+protocol+"://"+host+":"+port+"/"+profile;
-    Gateway g = null;
-    try { 
-      g = Gateway.newGateway(nickname, serviceURL, virtual);
-    } catch (Exception exep) {
-      System.out.println(""+exep);
-      return null;
-    }
-    return g;
+    int val = JOptionPane.showOptionDialog(new javax.swing.JFrame(), "Link to another gateway
?", "Gateway association", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null,
gateway_list2, gateway_list2[0]);
+    String str_parent = "";
+    if ( val != JOptionPane.CLOSED_OPTION ) { str_parent = ""+gateway_list2[val]; }
+    if ( val == 0 ) { str_parent = ""; }
+    return Gateway.newGateway(nickname, str_jmxsurl, str_parent);
   }
 
   public boolean connect(NotificationListener notificationListener) {

Modified: felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodeCellRenderer.java
URL: http://svn.apache.org/viewvc/felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodeCellRenderer.java?rev=669139&r1=669138&r2=669139&view=diff
==============================================================================
--- felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodeCellRenderer.java
(original)
+++ felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodeCellRenderer.java
Wed Jun 18 04:33:32 2008
@@ -42,7 +42,7 @@
     Object o = ((DefaultMutableTreeNode) value).getUserObject();
     if ( !o.equals(NodesTree.TOP_NAME) ) {
       Gateway g = (Gateway) o;
-      super.getTreeCellRendererComponent(tree, g.getName(), sel, expanded, leaf, row, hasFocus);
+      super.getTreeCellRendererComponent(tree, g.getNickname(), sel, expanded, leaf, row,
hasFocus);
       if ( g.isConnected() ) {
         setIcon(iconConnected);
       } else {

Modified: felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodesTree.java
URL: http://svn.apache.org/viewvc/felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodesTree.java?rev=669139&r1=669138&r2=669139&view=diff
==============================================================================
--- felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodesTree.java
(original)
+++ felix/trunk/mosgi/console.gui/src/main/java/org/apache/felix/mosgi/console/gui/NodesTree.java
Wed Jun 18 04:33:32 2008
@@ -175,10 +175,20 @@
   public void actionPerformed(ActionEvent ae) {
     Object object = ae.getSource();
     if ( object == jb_addNode ) { // Add a new node into tree
-      Gateway g = Gateway.newGateway();
-      if ( g != null ) {
+      DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
+      Gateway selectedGateway = null;
+      if ( node != null && node != top) {
+        selectedGateway = (Gateway) node.getUserObject();
+      }
+      Gateway newGateway = null;
+      try {
+        newGateway = Gateway.newGateway(selectedGateway);
+      } catch (Exception exep) {
+        JOptionPane.showMessageDialog(null, "Gateway creation error:\n "+exep.toString(),
"Error", JOptionPane.ERROR_MESSAGE);
+      }
+      if ( newGateway != null ) {
         TreePath tp = tree.getSelectionPath();
-        this.createTreeNode(g);
+        this.createTreeNode(newGateway);
         dtm.reload(top);
         isAllNodesConnected = false;
         tree.setSelectionPath(tp);
@@ -188,7 +198,7 @@
       if ( node != top) {
         Gateway g = (Gateway) node.getUserObject();
         if ( !node.equals(top) ){
-	  if( JOptionPane.showConfirmDialog(null, "Sure we remove this gateway \""+g.getName()+"\"
?\n "+g.toString()) == JOptionPane.YES_OPTION ) {
+	  if( JOptionPane.showConfirmDialog(null, "Sure we remove this gateway \""+g.getNickname()+"\"
?\n "+g.toString()) == JOptionPane.YES_OPTION ) {
             g.disconnect(this);
 	    dtm.removeNodeFromParent(node);
 	    System.out.println("Remove node : "+g);
@@ -271,8 +281,9 @@
       String packages = bc.getProperty("mosgi.jmxconsole.protocol."+protoName+".package");
       if ( packages == null ) {
         packages = "";
+      } else {
+        System.out.println("Protocol provider package for \""+protoName+"\" is prefixed with
\""+packages+"\"");
       }
-      System.out.println("Protocol provider package for \""+protoName+"\" = "+packages);
       PROTOCOL_PACKAGE_PROVIDER.put(protoName, packages);
       return packages;
     }

Modified: felix/trunk/mosgi/doc/config.properties.jmxconsole
URL: http://svn.apache.org/viewvc/felix/trunk/mosgi/doc/config.properties.jmxconsole?rev=669139&r1=669138&r2=669139&view=diff
==============================================================================
--- felix/trunk/mosgi/doc/config.properties.jmxconsole (original)
+++ felix/trunk/mosgi/doc/config.properties.jmxconsole Wed Jun 18 04:33:32 2008
@@ -35,17 +35,14 @@
 # mosgi.jmxconsole.rmiport.core=1099
 
 # NEW :
-mosgi.jmxconsole.id.1.nickname=main
-mosgi.jmxconsole.id.1.profile=core
-mosgi.jmxconsole.id.1.host=127.0.0.1
-mosgi.jmxconsole.id.1.protocol=rmi
-mosgi.jmxconsole.id.1.port=1099
-#mosgi.jmxconsole.id.1.jmxserviceurl=service:jmx:rmi:///jndi/rmi://127.0.0.1:1099/core
+# mosgi.jmxconsole.id.<number>.nickname is the gateway nickname used by the GUI (default
value is the gateway <number>)
+# mosgi.jmxconsole.id.<number>.jmxsurl is the string used to create the JMXServiceURL.
This string must look like this : service:jmx:<protocol>:<sap>, <protocol>
ie. "rmi", <sap> ie. "///jndi/rmi://127.0.0.1:1099/core"
+# More details on the JMXServiceURL class javadoc
+mosgi.jmxconsole.id.1.jmxsurl=service:jmx:rmi:///jndi/rmi://127.0.0.1:1099/core
+mosgi.jmxconsole.id.1.nickname=core std (rmi)
 
-mosgi.jmxconsole.id.2.profile=core2
-mosgi.jmxconsole.id.2.host=127.0.0.1
-mosgi.jmxconsole.id.2.protocol=rmi
-mosgi.jmxconsole.id.2.port=1100
+mosgi.jmxconsole.id.2.jmxsurl=service:jmx:ws://127.0.0.1:1100/core2
+mosgi.jmxconsole.id.2.nickname=core 2 (web service connector)
 
 felix.startlevel.framework=1
 felix.startlevel.bundle=1

Modified: felix/trunk/mosgi/doc/core.sh
URL: http://svn.apache.org/viewvc/felix/trunk/mosgi/doc/core.sh?rev=669139&r1=669138&r2=669139&view=diff
==============================================================================
--- felix/trunk/mosgi/doc/core.sh (original)
+++ felix/trunk/mosgi/doc/core.sh Wed Jun 18 04:33:32 2008
@@ -1,5 +1,6 @@
 #!/bin/sh
-rm -rf ~/.felix/core
+
+#rm -rf ~/.felix/core
 
 echo "cd into felix directory"
 cd ../../main

Modified: felix/trunk/mosgi/doc/jmxconsole.sh
URL: http://svn.apache.org/viewvc/felix/trunk/mosgi/doc/jmxconsole.sh?rev=669139&r1=669138&r2=669139&view=diff
==============================================================================
--- felix/trunk/mosgi/doc/jmxconsole.sh (original)
+++ felix/trunk/mosgi/doc/jmxconsole.sh Wed Jun 18 04:33:32 2008
@@ -1,5 +1,6 @@
 #!/bin/sh
-rm -rf ~/.felix/jmxconsole
+
+#rm -rf ~/.felix/jmxconsole
 
 echo "cd into felix directory"
 cd ../../main

Modified: felix/trunk/mosgi/jmx.agent/src/main/java/org/apache/felix/mosgi/jmx/agent/AgentActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/mosgi/jmx.agent/src/main/java/org/apache/felix/mosgi/jmx/agent/AgentActivator.java?rev=669139&r1=669138&r2=669139&view=diff
==============================================================================
--- felix/trunk/mosgi/jmx.agent/src/main/java/org/apache/felix/mosgi/jmx/agent/AgentActivator.java
(original)
+++ felix/trunk/mosgi/jmx.agent/src/main/java/org/apache/felix/mosgi/jmx/agent/AgentActivator.java
Wed Jun 18 04:33:32 2008
@@ -56,17 +56,10 @@
     AgentActivator.bc=context;
     this.version=(String)bc.getBundle().getHeaders().get(Constants.BUNDLE_VERSION);
     AgentActivator.log(LogService.LOG_INFO, "Starting JMX Agent "+version,null);
-    String profile=bc.getProperty(BundleCache.CACHE_PROFILE_PROP);
-    if (profile==null){
-      profile=System.getProperty(BundleCache.CACHE_PROFILE_PROP);
-     }
-    String virtual=bc.getProperty("mosgi.jmxconsole.core."+profile);
     StringTokenizer st=new StringTokenizer(System.getProperty("java.version"), ".");
     st.nextToken();
-    int minor=Integer.parseInt(st.nextToken());
-
-    System.out.println("VIRTUAL OOOO "+virtual+" : "+profile);
-    this.startAgent(virtual, minor);
+    int minorVersion = Integer.parseInt(st.nextToken());
+    this.startAgent(minorVersion);
     this.registerExistingMBeans();
     bc.addServiceListener(this);
   }
@@ -110,11 +103,9 @@
     }
   }
 
-  private void startAgent(String virtual, int minor){
-    if (virtual==null && minor >=5){
-      Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
-      //this.server= ManagementFactory.getPlatformMBeanServer();
-      this.server = MBeanServerFactory.createMBeanServer();
+  private void startAgent(int minor){
+    if ( minor >= 5 ){
+      this.server = java.lang.management.ManagementFactory.getPlatformMBeanServer();
       AgentActivator.log(LogService.LOG_DEBUG, "A jdk1.5 agent started "+this.server,null);
     }else {
       Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());



Mime
View raw message