Re: Configuration setup

Daniel Henrique Alves Lima <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
	Hi, Daniel.

	Is it safe to assume that template loader changing and auto-imports and
shared variable definitions should be executed once per Configuration
instance?
	I'm "reconfiguring" the same Configuration instance, with the *same*
values, more than once. I intend to rework this code.


       def loaders = [stringLoader, oldLoader]
       def loader = new MultiTemplateLoader(loaders as TemplateLoader[])
       configuration.setTemplateLoader(loader)

       autoImport.each {
	configuration.addAutoImport(it.key, it.value)
       }

       if (sharedVariables != null) {
	def replacedSharedVars = new HashSet();
	sharedVariables.entrySet().each {
	  entry ->
	    def sharedVar = configuration.getSharedVariable(entry.key)
	    if (sharedVar != entry.value) {	
	      replacedSharedVars << entry.key
	      configuration.setSharedVariable(entry.key, entry.value)
	    }
	}
       }
     }



	Thanks.

	Best regards,

		Daniel.

Daniel Dekany wrote:
> I haven't read the source code, but if this is what you are unsure
> about, the Configuration object must not be changed after it was
> started to be used for loading/processing templates. If you need
> different configurations for different templates, either you need
> multiple configuration objects (which is might not be very efficient
> as it means you will have two template caches), or you have to do the
> necessary configuration setting changes in the Environment object
> before each template processing.
> 
> If the above didn't answer what you are unsure about, tell me more.
> 
> 
> Sunday, February 20, 2011, 1:29:24 PM, Daniel Henrique Alves Lima wrote:
> 
>>         Hi, everybody.
>>
>>         It is a question related to Grails FreeMarker Tags Plugin, Spring
>> Framework and FreeMarker.
>>         Just to be sure, the plugin should to execute the following steps once
>> per Configuration instance:
>>
>> http://code.google.com/p/grails-freemarker-tags-plugin/source/browse/trunk/src/groovy/org/codehaus/groovy/grails/plugins/freemarker/AutoConfigHelper.groovy#173
>>
>>         Right?
>>
>>         The plugin is changing the template loader and it is adding 
>> auto-imports or shared variables.
>>         I think there is no need of executing these steps for every created View:
>>
>> http://code.google.com/p/grails-freemarker-tags-plugin/issues/detail?id=1#c12
>>
>>
>>         Is there a way of preventing changes to a Configuration object?
>>
>>
>>         Thanks!
>>
>>         Best regards,
>>
>>                 Daniel.
>>
>> ------------------------------------------------------------------------------
>> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
>> Pinpoint memory and threading errors before they happen.
>> Find and fix more than 250 security defects in the development cycle.
>> Locate bottlenecks in serial and parallel code that limit performance.
>> http://p.sf.net/sfu/intel-dev2devfeb
>> _______________________________________________
>> FreeMarker-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>>
> 



------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.