Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaEE solution configuration best practices

We build 3-tier enterprise solutions that typically consists of several webapp and ejbjar modules that all talk to a db and have several external integration points.

Each module typically needs its own configurations that can change over the solution's life time. Deploying it becomes a nightmare because now we have 18 property files that must be remembered to copied over and configured also setting up data-sources, queues, memory requirements etc.

I'm hopeful but not optimistic that there can be a better way. Some options we've considered/used, each with it's pros and cons:

  1. Use multiple maven projects and continuous integration (eg. hudson or jenkins) to build a configuration jar that includes all the property files for each environment (dev, qa, prod) and then bundle everything up as an EAR. But then things can't be easily changed in production when needed.
  2. Put most of the settings in the DB and have a simple screen to modify it. Internally we can have a generic configuration service EJB that can read and modify the values. Each module can have a custom extended version that have specific getters and setter.
  3. Version control all the property files then check it out on production and check it into a production branch after making changes.

With all of these you still need to configure data-sources and queues etc. in a container specific way :(

like image 804
AmanicA Avatar asked Nov 17 '11 09:11

AmanicA


1 Answers

  1. Сonsider binding a custom configuration object to JNDI. Then lookup this object in your apps to configure them. Benefits - you can use custom configuration object instead of rather generic Map or Properties.
  2. Another way is to use JMX to configure applications you need. Benefits - you can bind objects you have to configure directly to MBean Server and then use such a well-known tools as jconsole or visualvm to configure components of your application.

Both ways support dynamic reconfiguration of your applications at runtime. I would prefer using JMX.

like image 66
szhem Avatar answered Oct 21 '22 04:10

szhem