Dynamic Java properties

What are Java properties?

Java properties is the most famous way of defining Java application resources such as database connections, specific application “variables”, etc. This is very useful but, since this mechanism is static, it may become a programmer’s nightmare when it comes to adapt an application to several testbed or production environments, cause every time you make a change you have to restart your application in order to load those same changes.

Many smart coders find themselves implementing their own properties machine to enable their application to reload the properties file without having to restart the entire application. Unfortunately the complexity of this solution grows side-by-side with the application’s size.

Real world example:

We [me and the team I’m part of] are developing a JEE application which is now in the “bring-up” phase, which consists in deploying several JBoss instances in different machines and distinct Hibernate configuration for each one of the database engines. This is hard to maintain with current java.lang.Properties methodology but not with Dynamic Java properties!

So, what is Dynamic Java properties?
As the name itself explains, dynamic Java properties is nothing more than a concept that provides you a flexible way of configuring your application resources and/or behaviour in a simple way and during application runtime.

If it’s just a concept, why should I care?

Well I just wanted you to understand easily and rapidly what I’m going to present to you now: Hierarchical Inherited Rule-Interpreted XML (aka HIRIX).

Hierarchical Inherited Rule-Interpreted XML is much like an XML parser in that it takes any XML source and parses the XML to create a document object model (DOM), which can then be accessed via an API. However, the capabilities of Hierarchical Inherited Rule-Interpreted XML extend far beyond the realm of simply parsing XML. This technology is capable of modifying the XML structure as the DOM is created as well as dynamically interpreting values from the DOM as it is accessed via the API during run-time execution. Therefore, expressions can now be embedded within the elements and attributes of a XML document, and, when the element or attribute value is retrieved via the API, it is interpreted by execution of the expression.” [source: alphaworks.ibm.com]

A basic introduction to HIRIX can be found here [developerworks @ ibm.com].

Btw, does anyone know something like this for C#? Tks in advance!

Cheers

4 thoughts on “Dynamic Java properties

  1. CPinto says:

    Instead of rolling your own dynamic Java properties bla bla bla you should check JMX and MBeans. Pretty good technology and has no external dependencies.

  2. The given example was only given for simpler understanding of the “problem” and what could be a solution. As for every problem there’s always more than one solution, I thank you for stopping by and showing us another and better one.

    Cheers Celso,
    PP

  3. CPinto says:

    No need to be rude mate. I was just saying that I’ve used JMX to accomplish more or less the same task and it was pretty easy to integrate it with our applications.

  4. Much admired Celso, please don’t get me wrong! As pointed in my previous comment I am grateful for your tip, once that JMX/Managed Beans are truly a better solution for the problem that I posed as an example. I just wanted you to know that it was only “an example” and not a real problem where we [me and the team] are using HIRIX😉

    Once again, thank you a lot for stopping by, hope to see your comments many more times!

    Cheers,
    PP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s