There are a lot of instances when a number or string should be able to be adjusted in environments outside of your development machine. In these cases, environment variables are a good choice. However, the Hybris platform provides a more convenient approach. Let’s see how.
The first place of the configuration is in the platform’s project.properties.
This file contains the global properties for the whole Hybris platform. By using it you can configure:
A lot of setting entries have some default values. But this file isn’t a good place to make custom changes. For this, the local.properties file inside the config folder exists.
The entries inside this file override the same ones from the project.properties of the platform. So, you need to place everything you need to configure for the platform inside this file.
Besides global configuration, each Hybris extension has its own configuration file. See below the project.properties file with some configuration items.
You’re able to view all available properties and change them inside Hybris Administration Console. For this, go here.
You can use the search box to find properties you want to change. Please be aware that all changes will be lost after the server reload due to the fact that all changes are stored only in memory (information in the yellow block on the screenshot).
I’ve figured out several ways to read the properties during the Hybris development process. Let’s go through each of them:
Firstly, you can read them in the source code. Hybris offers de.hybris.platform.util.Config which has a pretty straightforward API. For example:
Config.getParameter(“<keyPath>”) Config.getString(“<keyPath>”) Config.getChar(“<keyPath>”) Config.getBoolean(“<keyPath>”) Config.getInt(“<keyPath>”) Config.getLong(“<keyPath>”) Config.getDouble(“<keyPath>”)
If such a key path exists then an appropriate value will be returned. If not, then the method will return a null value.
The second way you can read properties is inside impex files. Impex framework is used inside the Hybris platform to perform import data procedures. You can use defined properties inside an impex file to make your import procedure more flexible and abstract. For example:
# Import modulegen config properties into impex macros
GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true] $jarResourceCms=$config-jarResourceCmsValue $emailPackageName=$config-emailContextPackageName
The code above imports two properties into an impex script: jarResourceCmsValue and emailContextPackageName. Those items, of course, exist in the config section of the HAC.
The Hybris platform provides developers a convenient and flexible approach for configuring applications. The one very interesting feature for me is that you can use properties not only inside Java code, but in the impex scripts as well, which helps us to create very dynamic data imports.
An executive’s guide to AI and Intelligent Automation. Working Machines takes a look at how the renewed vigour for the development of Artificial Intelligence and Intelligent Automation technology has begun to change how businesses operate.