Skip to content

Conversation

@dgriffon
Copy link
Member

@dgriffon dgriffon commented Jan 12, 2026

fixes #616

Description

Browse cnd files to extract nodetypes used and provided
Browse XML files to extract used nodetypes

Store used/provided nodetypes in OSGi require/provided capabilities.

Implementation

We use the library used by our maven jahia plugin: osgi tools to extract nodetypes the same way we do for jahia modules.
Cnd and XML files are parsed.

To use the library, we had to adapt the import packages as the library was not meant to use in an OSGi bundle. Also the library seems to provide too much regarding the current usage, a task will handle the extract of the parsing part to lightened and simplify its usage.

The usage of the library was not possible because of class conflicts resulting into the OSGi annotation (@activate more precisely) that was not working anymore. Using a light version, with no library embed, of the osgi-tool lib or by excluding the dependencies did not fix the issue. It has been chosen to embed the parses' classes into the Javascript module with a high level of depreciation.
#620 will handle the replacement of the parsers by a clean implementation

Note that implementing the changes shows up some inconsistencies in the hydrogen definitions, some namespaces were missing.

Checklist

Tests

  • I've provided Unit and/or Integration Tests
  • I've updated the parent issue with required manual validations

Tip

Documentation to guide the reviews: How to do a code review

Copilot AI review requested due to automatic review settings January 12, 2026 07:52
@dgriffon dgriffon requested a review from a team as a code owner January 12, 2026 07:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements OSGi capability generation for node types by parsing CND (Content Node Definition) files and XML import files to extract provided and required node types, which are then stored as OSGi capabilities in the bundle manifest.

Changes:

  • Integration of the osgi-tools library for parsing CND and XML files to extract node type information
  • Refactoring of the bundle generation logic to collect node type capabilities during file processing
  • Addition of namespace declarations to sample CND files to ensure proper parsing

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/docker-compose.yml Removed obsolete version declaration from docker-compose configuration
samples/hydrogen/src/components/Hero/CallToAction/definition.cnd Added Jahia namespace declaration for proper CND parsing
samples/hydrogen/src/components/BlogPost/definition.cnd Added mix namespace declaration for proper CND parsing
pom.xml Added osgi-tools dependency to dependency management
javascript-modules-engine/pom.xml Configured bundle plugin to embed osgi-tools and made jackrabbit JMX import optional
javascript-modules-engine-java/pom.xml Added osgi-tools as a direct dependency
javascript-modules-engine-java/src/main/java/org/jahia/modules/javascript/modules/engine/jshandler/JavascriptProtocolConnection.java Refactored bundle generation to parse CND/XML files and generate OSGi capabilities for node types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dgriffon dgriffon force-pushed the feat-nodetypes-osgi-capabilities branch 2 times, most recently from 9f59235 to 4a22d55 Compare January 12, 2026 07:57
@dgriffon dgriffon force-pushed the feat-nodetypes-osgi-capabilities branch from 4a22d55 to 7055fb9 Compare January 12, 2026 07:58
@dgriffon dgriffon force-pushed the feat-nodetypes-osgi-capabilities branch from 54461e6 to d8df492 Compare January 12, 2026 09:34
@dgriffon dgriffon force-pushed the feat-nodetypes-osgi-capabilities branch 3 times, most recently from 42c8fb2 to 00407e1 Compare January 13, 2026 09:31
@dgriffon dgriffon force-pushed the feat-nodetypes-osgi-capabilities branch from 00407e1 to eb864a6 Compare January 13, 2026 09:34
Copy link
Contributor

@jkevan jkevan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks very good considering the limitations.
I added a couple of comments, mostly cosmetics.

It would also be great to add a bit more logging in the process, I know that for insight it's always very useful to check jahia logs when a module is starting/installed to see what is happening, I would like to have logs like:

  • submitting file: /path/definitions.cnd to parsing for capabilities extraction.
  • done processing file for capabilities
  • etc..

I saw that the parse method is returning a boolean, it could be used to know when an import xml have been really processed or not.

also it seem's catching of errors and logging of errors when a parsing fail could be improved to help troubleshooting in case of issue.

The thing I am a bit scared of at the moment, but it could probably be part of the next iteration to clean this up, is that in case of issue in cnd/xml the parsing will have direct impact on module deployment compare to a java module where you get feedback when compiling. Runtime impact is way more intrusive and have to be handled properly in the context of module deployement jahia runtime, which is a huge difference and impacts ar clearly not the same.
We will reconsider a JS plugin to do this job later on, for now a working solution is the priority.

@dgriffon dgriffon requested a review from jkevan January 13, 2026 15:35
@dgriffon dgriffon changed the title feat: generate OSGi capabilities from provided/required nodetypes feat: generate OSGi capabilities from declared nodetypes in cnd and xml import Jan 14, 2026
@dgriffon dgriffon changed the title feat: generate OSGi capabilities from declared nodetypes in cnd and xml import feat: generate OSGi capabilities from declared nodetypes in cnd and xml import files Jan 14, 2026
@dgriffon dgriffon merged commit e1211fd into main Jan 14, 2026
18 checks passed
@dgriffon dgriffon deleted the feat-nodetypes-osgi-capabilities branch January 14, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OSGi Provide-Capability and Require-Capability are not populated with nodetypes.

3 participants