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

Terence Parr parrt at cs.usfca.edu
Sat Sep 22 16:52:33 PDT 2007


Hi Gary,

Yeah, I think I decided that ST groups would only be used for code  
generation since you can only put small templates together  
realistically in one file.  I didn't intend for those to be  
refreshed.  Sorry about that.  At least you can override and fix it!  
hooray!
Ter
On Sep 14, 2007, at 10:50 PM, Gary Clark wrote:

> 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();
>         }
>
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest



More information about the stringtemplate-interest mailing list