Re: Performance Issue UrlMapping.getPatternParser()

Splash Forums PrettyFaces Users Performance Issue UrlMapping.getPatternParser() Re: Performance Issue UrlMapping.getPatternParser()

#21173

Frank Caputo
Participant

It is much better now, but URLPatternParser still seems to be created to often:

com.ocpsoft.pretty.faces.beans.ExtractedValuesURLBuilder#buildURL

com.ocpsoft.pretty.faces.util.PrettyURLBuilder#build

URLPatternParser seems to be threadsafe, so you could simply call com.ocpsoft.pretty.faces.config.mapping.UrlMapping#getPatternParser()

Another point is the use of String.split, matches etc.:

com.ocpsoft.pretty.faces.url.URL#URL

com.ocpsoft.pretty.faces.url.QueryString#addParameters

com.ocpsoft.pretty.PrettyContext#PrettyContext

com.ocpsoft.pretty.PrettyFilter#doFilter

These methods always create new Pattern instances. If you have a regex, try to compile it and reuse it. If you don’t have a regex, just use one of the org.apache.commons.lang.StringUtils methods. Or simply String.indexOf(…).

Hope this helps.

Ciao Frank

PS: to check if the sessionid is in the url, just use javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromURL