Tuesday, September 1, 2009

Avoiding over eager reloading in Impala

The forthcoming version of Impala has new features which help to avoid "over-eager" reloading of modules, that is, module reloads which take place either unnecessarily and too frequently.

If you run an Impala application within Eclipse you can have a running application automatically reload modules to reflect changes in your workspace. You do this by adding the line

#Automatically detect changes and reload modules
auto.reload.modules=true

to the file impala-embedded.properties.

This is really nice, because it means you can redeploy your application without having to do anything, that is, no build step whatsoever.

The trouble is, redeployment can get a bit overeager. For example, some changes will automatically get picked up without the need for redeployment, for example, my Freemarker web templates. Some changes you also want Impala to ignore completely, for example, changes which occur within your subversion (.svn) directories.

The next drop of Impala now contains a mechanism to filter which files get checked for modifications, via the auto.reload.extension.includes and auto.reload.extension.excludes. An example is shown below:

#Includes only files ending with context.xml and class
auto.reload.extension.includes=context.xml,class

With the setting above, only classes and files ending in context.xml will be checked for modifications, reducing the number of spurious reloads. You can also get complete control over the timing of reloads by specifiying a touch file.

use.touch.file=true
touch.file=/touch.txt

Using a touch file removes all spurious reloads, but does require an extra build step every time in order to update the timestamp of the touch file.

No comments: