Expand my Community achievements bar.

SOLVED

AEM Cloud - OSGi config and environment variables

Avatar

Level 1

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.

AEM Cloud Environment Variables (just a reference image)AEM Cloud Environment Variables (just a reference image)

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.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@matzikica 

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.h...

See if this makes sense..

 

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

@matzikica 

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.h...

See if this makes sense..

 

Avatar

Community Advisor

Hello @matzikica 

 

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

Avatar

Employee

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.

 

Avatar

Administrator

@matzikica 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