March 20, 2020
Estimated Post Reading Time ~

Visualize OSGi Service Graphs with Composum

What is Composum?
Composum is an Open-Source project based on Apache Sling, which is a set of useful tools and a
a framework to work with Apache Sling framework easily

Modules of Composum: Nodes, Pages, Assets, Platform
Composum Platform: This is the central services to set up an Apache Sling based application platform
Composum Pages: Pages provide the content management feature of the Composum platform
Composum Assets: This is the image asset management feature of the Composum
Composum Nodes: Resource/JCR development tool with core API for all Composum modules.
Use case with AEM: Composum helps to create a diagram representation of the OSGI service dependencies

Here’s a neat trick for AEM developers and architects: you can create a diagram representation of the service dependencies using Composum. For those not familiar, Composum is an Open-Source project based on Apache Sling.
To create a service dependency diagram, you will need to install two additional dependencies:
Composum Sling Core Console
Composum Sling Core Commons

Once you install the dependencies, you can access the Composum Service Graph web console at /system/console/servicegraph.

 

Using the Service Graph Web Console
The Service Graph Web Console has a couple fields, the most important being the Classnames Regex. You can put any regular expression to filter what classes should be including:
^com.composum
^com.day.cq.wcm.foundation.forms

Every OSGi Service matching the regular expression will be included in the graph. Note that having too broad of a regular expression, such as ^com.adobe or ^org will cause the graph to fail to render, so make sure to narrow down as much as possible.
Downloading as an Image
Currently, the Service Graph is only available as an SVG, not a downloadable image, but using the following JavaScript snippet you can download the Service Graph:

function svg2img(){
var svg = document.querySelector('svg');
var xml = new XMLSerializer().serializeToString(svg);
var svg64 = btoa(xml);
var b64start = 'data:image/svg+xml;base64,';
var image64 = b64start + svg64;
return image64;
};

var img = document.createElement('img');
img.src = svg2img();
document.body.appendChild(img);

Reference: https://blogs.perficient.com/2019/10/09/visualize-osgi-service-graphs-with-composum/


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.