[MAGNOLIA-6996] Streamline DefinitionProvider population in JcrConfigurationSource Created: 30/Mar/17  Updated: 30/Mar/17

Status: Accepted
Project: Magnolia
Component/s: None
Affects Version/s: 5.5.2
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Aleksandr Pchelintcev Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)

 Description   

By design besides the definition bean itself DefinitionProvider also carries over the so-called DefinitionRawView, a map-like structure that is easier to traverse than the bean and which should be available even when the bean resolution completely failed.

In case of JcrConfigSource in order to populate the raw view we extend the Node2BeanProcessor and piggyback on the transformation process populating the raw view along. Such approach has several certain drawbacks:

  • N2B is quite complex as it is and the extension feels a bit hacky
  • Definition raw view should be available independently from the bean and, ideally, before the bean is even resolved (there's a TODO in the code suggesting that)
  • Raw view might end up incomplete if the JCR transformation fails.

There is a simple way to improve the situation: use a separate algorithm to populate the raw view, then use vanilla N2B to populate then bean. The penalty of such approach is that the node traversal would happen not once but twice. However, since definition population is an infrequent operation (especially in production) - this shouldn't be a problem.

As for the algorithm of resolving the DefinitionRawView from the JCR, there's a couple of obvious approaches:
1 - merely traverse the node recursively and populate the map (then use the raw view adapter to map)
2 - create a simple raw view adapter to the node (would act lazily, but would also impose problems with node lifecycle and etc)


Generated at Mon Feb 12 04:19:45 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.