[stringtemplate-interest] StringTemplateGroup.setRefreshInterval(0)dosen't flush super templates

Gary Clark GaryC at jeld-wen.com
Fri Sep 14 22:50:42 PDT 2007


Hmm, seems I deleted the part in my post where I discussed the problem.

In my case, I'm deploying the library in an war file and accessing the templates in a fixed directory during development.  If I change a super template then any templates based on it do not show the changes if they have already been loaded.  The basic steps are:

1. create super tempate (err-super.stg)
2. create template that references the super template (err.stg)
3. load and use err.stg
4. set the group refresh interval to 0
5. modify err-super.stg while the application is still running
6. load and use err.stg again and it will not reflect the changes in err-super.stg.

It could very well be that I'm doing something wrong, but looking at StringTemplateGroup.java shows that if the refresh interval is not 0 then it will read super templates from nameToGroupMap (and interfaces from nameToInterfaceMap).

The fix that I came up with was to modify "public void implementInterface(String interfaceName)" and "public void setSuperGroup(String groupName)" by adding "&& refreshIntervalInSeconds!=0" to the if statement before the put into a nameTo*Map.  In addition to that, I modified setRefreshInterval to clear those two maps after setting the interval as shown below.

	public void setRefreshInterval(int refreshInterval) {
		this.refreshIntervalInSeconds = refreshInterval;
		nameToGroupMap.clear();
		nameToInterfaceMap.clear();
	}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20070914/922631ce/attachment.html 


More information about the stringtemplate-interest mailing list