DefaultObjectWrapper

"Bruce Ritchie" <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
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.