AEM Developer Series
- Day 00: AEM Developer Series
- Day 01: Introduction to AEM
- Day 02: AEM Architecture
- Day 03: Setting up AEM Development Environment
- Day 04: Developing First OSGi Bundle
- Day 05: Working with Sling Servlets in AEM
- Day 06: Playing with Sling Post Servlet
- Day 07: Creating your first component in AEM
- Day 08: Dueling with JavaScript Use API
- Day 09: Dueling with Java Use API
- Day 10: Getting to know Sling Models
- Day 11: Client Libraries in Action
- Day 12: Creating your custom OSGi Configuration
- Day 13: Schedulers in AEM
- Day 14: Eventing in AEM
- Day 15: Custom Workflows in AEM
- Day 16: Creating JMX Beans in AEM
- Day 17: Working with QueryBuilder API
- Day 18: Working with Granite Datasources in AEM
- Day 19: Replication API in Action
- Day 20: Working with Users and Groups in AEM
In AEM also, sometimes we need to use this architecture to manage resources dynamically. Although AEM provides a rich set of out of the box MBeans, we also create our own MBeans as and when required.
In this post, we will be creating an MBean that will take a set of input parameters and return the status of all the bundles/services/components in the AEM instance in a JSON format.
Let us look at the steps of creating such an MBean.
Create an MBean
- The first step is to create the layout of our MBean. By layout, I mean the input parameters that the MBean requires to function.
- All the parameters are specified by the specified parameters. In our case, we need the server's hostname, port number and the entity which we want to examine (bundles/services/components).
- Create an interface named SystemInfo and paste the following code in it Here we have three methods that take host, port and protocol and gives us the JSON response of the bundles, services and components
- Now let us create the implementation class of the SystemInfo interface and paste the following code in it Here we are registering this class of service DynamicMBean which exposes a dynamic management interface. We are using property jmx.objectname which defines the name of our MBean. We are reading the passed parameters and creating an appropriate URL to get the JSON response.
- Now deploy the code and navigate to http://<host>:<port>/system/console/jmx. There you will see all the registered MBean. Search for your MBean.
![]() |
System Info MBean |
- Open the MBean, you will see three methods each for bundles, components and services.
- Open the getBundles() methods, and configure it. After clicking on invoke, you will see the JSON response returned.
![]() |
JSON Response returned |
Conclusion
Congratulations!! 🙋 today we have worked with MBeans and their configurations. I hope you enjoyed this post.
You can find the complete code of this project on my GitHub in this commit. Feel free to fork or open issues, if any.
I would love to hear your thoughts on this and would like to have suggestions from you to make it better.
Happy Coding 😊
In conclusion error
ReplyDelete"Congratulations!! Today we have worked with Clientlibs and their basic structures and properties. I hope you enjoyed this post."
My bad. Long hours of work lead to careless copy pasting. Fixed it. Thanks for pointing that out.
Delete