geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwo...@apache.org
Subject svn commit: r890689 - in /geronimo/sandbox/rex: org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/agent/ org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/ org.apache.geron...
Date Tue, 15 Dec 2009 08:40:34 GMT
Author: rwonly
Date: Tue Dec 15 08:40:34 2009
New Revision: 890689

URL: http://svn.apache.org/viewvc?rev=890689&view=rev
Log:
some updates and fixes

Modified:
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/agent/Activator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/Activator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintMetadata.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintState.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintMetadataMBean.java

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/agent/Activator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/agent/Activator.java?rev=890689&r1=890688&r2=890689&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/agent/Activator.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/agent/Activator.java
Tue Dec 15 08:40:34 2009
@@ -1,5 +1,7 @@
 package org.apache.geronimo.blueprint.jmx.agent;
 
+import java.lang.management.ManagementFactory;
+
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
 import javax.management.remote.JMXConnectorServer;
@@ -15,17 +17,22 @@
     protected ServiceRegistration mbsReg;
     
     public void start(BundleContext context) throws Exception {
-        
+        // Create a MBean Server
+        //MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
         MBeanServer mbs = MBeanServerFactory.createMBeanServer();
         
-        // Create an RMI connector and start it, need "rmiregistry 9999" in cmd of Windows
-        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/server");
-        JMXConnectorServer connServer = JMXConnectorServerFactory.newJMXConnectorServer(url,
null, mbs);
-        connServer.start();
-        System.out.println("rmi..start.....");
-        
         // Register as a service
         mbsReg = context.registerService(MBeanServer.class.getCanonicalName(), mbs, null);
+        
+        // Create an RMI connector and start it, need first "rmiregistry 9999" in cmd of
Windows
+        try{
+            JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/server");
+            JMXConnectorServer connServer = JMXConnectorServerFactory.newJMXConnectorServer(url,
null, mbs);
+            connServer.start();
+            System.out.println("JMX Connect Server @ service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/server
start.....");
+        } catch (RuntimeException e){
+            e.printStackTrace();
+        }
     }
 
     public void stop(BundleContext context) throws Exception {

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/Activator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/Activator.java?rev=890689&r1=890688&r2=890689&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/Activator.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/Activator.java
Tue Dec 15 08:40:34 2009
@@ -40,37 +40,30 @@
         this.blueprintStateName = new ObjectName(BlueprintStateMBean.OBJECTNAME);
         this.blueprintMetadataName = new ObjectName(BlueprintMetadataMBean.OBJECTNAME);
 
-        // get mbeanServiceTracker
+        // create MBeanServerServiceTracker
+        // if there has been already a MBeanServer Service in place, this MBeanServerServiceTracker
won't miss it
         mbeanServiceTracker = new ServiceTracker(bundleContext, MBeanServer.class.getCanonicalName(),
-                new MBeanServiceTracker());
+                new MBeanServerServiceTracker());
         System.out.println("Awaiting MBeanServer service registration"); // Fine
         mbeanServiceTracker.open();
     }
 
     public void stop(BundleContext context) throws Exception {
-        mbeanServiceTracker.close();
         for (MBeanServer mbeanServer : mbeanServers) {
-            deregisterServices(mbeanServer);
+            this.deregisterMBeans(mbeanServer);
         }
+        mbeanServiceTracker.close();
         mbeanServers.clear();
     }
 
-    class MBeanServiceTracker implements ServiceTrackerCustomizer {
+    class MBeanServerServiceTracker implements ServiceTrackerCustomizer {
 
         public Object addingService(ServiceReference servicereference) {
             try {
                 System.out.println("Adding MBeanServer: " + servicereference); // Fine
                 final MBeanServer mbeanServer = (MBeanServer) bundleContext.getService(servicereference);
-                mbeanServers.add(mbeanServer);
-                Runnable registration = new Runnable() {
-                    public void run() {
-                        Activator.this.registerServices(mbeanServer);
-                    }
-                };
-                Thread registrationThread = new Thread(registration, "Blueprint MBean Registration");
-                registrationThread.setDaemon(true);
-                registrationThread.start();
-
+                Activator.this.mbeanServers.add(mbeanServer);
+                Activator.this.processRegister(mbeanServer);
                 return mbeanServer;
             } catch (RuntimeException e) {
                 System.out.println("uncaught exception in addingService" + e); // Severe
@@ -78,34 +71,49 @@
             }
         }
 
-        public void modifiedService(ServiceReference servicereference, Object obj) {
-            // no op
-        }
-
         public void removedService(ServiceReference servicereference, Object obj) {
             try {
                 System.out.println("Removing MBeanServer: " + servicereference); // Fine
                 final MBeanServer mbeanServer = (MBeanServer) bundleContext.getService(servicereference);
-                mbeanServers.remove(mbeanServer);
-                Runnable deregister = new Runnable() {
-                    public void run() {
-                        Activator.this.deregisterServices(mbeanServer);
-                    }
-                };
-
-                Thread deregisterThread = new Thread(deregister, "Blueprint MBean Deregistration");
-                deregisterThread.setDaemon(true);
-                deregisterThread.start();
-
+                Activator.this.mbeanServers.remove(mbeanServer);
+                Activator.this.processDeregister(mbeanServer);
             } catch (Throwable e) {
                 System.out.println("uncaught exception in removedService"); // Fine
             }
         }
+
+        public void modifiedService(ServiceReference servicereference, Object obj) {
+            // no op
+        }
+
     }
 
-    protected synchronized void registerServices(MBeanServer mbeanServer) {
-        // create BlueprintStateMBean
+    private void processRegister(final MBeanServer mbeanServer) {
+        Runnable registration = new Runnable() {
+            public void run() {
+                Activator.this.registerMBeans(mbeanServer);
+            }
+        };
+        Thread registrationThread = new Thread(registration, "Blueprint MBeans Registration");
+        registrationThread.setDaemon(true);
+        registrationThread.start();
+
+    }
+
+    private void processDeregister(final MBeanServer mbeanServer) {
+        Runnable deregister = new Runnable() {
+            public void run() {
+                Activator.this.deregisterMBeans(mbeanServer);
+            }
+        };
+
+        Thread deregisterThread = new Thread(deregister, "Blueprint MBeans Deregistration");
+        deregisterThread.setDaemon(true);
+        deregisterThread.start();
+    }
 
+    protected synchronized void registerMBeans(MBeanServer mbeanServer) {
+        // create BlueprintStateMBean
         /* the StardardMBean does not implement the MBeanRegistration in jdk1.5 */
         try {
             blueprintState = new RegistrationStandardMBean(new BlueprintState(bundleContext),
BlueprintStateMBean.class);
@@ -135,7 +143,7 @@
             return;
         }
         // register BlueprintMetadataMBean to MBean server
-        System.out.println("Registering bundle state monitor with MBeanServer: " + mbeanServer
+ " with name: "
+        System.out.println("Registering bundle metadata monitor with MBeanServer: " + mbeanServer
+ " with name: "
                 + blueprintMetadataName); // Fine
         try {
             mbeanServer.registerMBean(blueprintMetadata, blueprintMetadataName);
@@ -150,7 +158,7 @@
         servicesRegistered.set(true);
     }
 
-    protected synchronized void deregisterServices(MBeanServer mbeanServer) {
+    protected synchronized void deregisterMBeans(MBeanServer mbeanServer) {
         if (!servicesRegistered.get()) {
             return;
         }
@@ -177,5 +185,4 @@
         servicesRegistered.set(false);
     }
 
-
 }

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintMetadata.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintMetadata.java?rev=890689&r1=890688&r2=890689&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintMetadata.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintMetadata.java
Tue Dec 15 08:40:34 2009
@@ -2,7 +2,6 @@
 
 import java.io.IOException;
 import java.util.Collection;
-import java.util.Set;
 
 import javax.management.openmbean.CompositeData;
 

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintState.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintState.java?rev=890689&r1=890688&r2=890689&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintState.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintState.java
Tue Dec 15 08:40:34 2009
@@ -61,8 +61,12 @@
     }
 
     public void preDeregister() throws Exception {
-        // unreg Listener
-        listenerReg.unregister();
+        // deregister Listener
+        try{
+            listenerReg.unregister();
+        }catch(Exception e){
+            e.printStackTrace();
+        }
     }
 
     public void postDeregister() {

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintMetadataMBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintMetadataMBean.java?rev=890689&r1=890688&r2=890689&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintMetadataMBean.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintMetadataMBean.java
Tue Dec 15 08:40:34 2009
@@ -321,7 +321,7 @@
     Item            VALUES_ITEM             = new Item(
                                                     VALUES,
                                                     "All the values",
-                                                    Item.arrayType(1, JmxConstants.BYTE_ARRAY_TYPE));
+                                                    Item.arrayType(2, JmxConstants.BYTE_ARRAY_TYPE));
     
 
     /**
@@ -579,7 +579,7 @@
                                                     SimpleType.STRING);
 
     /**
-     * The key ARGUMENT, used in {@link #BEAN_ARGUMENTS_ITEM}.
+     * The key ARGUMENT, used in {@link #ARGUMENTS_ITEM}.
      */
     String          ARGUMENTS                   = "Arguments";
         
@@ -731,6 +731,7 @@
      * The item containing the auto-export mode for the service.
      * The key is {@link #AUTO_EXPORT}, and the type is {@link SimpleType#INTEGER}.
      */
+    //TODO describe integer
     Item            AUTO_EXPORT_ITEM        = new Item(
                                                     AUTO_EXPORT, 
                                                     "The auto-export mode for the service",

@@ -887,7 +888,9 @@
     /**
      * The item specify whether or not a matching service is required at all times.
      * The key is {@link #AVAILABILITY}, and the type is {@link SimpleType#INTEGER}.
+     * 
      */
+    //TODO add description for each int
     Item            AVAILABILITY_ITEM       = new Item(
                                                     AVAILABILITY, 
                                                     "To specify whether or not a matching
service is required at all times", 
@@ -1062,6 +1065,7 @@
      * @param type The string used to specify the type of component
      * @return the array of component id
      */
+    //TODO add description for type
     public String[] getComponentIdsByType(long containerServiceId, String type);
     
     /**



Mime
View raw message