karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Moulliard <ch0...@gmail.com>
Subject Register a bean as a MBean (JMX)
Date Wed, 03 Oct 2012 16:12:19 GMT
Hi,

I have developed a small project to register a bean as a JMX Mbean. The
code looks the same as org.apache.karaf.web.management.internal.Web of
Karaf

1. Interface

package com.fusesource.poc.service;

public interface ServiceMBean {

    String sayHello();

}

2. Impl

package com.fusesource.poc.service.impl;

import com.fusesource.poc.service.ServiceMBean;

import javax.management.NotCompliantMBeanException;
import javax.management.StandardMBean;

public class MyService extends StandardMBean implements ServiceMBean {

    public MyService() throws NotCompliantMBeanException {
        super(ServiceMBean.class);
    }

    @Override
    public String sayHello() {
        return ">> Good morning from Weather Team";
    }
}

3. Blueprint

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="
           http://www.osgi.org/xmlns/blueprint/v1.0.0
              http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

    <bean id="service" class="com.fusesource.poc.service.impl.MyService"/>

    <service ref="service" auto-export="interfaces">
        <service-properties>
            <entry key="jmx.objectname"
value="com.fusesource.poc.service:type=service,name=feedback" />
        </service-properties>
    </service>

</blueprint>

Remark : no error is reported in the console of karaf

Unfortunately, when my bundle is started, I cannot see it registered in
MBean server - JConsole. Is there something that I missed ?

Regards

-- 
Charles Moulliard
Apache Committer / Sr. Enterprise Architect (RedHat)
Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com

Mime
View raw message