AEM Cloud - OSGi config and environment variables | Adobe Higher Education
Skip to main content
MatijaLeskovic
Level 2
October 6, 2023
Beantwoord

AEM Cloud - OSGi config and environment variables

  • October 6, 2023
  • 4 reacties
  • 2561 Bekeken

Hi,

 

I'm wondering if there is a possibility to have an environment variable for the OSGi config that is accepting an array. If yes, how? Currently, in AEM Cloud Environment Variables, I can see that the environment variables are accepting single-string items.

In my case, I have a resource change listener which listens to multiple paths (reading them from the OSGi configuration), and I would like to have these paths authorable so we could add more of them if required in the future, in order to avoid the whole development process to get to PROD with a single change in the OSGi configuration.

 

Thanks in advance.

Er kunnen geen reacties meer worden geplaatst op dit onderwerp.
Beste antwoord door A_H_M_Imrul

@matijaleskovic 

Though I am a little confused about the expectation from OSGi config properties and environment variables. But I think you would like to run the listener for different resource paths, and you want it to be authorable.

To achieve that do the following

- put the paths via multi field (path browser) in a page(static) properties (for example /content/configs)

- In your listener code, read the paths from that page properties and register the listener against the authored path dynamically by the method setAdditionalPaths(paths) from org.apache.jackrabbit.api.observation.JackrabbitEventFilter

Reference: https://jackrabbit.apache.org/api/2.14/org/apache/jackrabbit/api/observation/JackrabbitEventFilter.html#setAdditionalPaths-java.lang.String...- 

See if this makes sense..

 

4 reacties

A_H_M_Imrul
Community Advisor
A_H_M_ImrulCommunity AdvisorAntwoord
Community Advisor
October 6, 2023

@matijaleskovic 

Though I am a little confused about the expectation from OSGi config properties and environment variables. But I think you would like to run the listener for different resource paths, and you want it to be authorable.

To achieve that do the following

- put the paths via multi field (path browser) in a page(static) properties (for example /content/configs)

- In your listener code, read the paths from that page properties and register the listener against the authored path dynamically by the method setAdditionalPaths(paths) from org.apache.jackrabbit.api.observation.JackrabbitEventFilter

Reference: https://jackrabbit.apache.org/api/2.14/org/apache/jackrabbit/api/observation/JackrabbitEventFilter.html#setAdditionalPaths-java.lang.String...- 

See if this makes sense..

 

aanchal-sikka
Community Advisor
Community Advisor
October 6, 2023

Hello @matijaleskovic 

 

If the paths are configured via an OSGi config, you should be able to configure runmode specific configs for this OSGi Service.

Are the paths updating frequently, that you need to control it via CM configs?

Aanchal Sikka
joerghoh
Adobe Employee
Adobe Employee
October 7, 2023

I am not entirely sure, but you could try something like this as the entry of the value.

["value1","value2","value3"]

 

That should be parsed as multi-value.

 

kautuk_sahni
Community Manager
Community Manager
October 9, 2023

@matijaleskovic Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni