In Adobe Managed Services (AMS), the process of managing OSGi configurations via environment variables is slightly different compared to Adobe Cloud Services, but there are ways to achieve this.
Approach for AMS:
Environment Variables in AMS:
AMS allows environment variables to be configured at the infrastructure level, but they are not directly tied to OSGi configurations in the same way they are in Adobe Cloud Services. However, you can still use environment variables in AMS to dynamically configure certain settings.
Use the OSGi Configuration API:
- To configure OSGi settings dynamically based on environment variables, you can use the OSGi Configuration API in your custom bundles or services.
- You can retrieve the environment variables programmatically (via Java's System.getenv()) and then apply them to OSGi configurations at runtime using the ConfigurationAdmin service.
Custom Solution with Sling or Servlet:
- If you need to read environment variables and inject them into OSGi configurations, you can create a Servlet or a Sling Post Processor that:
- Reads the environment variables.
- Programmatically updates the corresponding OSGi configurations using the ConfigurationAdmin service.
Deployment Process:
- When deploying on AMS, you may need to configure environment variables on the server level (in the crx-quickstart configuration or system settings) via AMS support or using custom startup scripts if AMS allows access to this level of configuration.
- Alternatively, you can set the environment variables via Vault or JCR configuration repositories and reference them in your OSGi configuration files.
Steps:
- Create a custom bundle that retrieves the environment variables and updates the OSGi configuration.
- Deploy the bundle via AMS deployment pipeline.
- Use AMS deployment tools to inject values into the system environment or custom scripts as needed.
Summary:
While AMS doesn’t directly support adding OSGi configurations through environment variables like in Adobe Cloud Services, you can achieve this by creating a custom Java bundle that reads the environment variables and dynamically updates the OSGi configurations via the ConfigurationAdmin API.