geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwo...@apache.org
Subject svn commit: r886069 - in /geronimo/sandbox/rex: ./ org.apache.geronimo.blueprint.jmx.impl/ org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/ org.apache.geronimo.blueprint.jmx/
Date Wed, 02 Dec 2009 08:03:20 GMT
Author: rwonly
Date: Wed Dec  2 08:03:19 2009
New Revision: 886069

URL: http://svn.apache.org/viewvc?rev=886069&view=rev
Log:
Temply Create MBean Service in impl's activator

Modified:
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/pom.xml
    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/RegistrationStandardMBean.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/pom.xml
    geronimo/sandbox/rex/pom.xml

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/pom.xml?rev=886069&r1=886068&r2=886069&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/pom.xml (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/pom.xml Wed Dec  2 08:03:19
2009
@@ -3,13 +3,13 @@
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.geronimo.blueprint</groupId>
-        <artifactId>org.apache.geronimo.blueprint.jmx-parent</artifactId>
+        <artifactId>jmx-parent</artifactId>
         <version>1.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>org.apache.geronimo.blueprint.jmx.impl</artifactId>
     <packaging>bundle</packaging>
-    <name>org.apache.geronimo.blueprint.jmx.impl</name>
+    <name>Apache Geronimo Blueprint Jmx Implementation</name>
   
     <dependencies>
         <dependency>
@@ -49,6 +49,11 @@
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
+					    <Bundle-SymbolicName>org.apache.geronimo.blueprint.jmx.impl</Bundle-SymbolicName>
+						<Bundle-Name>Apache Geronimo Blueprint Jmx Implementation</Bundle-Name>
+						<Bundle-Description>Apache Geronimo Blueprint Jmx implementation.</Bundle-Description>
+						<Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+						<Export-Package>org.apache.geronimo.blueprint.jmx.impl*</Export-Package>
                         <Bundle-Activator>org.apache.geronimo.blueprint.jmx.impl.Activator</Bundle-Activator>
                      </instructions>
                 </configuration>

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=886069&r1=886068&r2=886069&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
Wed Dec  2 08:03:19 2009
@@ -8,15 +8,20 @@
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanRegistrationException;
 import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
 import javax.management.StandardMBean;
+import javax.management.remote.JMXConnectorServer;
+import javax.management.remote.JMXConnectorServerFactory;
+import javax.management.remote.JMXServiceURL;
 
 import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
 import org.apache.geronimo.blueprint.jmx.BlueprintStateMBean;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
 import org.osgi.util.tracker.ServiceTracker;
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
@@ -24,9 +29,9 @@
 
     protected BundleContext bundleContext;
 
-    /* the StardardMBean does not implement the MBeanRegistration in jdk1.5*/   
-    //protected StandardMBean blueprintState;
-    protected BlueprintState blueprintState;
+    protected ServiceRegistration mbsReg;
+    
+    protected StandardMBean blueprintState;
     protected ObjectName blueprintStateName;
 
     protected StandardMBean blueprintMetadata;
@@ -47,6 +52,11 @@
                 new MBeanServiceTracker());
         System.out.println("Awaiting MBeanServer service registration"); // Fine
         mbeanServiceTracker.open();
+        
+        // create JMX agent. This could be in a separate bundle.
+        MBeanServer mbs = createJMXAgent();
+        // reg mbeanServer
+        mbsReg = context.registerService(MBeanServer.class.getCanonicalName(), mbs, null);
     }
 
     public void stop(BundleContext context) throws Exception {
@@ -55,6 +65,9 @@
             deregisterServices(mbeanServer);
         }
         mbeanServers.clear();
+        
+        // move mbs
+        mbsReg.unregister();
     }
 
     class MBeanServiceTracker implements ServiceTrackerCustomizer {
@@ -109,13 +122,12 @@
         // create BlueprintStateMBean
         
         /* the StardardMBean does not implement the MBeanRegistration in jdk1.5*/       

-        //        try {
-        //            blueprintState = new RegistrationStandardMBean(new BlueprintState(bundleContext),
BlueprintStateMBean.class);
-        //        } catch (NotCompliantMBeanException e) {
-        //            System.out.println("Unable to create StandardMBean for BlueprintState"
+ e); // Severe
-        //            return;
-        //        }
-        blueprintState = new BlueprintState(bundleContext);
+        try {
+            blueprintState = new RegistrationStandardMBean(new BlueprintState(bundleContext),
BlueprintStateMBean.class);
+        } catch (NotCompliantMBeanException e) {
+            System.out.println("Unable to create StandardMBean for BlueprintState" + e);
// Severe
+            return;
+        }
         
         // register BlueprintStateMBean to MBean server
         System.out.println("Registering bundle state monitor with MBeanServer: " + mbeanServer
+ " with name: "
@@ -179,5 +191,24 @@
 
         servicesRegistered.set(false);
     }
+    
+    
+    private MBeanServer createJMXAgent() throws Exception {    
+        MBeanServer server = MBeanServerFactory.createMBeanServer();    
+        // Create an RMI connector and start it    
+        try{
+        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/server");
  
+        JMXConnectorServer connServer = JMXConnectorServerFactory.newJMXConnectorServer(url,
null, server);    
+        connServer.start();    
+        System.out.println("rmi¬°¬°start....."); 
+        }
+        catch(Exception e){
+            e.printStackTrace();
+        }
+        
+        
+        
+        return server;
+    }    
 
 }

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/RegistrationStandardMBean.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/RegistrationStandardMBean.java?rev=886069&r1=886068&r2=886069&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/RegistrationStandardMBean.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/RegistrationStandardMBean.java
Wed Dec  2 08:03:19 2009
@@ -6,48 +6,46 @@
 import javax.management.ObjectName;
 import javax.management.StandardMBean;
 
-public class RegistrationStandardMBean /*extends StandardMBean*/ {
+public class RegistrationStandardMBean extends StandardMBean implements MBeanRegistration
{
+    
+    // in java 6, StandardMBean implements MBeanRegistration, but it does not in java 5.
+
+    public <T> RegistrationStandardMBean(T implementation, Class<T> mbeanInterface)

+        throws NotCompliantMBeanException {
+        super(implementation, mbeanInterface);
+    }
+
+    public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
+        //name = super.preRegister(server, name);
+        Object impl = getImplementation();
+        if (impl instanceof MBeanRegistration) {
+            return ((MBeanRegistration) impl).preRegister(server, name);
+        }
+        return name;
+    }
+
+    public void postRegister(Boolean registrationDone) {
+        //super.postRegister(registrationDone);
+        Object impl = getImplementation();
+        if (impl instanceof MBeanRegistration) {
+            ((MBeanRegistration) impl).postRegister(registrationDone);
+        }
+    }
+
+    public void preDeregister() throws Exception {
+        //super.preDeregister();
+        Object impl = getImplementation();
+        if (impl instanceof MBeanRegistration) {
+            ((MBeanRegistration) impl).preDeregister();
+        }
+    }
 
-//    public <T> RegistrationStandardMBean(T implementation, Class<T> mbeanInterface)

-//        throws NotCompliantMBeanException {
-//        super(implementation, mbeanInterface);
-//    }
-//
-//    @Override
-//    public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
{
-//        name = super.preRegister(server, name);
-//        Object impl = getImplementation();
-//        if (impl instanceof MBeanRegistration) {
-//            return ((MBeanRegistration) impl).preRegister(server, name);
-//        }
-//        return name;
-//    }
-//
-//    @Override
-//    public void postRegister(Boolean registrationDone) {
-//        super.postRegister(registrationDone);
-//        Object impl = getImplementation();
-//        if (impl instanceof MBeanRegistration) {
-//            ((MBeanRegistration) impl).postRegister(registrationDone);
-//        }
-//    }
-//
-//    @Override
-//    public void preDeregister() throws Exception {
-//        super.preDeregister();
-//        Object impl = getImplementation();
-//        if (impl instanceof MBeanRegistration) {
-//            ((MBeanRegistration) impl).preDeregister();
-//        }
-//    }
-//
-//    @Override
-//    public void postDeregister() {
-//        super.postDeregister();
-//        Object impl = getImplementation();
-//        if (impl instanceof MBeanRegistration) {
-//            ((MBeanRegistration) impl).postDeregister();
-//        }
-//    }
+    public void postDeregister() {
+        //super.postDeregister();
+        Object impl = getImplementation();
+        if (impl instanceof MBeanRegistration) {
+            ((MBeanRegistration) impl).postDeregister();
+        }
+    }
     
 }

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/pom.xml?rev=886069&r1=886068&r2=886069&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/pom.xml (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/pom.xml Wed Dec  2 08:03:19 2009
@@ -3,12 +3,30 @@
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.geronimo.blueprint</groupId>
-        <artifactId>org.apache.geronimo.blueprint.jmx-parent</artifactId>
+        <artifactId>jmx-parent</artifactId>
         <version>1.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>org.apache.geronimo.blueprint.jmx</artifactId>
     <packaging>bundle</packaging>
-    <name>org.apache.geronimo.blueprint.jmx</name>
+    <name>Apache Geronimo Blueprint Jmx API</name>
 
+	<build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+						<Bundle-SymbolicName>org.apache.geronimo.blueprint.jmx</Bundle-SymbolicName>
+						<Bundle-Name>Apache Geronimo Blueprint Jmx API</Bundle-Name>
+						<Bundle-Description>Apache Geronimo Blueprint Jmx api.</Bundle-Description>
+						<Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+						<Export-Package>org.apache.geronimo.blueprint.jmx</Export-Package>
+                     </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>

Modified: geronimo/sandbox/rex/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/pom.xml?rev=886069&r1=886068&r2=886069&view=diff
==============================================================================
--- geronimo/sandbox/rex/pom.xml (original)
+++ geronimo/sandbox/rex/pom.xml Wed Dec  2 08:03:19 2009
@@ -2,25 +2,13 @@
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.apache.geronimo.blueprint</groupId>
-    <artifactId>org.apache.geronimo.blueprint.jmx-parent</artifactId>
+    <artifactId>jmx-parent</artifactId>
     <packaging>pom</packaging>
     <version>1.0-SNAPSHOT</version>
     <name>org.apache.geronimo.blueprint.jmx-parent</name>
   
-    <dependencies>
-    </dependencies>
-
     <build>
-        <pluginManagement>
-            <plugins>
-                <plugin>
-                    <groupId>org.apache.felix</groupId>
-                    <artifactId>maven-bundle-plugin</artifactId>
-                    <version>2.0.1</version>
-                    <extensions>true</extensions>
-                </plugin>
-            </plugins>
-        </pluginManagement>
+    <pluginManagement>
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
@@ -33,13 +21,17 @@
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.0.1</version>
+                <extensions>true</extensions>
             </plugin>
-       </plugins>
+        </plugins>
+    </pluginManagement>
+    <plugins></plugins>
     </build>
 
     <modules>
-       <module>org.apache.geronimo.blueprint.jmx</module>
-       <module>org.apache.geronimo.blueprint.jmx.impl</module>
+        <module>org.apache.geronimo.blueprint.jmx</module>
+        <module>org.apache.geronimo.blueprint.jmx.impl</module>
     </modules>
 
 </project>



Mime
View raw message