You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Greg Huber <gr...@gmail.com> on 2014/03/06 13:38:46 UTC

LocalizedTextUtil mods

Seeing this mod the other day has reminded me that I do a local change on
LocalizedTextUtil to speed up the screens.

What I do is to add a check to see if the property comes from the
getDefaultMessage(..) method (ie from ApplicationResources.properties) and
if it does skip all the checking that it does (for every request).  If you
have a lot of inheritance or <s:text> and do not use properties / class
name strategy it makes the rendering a whole lot faster.

ie

HashSet<String> set = defaultLocationMap.get(locale.toString());
if(set != null && set.contains(aTextName)){
...
}

Would this be acceptable here?

Cheers Greg

Re: LocalizedTextUtil mods

Posted by Lukasz Lenart <lu...@apache.org>.
2014-03-06 17:51 GMT+01:00 Greg Huber <gr...@gmail.com>:
> Following this http://struts.apache.org/git-for-struts.html
>
>  url https://github.com/apachestruts/struts don't look correct? 404  >>
> apache/struts <https://github.com/apachestruts/struts>

It suppose to be https://github.com/apache/struts - where did find such url?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: LocalizedTextUtil mods

Posted by Greg Huber <gr...@gmail.com>.
Following this http://struts.apache.org/git-for-struts.html

 url https://github.com/apachestruts/struts don't look correct? 404  >>
apache/struts <https://github.com/apachestruts/struts>


On 6 March 2014 13:34, Lukasz Lenart <lu...@apache.org> wrote:

> 2014-03-06 13:38 GMT+01:00 Greg Huber <gr...@gmail.com>:
> > Seeing this mod the other day has reminded me that I do a local change on
> > LocalizedTextUtil to speed up the screens.
> >
> > What I do is to add a check to see if the property comes from the
> > getDefaultMessage(..) method (ie from ApplicationResources.properties)
> and
> > if it does skip all the checking that it does (for every request).  If
> you
> > have a lot of inheritance or <s:text> and do not use properties / class
> > name strategy it makes the rendering a whole lot faster.
> >
> > ie
> >
> > HashSet<String> set = defaultLocationMap.get(locale.toString());
> > if(set != null && set.contains(aTextName)){
> > ...
> > }
> >
> > Would this be acceptable here?
>
> It's easier to discuss over code, prepare a branch then Pull Request
> via GitHub and we can discuss :-)
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Re: LocalizedTextUtil mods

Posted by Lukasz Lenart <lu...@apache.org>.
2014-03-06 13:38 GMT+01:00 Greg Huber <gr...@gmail.com>:
> Seeing this mod the other day has reminded me that I do a local change on
> LocalizedTextUtil to speed up the screens.
>
> What I do is to add a check to see if the property comes from the
> getDefaultMessage(..) method (ie from ApplicationResources.properties) and
> if it does skip all the checking that it does (for every request).  If you
> have a lot of inheritance or <s:text> and do not use properties / class
> name strategy it makes the rendering a whole lot faster.
>
> ie
>
> HashSet<String> set = defaultLocationMap.get(locale.toString());
> if(set != null && set.contains(aTextName)){
> ...
> }
>
> Would this be acceptable here?

It's easier to discuss over code, prepare a branch then Pull Request
via GitHub and we can discuss :-)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: LocalizedTextUtil mods

Posted by Greg Huber <gr...@gmail.com>.
Every <s:text> will scan up the package hierarchy

ie <s:text name="eventedit.subtitle" /> is does these getMessage(..)
findText(..) calls:

ListEvents.title : org.events.ui.struts2.editor.Events
ListEvents.title : org.events.ui.struts2.editor.EventBase
ListEvents.title : org.events.ui.struts2.util.ActionBase
ListEvents.title : com.opensymphony.xwork2.ActionSupport
ListEvents.title : java.lang.Object
org.events.ui.struts2.editor.package : ListEvents.title
org.events.ui.struts2.package : ListEvents.title
org.events.ui.package : ListEvents.title
org.events.package : ListEvents.title
org.package : ListEvents.title
org.events.ui.struts2.editor.package : ListEvents.title
org.events.ui.struts2.package : ListEvents.title
org.events.ui.package : ListEvents.title
org.events.package : ListEvents.title
org.package : ListEvents.title
org.events.ui.struts2.util.package : ListEvents.title
org.events.ui.struts2.package : ListEvents.title
org.events.ui.package : ListEvents.title
org.events.package : ListEvents.title
org.package : ListEvents.title
com.opensymphony.xwork2.package : ListEvents.title
com.opensymphony.package : ListEvents.title
com.package : ListEvents.title

I did look at using TextProviderSupport in the config, but I think it would
involve duplicating the LocalizedTextUtil class with my local mods.

<bean type="com.opensymphony.xwork2.TextProvider" name="myTextProvider"
      class="local.TextProviderSupport" scope="default" />
<constant name="struts.xworkTextProvider" value="myTextProvider"/>





On 6 March 2014 12:43, Dave Newton <da...@gmail.com> wrote:

> What's the actual speedup?
>
> It might be nice if it was configurable; I'm not sure what the stats would
> be regarding how many apps use S2 vs. "regular" localization.
>
> Dave
>
>
>
> On Thu, Mar 6, 2014 at 7:38 AM, Greg Huber <gr...@gmail.com> wrote:
>
> > Seeing this mod the other day has reminded me that I do a local change on
> > LocalizedTextUtil to speed up the screens.
> >
> > What I do is to add a check to see if the property comes from the
> > getDefaultMessage(..) method (ie from ApplicationResources.properties)
> and
> > if it does skip all the checking that it does (for every request).  If
> you
> > have a lot of inheritance or <s:text> and do not use properties / class
> > name strategy it makes the rendering a whole lot faster.
> >
> > ie
> >
> > HashSet<String> set = defaultLocationMap.get(locale.toString());
> > if(set != null && set.contains(aTextName)){
> > ...
> > }
> >
> > Would this be acceptable here?
> >
> > Cheers Greg
> >
>
>
>
> --
> e: davelnewton@gmail.com
> m: 908-380-8699
> s: davelnewton_skype
> t: @dave_newton <https://twitter.com/dave_newton>
> b: Bucky Bits <http://buckybits.blogspot.com/>
> g: davelnewton <https://github.com/davelnewton>
> so: Dave Newton <http://stackoverflow.com/users/438992/dave-newton>
>

Re: LocalizedTextUtil mods

Posted by Dave Newton <da...@gmail.com>.
What's the actual speedup?

It might be nice if it was configurable; I'm not sure what the stats would
be regarding how many apps use S2 vs. "regular" localization.

Dave



On Thu, Mar 6, 2014 at 7:38 AM, Greg Huber <gr...@gmail.com> wrote:

> Seeing this mod the other day has reminded me that I do a local change on
> LocalizedTextUtil to speed up the screens.
>
> What I do is to add a check to see if the property comes from the
> getDefaultMessage(..) method (ie from ApplicationResources.properties) and
> if it does skip all the checking that it does (for every request).  If you
> have a lot of inheritance or <s:text> and do not use properties / class
> name strategy it makes the rendering a whole lot faster.
>
> ie
>
> HashSet<String> set = defaultLocationMap.get(locale.toString());
> if(set != null && set.contains(aTextName)){
> ...
> }
>
> Would this be acceptable here?
>
> Cheers Greg
>



-- 
e: davelnewton@gmail.com
m: 908-380-8699
s: davelnewton_skype
t: @dave_newton <https://twitter.com/dave_newton>
b: Bucky Bits <http://buckybits.blogspot.com/>
g: davelnewton <https://github.com/davelnewton>
so: Dave Newton <http://stackoverflow.com/users/438992/dave-newton>