Append Path to SlingServletResolver OSGi Config | Community
Skip to main content
Level 3
April 8, 2024

Append Path to SlingServletResolver OSGi Config

  • April 8, 2024
  • 3 replies
  • 1582 views

We use a multi-tenant architecture, where each tenant has its own path that needs to be added to the org.apache.sling.servlets.resolver.SlingServletResolver. However, it appears that the SlingServletResolver config lacks a factory setting. Consequently, whenever we add a config JSON at the project level, it tends to overwrite the existing one and retains only the last added configuration.

org.apache.sling.servlets.resolver.SlingServletResolver~tenant1.cfg.json
org.apache.sling.servlets.resolver.SlingServletResolver~tenant2.cfg.json

We suspect our approach might be incorrect because the SlingServletResolver lacks support for factory config. We're exploring a solution to append the new path to the config programmatically. This way, each tenant can have their own config that adds new paths directly to the org.apache.sling.servlets.resolver.SlingServletResolver.cfg.json without overwriting the existing one.

Note: Each tenant is a separate project and not a submodule of the one parent project.

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
April 8, 2024

Hi,

 

Typically, what you can do is set this configuration in a "commons" project. This way, it's visible to all other projects and manages configurations that affect the AEM instance's behavior rather than project-related behavior. This can help you organize and avoid errors from overwriting configurations.

 

Hope this helps.

Esteban Bustamante
BrianKasingli
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
April 9, 2024

I'd go for context aware configuration + Granite UI properties.

To manage multi-tenant configurations in AEM without overwriting org.apache.sling.servlets.resolver.SlingServletResolver settings, leverage Context-Aware Configuration (CAC) and Granite UI:

  1. Context-Aware Configuration (CAC): Define tenant-specific settings within the AEM content tree. Use these settings to dynamically adjust servlet behavior or resource resolution, bypassing the need for multiple SlingServletResolver configurations.

  2. Granite UI for Context Management: Create custom component-level propertied from Granite UI, allowing the component to manage their specific configurations within AEM’s authoring environment. This approach replaces direct manipulation of OSGi config files with a more user-friendly method, and the servlet would be able to get the configs.

This strategy offers flexibility, scalability, and a tenant-specific management approach, avoiding the pitfalls of global OSGi configuration conflicts.

Level 2
April 10, 2024

Could you please provide example code?

joerghoh
Adobe Employee
Adobe Employee
April 14, 2024

What configuration parameter do you want to add per tenant?

webdev91Author
Level 3
April 15, 2024

Hi @joerghoh

We are trying to add the tenant-specific Execution Paths. For example, /tenant1/, /tenant2/, etc.

As mentioned, since each tenant is a different application and this OSGi config doesn't support factory configuration, we have to maintain the same configuration in multiple projects. If we take this approach, if one tenant config changes, the all other tenants app codebase needs to be updated.

That's why we are looking for an approach where each tenant can have org.apache.sling.servlets.resolver.SlingServletResolver (either JSON or XML) into their codebase, but it should only add a new path to the Execution Paths list and not change or overwrite anything that already exists. That way, tenant one can add /tenant1/, and tenant two can /tenant2/ path.

Level 2
June 19, 2024

We are also facing similar issue. @webdev91  Did you find any code solution for this?