Thursday, May 11, 2006
Settings Refactoring
sipXconfig can configure 6 different hardward devices and at least that many servers. There are potentially thousands of settings that can be changed. Naturally we invented a meta-model to describe these settings and how they work so we wouldn't have to code each setting in java.

Typically the problem with meta-models is that when you actually *want* to code in java for a particular because of special handling you have to deal with a cumbersome syntax.

For example, let's say I want to convert the GMT offset from minutes to hours for a phone, in java I would like to do this:

public int getGmtOffset() {
return m_zone.getGmtOffset() / 60;

but instead I have to do this:
Setting s = getSettings().getSetting("sntp/gmtOffset");
s.setValue(String.valueOf(m_zone.getGmtOffset() / 60));

no big deal when it's just one or two setttings, but the more and more setting you write using the meta model language, the harder it is to maintain.

So... I refactored settings so that you can write in java for most things. It relies on Java annotations, it was pretty simple. Now I'm converting all the old code, so I can simplify the system. I was pleasantly please after refactoring the code for one of the more complex devices: Polycom Soundpoint with this warning from Eclipse:


Comments: Post a Comment

<< Home

Powered by Blogger