How to dynamically configure application settings

I recently updated / deployed a java web application product (which is just a war file without any code, so I can't take a look). It has an admin screen that allows the user to configure the properties of the application. I'm just wondering how they could do this, change the settings and not even require a reboot, since I got used to this configuration by editing some .ini or .xml and requiring the application to restart to take effect.

Any ideas on how such a feature could be implemented? Is there an API for this or not, what could be the inner workings for such?

+4
source share
3 answers

Any webapp that deserves its name is in the business, which puts the material in the database and returns it back. This is not a giant leap of imagination to make webapp change its behavior based on some data, and not just return it to the user. We are forced to think that the properties of the application are static, because this is the behavior of all large frameworks. They behave this way because the dynamic configuration is much more complicated than the static configuration, but this does not mean that the dynamic is not feasible.

+3
source

If there are only a few properties, they can be saved in the properties file, and then reload the properties, as shown in this thread. Loading a properties file from a Java package

If all properties are always read from this singleton porp object, then changing it instantly will cause the application behavior to change.

+2
source

This is done through reflection . Java has a reflection api for accessing a class property and calling this property.

For more advanced issues, such as Injection (DI) , if these properties are used by any other application component, you must report a configuration change.

0
source

Source: https://habr.com/ru/post/1368887/


All Articles