Re: DefaultObjectWrapper

Attila Szegedi <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Completely threadsafe. You should have one per Configuration, and you  
normally have one Configuration per your application. Struts should  
really reference a single instance somehow, but instead of a static  
singleton, the relevant object structure that does the tag parsing  
would better have access to a Configuration object somewhere.

Attila.

On 2008.05.09., at 22:49, Bruce Ritchie wrote:

> We've been profiling our application and came across a bit of code
> that is showing up as a hotspot -
> BeansWrapper.populateClassMapWithBeanInfo
>
>         at  
> freemarker.ext.beans.BeansWrapper.populateClassMapWithBeanInfo
>          ...
> 	  at  
> freemarker.ext.beans.BeansWrapper.introspectClass(BeansWrapper.java: 
> 938)
> 	  at freemarker.ext.beans.BeanModel.<init>(BeanModel.java:139)
> 	  at freemarker.ext.beans.BooleanModel.<init>(BooleanModel.java:69)
> 	  at freemarker.ext.beans.BeansWrapper.<init>(BeansWrapper.java:175)
> 	  at  
> freemarker 
> .template.DefaultObjectWrapper.<init>(DefaultObjectWrapper.java:68)
> 	  at  
> org 
> .apache 
> .struts2 
> .views.freemarker.tags.TagModel.unwrapParameters(TagModel.java:76)
> 	  at  
> org 
> .apache 
> .struts2.views.freemarker.tags.TagModel.getWriter(TagModel.java:66)
>
>
> Now from what we can tell this is caused by some struts2 tag code
> which is creating an instance of the DefaultObjectWrapper for what
> looks every tag it parses.
>
> protected Map unwrapParameters(Map params) {
>        Map map = new HashMap(params.size());
>        DefaultObjectWrapper objectWrapper = new  
> DefaultObjectWrapper();
>        ....
>        map.put(entry.getKey(), objectWrapper.unwrap((TemplateModel)  
> value));
>
>
> My question is: Is the DefaultObjectWrapper thread safe? We're
> thinking of making that variable a static and from our quick reading
> of the code it looks to be ok ... but we'd rather be sure then to have
> things break under load.
>
>
> Regards,
>
> Bruce Ritchie





-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
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.