adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
742 stars 749 forks source link

ClientLibrariesImpl should not always open a new ResourceResolver #2446

Open joerghoh opened 1 year ago

joerghoh commented 1 year ago

Feature Request

The ClientLibrariesImpl sling model uses a dedicated Service ResourceResolver to resolve the categories; but such a model is used within many components, I found it used in 12 snippets of the v1 page component. That means that in case a page uses all of these snippets, 12 times a resource resolver is opened and closed, which is quite some overhead (in the range of miliseconds).

It should be possible to share a single instance of such a ResourceResolver amongst all of these snippets in the context of a single request, which would reduce overhead and page rendering time.

Describe the solution you'd like

The ClientLibrariesImpl should store an opened ResourceResolver within the context of the ResourceResolver of the request (in the ResourceResolver.getPropertyMap()). When such a RR is available in that map, it should be used (instead of a new one being created).

The API contract of ResourceResolver.getPropertyMap()) ensures that the Service RR is closed when the page rendering is finished and its RR is closed.

joerghoh commented 1 year ago

Need to postpone it until this API is available in AEM 6.5.x ...