4

I have recently upgraded / deployed a java web application product (which is only a war file, without any code so I am unable to take a look). It has an admin screen that allows the user to configure application properties. I was just wondering how they were able to do that, change parameters and not even require a restart as I am accustomed to having such configuration done by editing some .ini or .xml and requiring app restart to take effect.

Any ideas how such feature may have implemented? Is there an API available for that or if not, what could possibly be the inner workings for such?

Carlos Jaime C. De Leon
  • 2,476
  • 2
  • 37
  • 53

3 Answers3

3

Any webapp worth its name is in the business of putting stuff in a database and getting it back out. It's not a giant leap of imagination to make the webapp itself vary its behavior based on some of that data instead of always just returning it to a user. We're conditioned to think that application properties are static because that's how all the big frameworks behave. They behave that way because dynamic configuration is a lot harder than static configuration, but that doesn't mean dynamic isn't doable.

Ryan Stewart
  • 126,015
  • 21
  • 180
  • 199
2

If there are just few properties then they might be persisting it to a properties file, and then reloading the properties like shown in this thread. Loading a properties file from Java package

If all the properties are always read from this singleton porp object then changing it will instantaneously result in changed behavior of the app.

Community
  • 1
  • 1
Sap
  • 5,197
  • 8
  • 59
  • 101
0

It is done via reflection. Java has reflection api to access class property and invoke those property.

For more advance issues like Dependency Injection (DI), if those properties are used some other component of the application, needs to be notified of the change in configuration.

Kowser
  • 8,123
  • 7
  • 40
  • 63