You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2013/09/30 17:04:07 UTC

svn commit: r1527605 - /karaf/trunk/manual/src/main/webapp/users-guide/jmx.conf

Author: jbonofre
Date: Mon Sep 30 15:04:06 2013
New Revision: 1527605

URL: http://svn.apache.org/r1527605
Log:
Upgrade JMX section of the manual about MBean registration

Modified:
    karaf/trunk/manual/src/main/webapp/users-guide/jmx.conf

Modified: karaf/trunk/manual/src/main/webapp/users-guide/jmx.conf
URL: http://svn.apache.org/viewvc/karaf/trunk/manual/src/main/webapp/users-guide/jmx.conf?rev=1527605&r1=1527604&r2=1527605&view=diff
==============================================================================
--- karaf/trunk/manual/src/main/webapp/users-guide/jmx.conf (original)
+++ karaf/trunk/manual/src/main/webapp/users-guide/jmx.conf Mon Sep 30 15:04:06 2013
@@ -28,7 +28,7 @@ h2. MBeans
 
 Apache Karaf provides the following MBeans:
 
-* org.apache.karaf:type=admin to administrate the child instances
+* org.apache.karaf:type=instances to administrate the child instances
 * org.apache.karaf:type=bundles to manipulate the OSGi bundles
 * org.apache.karaf:type=config to manipulate the Karaf configuration files (in the etc folder) and the ConfigAdmin layer
 * org.apache.karaf:type=dev to get information and manipulate the OSGi framework
@@ -47,72 +47,18 @@ h1. Registering its own MBean(s)
 The Karaf container exposes a MBeanServer as an OSGI service. This server is created when Karaf boots and can be used to registers its own MBeans. The processus is really simple as it only
 requires that the bean/pojo of the project extend the javax.management.StandardMBean class and implements an interface where the name of the class MUST contain the extension MBean.
 
-Here is an example based on Karaf WebMBean
+Karaf 3.x simplifies a lot the process of custom MBean registration.
 
-1. Interface definition
+You just have to write your MBean and register it as an OSGi service (using Blueprint for instance), providing the JMX ObjectName property:
 
-As mentioned before, remark that we have added MBean after Web word.
 {code}
-/**
- * Describe the web MBean.
- */
-public interface WebMBean {
-...
-}
-{code}
-
-2. Implementation
-
-The class must extend the javax.management.StandardMBean class and implements the interface
-{code}
-/**
- * Implementation of the web MBean.
- */
-public class Web extends StandardMBean implements WebMBean {
-
-    private WebContainerService webContainerService;
-
-    public Web() throws NotCompliantMBeanException {
-        super(WebMBean.class);
-    }
-...
-{code}
-
-3. Blueprint file
-
-The blueprint file will contain definition of the beans to be instantiated and OSGI services to look up or register. Basically, 2 things should be done : lookup to retrieve
-the MBeanServer and next registers its Mbean using the MBeanRegister of Karaf
-{code}
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+    <bean id="customMBean" class="...."/>
 
-    <!-- Reference to the MBean Server -->
-    <reference id="mbeanServer" interface="javax.management.MBeanServer">
-        <reference-listener ref="mbeanRegistrer" bind-method="registerMBeanServer" unbind-method="unregisterMBeanServer"/>
-    </reference>
-
-    <!-- Web MBean -->
-    <bean id="webMBean" class="org.apache.karaf.management.mbeans.web.internal.WebMBeanImpl">
-        <property name="bundleContext" ref="blueprintBundleContext"/>
-    </bean>
-
-    <!-- MBean Registrer -->
-    <bean id="mbeanRegistrer" class="org.apache.karaf.management.MBeanRegistrer" init-method="init" destroy-method="destroy">
-        <property name="mbeans">
-            <map>
-                <entry value="org.apache.karaf:type=web,name=${karaf.name}" key-ref="webMBean"/>
-            </map>
-        </property>
-    </bean>
-
-</blueprint>
-{code}
-
-Remark : Next versions of Karaf 3.x will simplify this process as you can see here after
-
-{code}
-    <service ref="webMBean" auto-export="interfaces">
+    <service ref="customMBean" auto-export="interfaces">
         <service-properties>
-            <entry key="jmx.objectname" value="org.apache.karaf:type=web,name=${karaf.name}"/>
+            <entry key="jmx.objectname" value="my.domain:type=custom,name=${karaf.name}"/>
         </service-properties>
     </service>
-{code}
\ No newline at end of file
+{code}
+
+The customMBean is a simple POJO implementing the MBeanRegistration interface (and your own interface).
\ No newline at end of file