This example shows different ways to register a JMX MBean in the Apache Karaf MBeanServer.
It exposes a MBean interacting with a BookingService
.
- karaf-mbean-example-api is a common bundle providing the
Booking
POJO and aBookingService
interface. - karaf-mbean-example-provider is a very simple bundle providing a
BookingService
implementation. - karaf-mbean-example-simple is a bundle doing a MBean registration using the Karaf util
- karaf-mbean-example-blueprint is a bundle doing a MBean registration using blueprint
- karaf-mbean-example-scr is a bundle doing a MBean registration using SCR
The build uses Apache Maven. Simply use:
mvn clean install
On a running Karaf instance, register the features repository:
karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-mbean-example-features/LATEST/xml
Then you can install the service provider feature:
karaf@root()> feature:install karaf-mbean-example-provider
Then you can test the different registration approach:
- To use the Karaf util registration, you install the
karaf-mbean-example-simple
feature:
karaf@root()> feature:install karaf-mbean-example-simple
- To use the blueprint registration, you install the
karaf-mbean-example-blueprint
feature:
karaf@root()> feature:install karaf-mbean-example-blueprint
- To use the SCR registration, you install the
karaf-mbean-example-scr
feature:
karaf@root()> feature:install karaf-mbean-example-scr
Once you have installed a feature registering the MBean, you can see the MBean using any JMX client, like jconsole
.