May 11, 2020
Estimated Post Reading Time ~

Osgi Config Dashboard

Apache Felix framework provides restful APIs to access OSGi bundle info over regular HTML and JSON format. if requests are sent with the .json extension; e.g. .../bundles/id.json. or .../bundle.json the JSON response of bundle will be returned. more info available at https://felix.apache.org/documentation/subprojects/apache-felix-web-console/web-console-restful-api.html

But for OSGi configs, there is no JSON API is available to fetch OSGi config as JSON response, though plain text representation of configuration can be seen at http://host:port/system/console/status-Configurations with web console access.

OSGi Configuration API
I created an API to return modified OSGi configurations as JSON response, available at https://github.com/arunpatidar02/osgi-config-api

OSGi Config Dashboard
I consume the above API and created a landing page in AEM, which shows the OSGi configs with filter and sorting options.
Package available at https://github.com/arunpatidar02/osgi-config-api/blob/master/aem-tools-osgiconfig-1.zip

Note: This zip package contains only nodes and UI code but doesn't contain OSGi bunndle(Servlet and other Java class). These java classes can be copied for github and use.

Dashboard page url - http://localhost:4502/osgiconfig

Osgi Configuration Dashboard Page

Filter
Results can be filtered using text and/or repository based configurations.
Text enter in 'Enter keyword' look for pid, factoryPid and Properties, if anyone of matches then result returns for that OSGi config.
Filter dropdown had two options All and Repository based.
if Repository based selected then all the repository based configs will be returned in the combination of text entered in 'Enter keyword' field otherwise all configs will be returned in the combination of text entered in 'Enter keyword' field.

Note: Result filtering is taking place at the client side, there is no request sent to the server to fetch new results.
OSGi configs only getting fetched once on page load and filtering/sorting is done at client side.


Filter section


Filtered Result - Repository based


Filtered Result - keyword + Repository based


Filtered Result - Keyword

Sorting
Results can be sorted either by pid or Repository based config.


Properties
When clicking on more info icon for OSGi config a popup will be shown which contains the following info:
  • Pid
  • factoryPid - if the config is a type of factory config
  • Change count
  • Repository Paths - if the config is repository based(sling: OsgiConfig)
  • Properties


Conclusion
This dashboard is an example of to consume API and can be used in non-prod instance to check OSGi configs if the users don't have access to the web console but the user should have read access at /apps, /conf and /libs (or alternatively sub-service session can be used in the servlet while executing query to fetch repository based config).


By aem4beginner

No comments:

Post a Comment

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