How do we specify environment-specific (DEV, STAGING, PROD) properties in BloomReach?

Hello,

I’m new to the BloomReach platform and I’m wondering if some kind individual might be able to provide me with direction on best practices for setting environment-specific properties that can then be accessed by, say, Spring beans.

This is something that can come up if we need to integrate with a third-party service provider to specify some sort of property (eg. “client.id”) whose value might differ between the DEV and STAGING environments, for example.

To illustrate more clearly, in a shared development server (eg. “DEV”), I might need to specify:

client.id=devserverclientid

And similarly in a STAGING/QA environment, I might need to use the same property name, but with a different value like so:

client.id=stagingserverclientid

Is there a standard approach to setting such environment-specific properties in BloomReach?

One approach that came to my mind was to try to add a new String property to the “/hst:hst/hst:hosts/dev-localhost” virtual host group in the CMS Console, and then define other virtual host groups for other environments (QA, UAT, PROD, whatever). However, I quickly discovered that I cannot just add any arbitrary string property to an hst:virtualhostgroup.

Any help in the matter would be very gratefully appreciated!

Thank you,
Nick

1 Like

Hi,
You may want to consider this [1], specially when you are developing HST components.

One of the suggested way is to drop a hst.properties file in your catalina /conf folder: once loaded, those properties can be used almost everywhere in your site application.

For each environment you can have different values in those properties files.

HTH,

Giacomo

[1] https://documentation.bloomreach.com/library/concepts/web-application/hst-2-container-configuration.html

Hello, Giacomo.

Firstly, thank you so much for your prompt assistance. It did help.

As an alternate approach to accessing properties within Java code, I created the following Spring configuration file in my BloomReach installation:

site/webapp/src/main/webapp/WEB-INF/applicationContext.xml

In that file, I added the following line within the standard “beans” element:

<context:property-placeholder location=“classpath:site-local.properties”/>

I placed a file named “site-local.properties” in the classpath, and then added properties such as, “my.property.key=whatever”.

This enabled me to access configurable properties file values in class fields within my Java code in the following manner:

@Value("${my.property.key}")
private String clientId;

I’m not sure if the above approach is the most elegant way to do this in BloomReach, but it appears to work just fine. Note that, when I placed an hst.properties file in the /conf folder without taking steps such as those described above, I was unable to access properties values with Spring annotations such as “@Value”. But that’s fine because this approach appears to work well.

Thanks so much for the direction and inspiration!

-Nick