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 2020/09/14 08:43:08 UTC

Modification to speed up s:text from StrutsLocalizedTextProvider

I have a local modification that I do to speed up my app on how I get 
screen text ie <s:text name="screen.title" /> via 
com.opensymphony.xwork2.util.StrutsLocalizedTextProvider.

By default StrutsLocalizedTextProvider will scan the class packages 
first for the message and then if it cannot find it try 
ApplicationResources.properties.

I use the ApplicationResources.properties for my screen messages and 
then scatter the validation stuff/messages in the packages/classes.  I 
seem to now have alot of packages for my struts classes, so has resulted 
in a lot of scanning for nothing.

Also, maybe only having one ApplicationResources.properties is/was not 
good practice, but makes it easy to manage my screen text, rather than 
duplicating them in many locations.  I think the system does try to do 
some location caching, but it is still slow in comparison.

It is a minor code change, ie scans ApplicationResources.properties 
first, then scans the packages.  I could do a PR to check it out. wdyt?


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


Re: Modification to speed up s:text from StrutsLocalizedTextProvider

Posted by Greg Huber <gr...@gmail.com>.
The overriding would be the main issue, but only if you override the properties.

It is 2000+ on each page render, list with 10 entries.  Think caches the bundle/locations, not what class/bundle, so it calls findResourceBundle(..) with the key.

If you put a trace on your own AbstractLocalizedTextProvider.findResourceBundle(..), and see what it does.

if (missingBundles.contains(key)) {
        	System.out.println("Miss : " + key);
         return null;
}

My structure:
> my.app.backoffice.struts2.list
> my.app.backoffice.struts2.base

> MyList extends MyListBase >> MyListBase extends BaseAction >> BaseAction extends ActionSupport


If I had bundles they would really only be in .display or .base not in these keys:

Miss : 1519736165com.opensymphony.xwork2.ActionSupport_en_GB
Miss : 1519736165com.opensymphony.xwork2.Action_en_GB
Miss : 1519736165com.opensymphony.xwork2.Validateable_en_GB
Miss : 1519736165com.opensymphony.xwork2.interceptor.ValidationAware_en_GB
Miss : 1519736165com.opensymphony.xwork2.TextProvider_en_GB
Miss : 1519736165com.opensymphony.xwork2.LocaleProvider_en_GB

For me, checking the ApplicationResources.properties first brings back Struts1 response (for those who can can remember that far back!)

On 21/09/2020 16:56, Yasser Zamani wrote:
> I think we have to search hierarchy all provided we want to support
> overridden text (even if you define some convention about location).
>
> So the only solution I can imagine is caching if applicable. Do you get
> 2075 on each page render or just first? Lukasz said we have caching and
> you wouldn't get on each render.
>
> Regards.
>
> On 9/20/2020 12:52 PM, Greg Huber wrote:
>> James,
>>
>> After a rethink I came to the same conclusion, the most efficient way is
>> to check ApplicationResources.properties first, but as Lukasz points out
>> the properties cannot be override higher up in the class hierarchy.
>> Which I guess would be an issue for some. One resolution would be use an
>> alternative default location, ie in a package.properties in
>> main/resources/myorg/.  Same basic location as
>> ApplicationResources.properties, but there are now two places needing
>> maintenance, and could get messy requiring too much testing.
>>
>> I will have a look at the text-provider example, but
>> StrutsLocalizedTextProvider does not look too bad, it is
>> AbstractLocalizedTextProvider.findMessage(..) which seems expensive, as
>> it does recursive call in every which way possible.
>>
>> One of my screens does 2075 calls to
>> AbstractLocalizedTextProvider.findResourceBundle(..), with some of the
>> (needless?) checks for each s:text used:
>>
>> Miss : 1519736165com.opensymphony.xwork2.ActionSupport_en_GB
>> Miss : 1519736165com.opensymphony.xwork2.Action_en_GB
>> Miss : 1519736165com.opensymphony.xwork2.Validateable_en_GB
>> Miss : 1519736165com.opensymphony.xwork2.interceptor.ValidationAware_en_GB
>> Miss : 1519736165com.opensymphony.xwork2.TextProvider_en_GB
>> Miss : 1519736165com.opensymphony.xwork2.LocaleProvider_en_GB
>> Miss : 1519736165java.io.Serializable_en_GB
>> Miss : 1519736165java.lang.Object_en_GB
>>
>>
>> Miss : 1519736165com.opensymphony.xwork2.package_en_GB
>> Miss : 1519736165com.opensymphony.package_en_GB
>> Miss : 1519736165com.package_en_GB
>>
>> eg limiting these to a hierarchy of
>> myorg.myapp.whatever.struts2.myAction would help, but messy.
>>
>> Cheers Greg
>>
>> On 19/09/2020 17:11, James Chaplin wrote:
>>> Hello Everyone (and Greg, Lukasz and Yasser more specifically).
>>>
>>>        There are probably differing opinions on what constitutes "best
>>> practice" for properties/resource bundles and Struts 2, but as long as
>>> the set-up you use for your application functions effectively for you,
>>> it is probably OK.  I find having a single set of global properties
>>> convenient and easy to read, but it might not be as flexible as having
>>> multiple/hierarchical property files.
>>>
>>>        Greg's proposal to change the order of lookup (scan the global
>>> ApplicationResources.properties first) is interesting, but might have
>>> some unintended impacts to applications whose behaviour depends on the
>>> current lookup order.  If there is a way to introduce the idea without
>>> impacting preexisting applications, that would be ideal.
>>>
>>>        I wonder if providing an opt-in (either by configuration flag or
>>> specifying the provider/factory) LocalizedTextProvider variant, with a
>>> lookup order change similar to what Greg proposed, might be a
>>> reasonable compromise ?
>>>
>>>        Since the current default LocalizedTextProvider does its
>>> look-ups "bottom-up", the new variant (or existing one with behaviour
>>> modified via configuration flag) could do its look-ups "top-down"
>>> (starting at the global ApplicationResources.properties and then
>>> proceeding in an opposite order to the current default).  Essentially,
>>> it would be more efficient for single-property-file applications, as
>>> in Greg's scenario (vs. the existing one which is more efficient for
>>> class/hierarchy text).
>>>
>>>        Since developers can implement their own LocalizedTextProvider
>>> instances (the Struts Examples
>>> https://github.com/apache/struts-examples/ text-provider example
>>> provides a starting point), the Struts 2 Core should probably only
>>> need to cover the most common usage patterns.  There is already a
>>> GlobalLocalizedTextProvider implemented, but it only looks at the
>>> global application bundle (so its JavaDoc comments are misleading).
>>>
>>>        What do you folks think ?
>>>
>>> Regards,
>>>
>>>        James.
>>>
>>> On 2020/09/15 08:16:53, Lukasz Lenart <lu...@apache.org> wrote:
>>>> wt., 15 wrz 2020 o 08:41 Yasser Zamani <ya...@apache.org>
>>>> napisał(a):
>>>>> Hi Lukasz :)
>>>>>
>>>>> Excuse me... do you remember the place where caching occurs please? I
>>>>> found some references of StrutsLocalizedTextProvider.getText and
>>>>> followed up their parents. Also saw TextProviderSupport.java. I
>>>>> couldn't
>>>>> find any cache for founded text :( Maybe because it's dependent to
>>>>> current valueStack and cannot be cached (?)
>>>> This is combination of bundlesMap and missingBundles, also please be
>>>> aware that ResourceBundle.getBundle() does caching as well
>>>>
>>>>
>>>> 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
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: dev-help@struts.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>

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


Re: Modification to speed up s:text from StrutsLocalizedTextProvider

Posted by Yasser Zamani <ya...@apache.org>.
I think we have to search hierarchy all provided we want to support
overridden text (even if you define some convention about location).

So the only solution I can imagine is caching if applicable. Do you get
2075 on each page render or just first? Lukasz said we have caching and
you wouldn't get on each render.

Regards.

On 9/20/2020 12:52 PM, Greg Huber wrote:
> James,
> 
> After a rethink I came to the same conclusion, the most efficient way is
> to check ApplicationResources.properties first, but as Lukasz points out
> the properties cannot be override higher up in the class hierarchy. 
> Which I guess would be an issue for some. One resolution would be use an
> alternative default location, ie in a package.properties in
> main/resources/myorg/.  Same basic location as
> ApplicationResources.properties, but there are now two places needing
> maintenance, and could get messy requiring too much testing.
> 
> I will have a look at the text-provider example, but
> StrutsLocalizedTextProvider does not look too bad, it is
> AbstractLocalizedTextProvider.findMessage(..) which seems expensive, as
> it does recursive call in every which way possible.
> 
> One of my screens does 2075 calls to
> AbstractLocalizedTextProvider.findResourceBundle(..), with some of the
> (needless?) checks for each s:text used:
> 
> Miss : 1519736165com.opensymphony.xwork2.ActionSupport_en_GB
> Miss : 1519736165com.opensymphony.xwork2.Action_en_GB
> Miss : 1519736165com.opensymphony.xwork2.Validateable_en_GB
> Miss : 1519736165com.opensymphony.xwork2.interceptor.ValidationAware_en_GB
> Miss : 1519736165com.opensymphony.xwork2.TextProvider_en_GB
> Miss : 1519736165com.opensymphony.xwork2.LocaleProvider_en_GB
> Miss : 1519736165java.io.Serializable_en_GB
> Miss : 1519736165java.lang.Object_en_GB
> 
> 
> Miss : 1519736165com.opensymphony.xwork2.package_en_GB
> Miss : 1519736165com.opensymphony.package_en_GB
> Miss : 1519736165com.package_en_GB
> 
> eg limiting these to a hierarchy of
> myorg.myapp.whatever.struts2.myAction would help, but messy.
> 
> Cheers Greg
> 
> On 19/09/2020 17:11, James Chaplin wrote:
>> Hello Everyone (and Greg, Lukasz and Yasser more specifically).
>>
>>       There are probably differing opinions on what constitutes "best
>> practice" for properties/resource bundles and Struts 2, but as long as
>> the set-up you use for your application functions effectively for you,
>> it is probably OK.  I find having a single set of global properties
>> convenient and easy to read, but it might not be as flexible as having
>> multiple/hierarchical property files.
>>
>>       Greg's proposal to change the order of lookup (scan the global
>> ApplicationResources.properties first) is interesting, but might have
>> some unintended impacts to applications whose behaviour depends on the
>> current lookup order.  If there is a way to introduce the idea without
>> impacting preexisting applications, that would be ideal.
>>
>>       I wonder if providing an opt-in (either by configuration flag or
>> specifying the provider/factory) LocalizedTextProvider variant, with a
>> lookup order change similar to what Greg proposed, might be a
>> reasonable compromise ?
>>
>>       Since the current default LocalizedTextProvider does its
>> look-ups "bottom-up", the new variant (or existing one with behaviour
>> modified via configuration flag) could do its look-ups "top-down"
>> (starting at the global ApplicationResources.properties and then
>> proceeding in an opposite order to the current default).  Essentially,
>> it would be more efficient for single-property-file applications, as
>> in Greg's scenario (vs. the existing one which is more efficient for
>> class/hierarchy text).
>>
>>       Since developers can implement their own LocalizedTextProvider
>> instances (the Struts Examples
>> https://github.com/apache/struts-examples/ text-provider example
>> provides a starting point), the Struts 2 Core should probably only
>> need to cover the most common usage patterns.  There is already a
>> GlobalLocalizedTextProvider implemented, but it only looks at the
>> global application bundle (so its JavaDoc comments are misleading).
>>
>>       What do you folks think ?
>>
>> Regards,
>>
>>       James.
>>
>> On 2020/09/15 08:16:53, Lukasz Lenart <lu...@apache.org> wrote:
>>> wt., 15 wrz 2020 o 08:41 Yasser Zamani <ya...@apache.org>
>>> napisał(a):
>>>> Hi Lukasz :)
>>>>
>>>> Excuse me... do you remember the place where caching occurs please? I
>>>> found some references of StrutsLocalizedTextProvider.getText and
>>>> followed up their parents. Also saw TextProviderSupport.java. I
>>>> couldn't
>>>> find any cache for founded text :( Maybe because it's dependent to
>>>> current valueStack and cannot be cached (?)
>>> This is combination of bundlesMap and missingBundles, also please be
>>> aware that ResourceBundle.getBundle() does caching as well
>>>
>>>
>>> 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
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 

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


Re: Modification to speed up s:text from StrutsLocalizedTextProvider

Posted by Greg Huber <gr...@gmail.com>.
James,

After a rethink I came to the same conclusion, the most efficient way is 
to check ApplicationResources.properties first, but as Lukasz points out 
the properties cannot be override higher up in the class hierarchy.  
Which I guess would be an issue for some. One resolution would be use an 
alternative default location, ie in a package.properties in 
main/resources/myorg/.  Same basic location as 
ApplicationResources.properties, but there are now two places needing 
maintenance, and could get messy requiring too much testing.

I will have a look at the text-provider example, but 
StrutsLocalizedTextProvider does not look too bad, it is 
AbstractLocalizedTextProvider.findMessage(..) which seems expensive, as 
it does recursive call in every which way possible.

One of my screens does 2075 calls to 
AbstractLocalizedTextProvider.findResourceBundle(..), with some of the 
(needless?) checks for each s:text used:

Miss : 1519736165com.opensymphony.xwork2.ActionSupport_en_GB
Miss : 1519736165com.opensymphony.xwork2.Action_en_GB
Miss : 1519736165com.opensymphony.xwork2.Validateable_en_GB
Miss : 1519736165com.opensymphony.xwork2.interceptor.ValidationAware_en_GB
Miss : 1519736165com.opensymphony.xwork2.TextProvider_en_GB
Miss : 1519736165com.opensymphony.xwork2.LocaleProvider_en_GB
Miss : 1519736165java.io.Serializable_en_GB
Miss : 1519736165java.lang.Object_en_GB


Miss : 1519736165com.opensymphony.xwork2.package_en_GB
Miss : 1519736165com.opensymphony.package_en_GB
Miss : 1519736165com.package_en_GB

eg limiting these to a hierarchy of 
myorg.myapp.whatever.struts2.myAction would help, but messy.

Cheers Greg

On 19/09/2020 17:11, James Chaplin wrote:
> Hello Everyone (and Greg, Lukasz and Yasser more specifically).
>
>       There are probably differing opinions on what constitutes "best practice" for properties/resource bundles and Struts 2, but as long as the set-up you use for your application functions effectively for you, it is probably OK.  I find having a single set of global properties convenient and easy to read, but it might not be as flexible as having multiple/hierarchical property files.
>
>       Greg's proposal to change the order of lookup (scan the global ApplicationResources.properties first) is interesting, but might have some unintended impacts to applications whose behaviour depends on the current lookup order.  If there is a way to introduce the idea without impacting preexisting applications, that would be ideal.
>
>       I wonder if providing an opt-in (either by configuration flag or specifying the provider/factory) LocalizedTextProvider variant, with a lookup order change similar to what Greg proposed, might be a reasonable compromise ?
>
>       Since the current default LocalizedTextProvider does its look-ups "bottom-up", the new variant (or existing one with behaviour modified via configuration flag) could do its look-ups "top-down" (starting at the global ApplicationResources.properties and then proceeding in an opposite order to the current default).  Essentially, it would be more efficient for single-property-file applications, as in Greg's scenario (vs. the existing one which is more efficient for class/hierarchy text).
>
>       Since developers can implement their own LocalizedTextProvider instances (the Struts Examples https://github.com/apache/struts-examples/ text-provider example provides a starting point), the Struts 2 Core should probably only need to cover the most common usage patterns.  There is already a GlobalLocalizedTextProvider implemented, but it only looks at the global application bundle (so its JavaDoc comments are misleading).
>
>       What do you folks think ?
>
> Regards,
>
>       James.
>
> On 2020/09/15 08:16:53, Lukasz Lenart <lu...@apache.org> wrote:
>> wt., 15 wrz 2020 o 08:41 Yasser Zamani <ya...@apache.org> napisał(a):
>>> Hi Lukasz :)
>>>
>>> Excuse me... do you remember the place where caching occurs please? I
>>> found some references of StrutsLocalizedTextProvider.getText and
>>> followed up their parents. Also saw TextProviderSupport.java. I couldn't
>>> find any cache for founded text :( Maybe because it's dependent to
>>> current valueStack and cannot be cached (?)
>> This is combination of bundlesMap and missingBundles, also please be
>> aware that ResourceBundle.getBundle() does caching as well
>>
>>
>> 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
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>

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


Re: Modification to speed up s:text from StrutsLocalizedTextProvider

Posted by James Chaplin <jc...@apache.org>.
Hello Everyone (and Greg, Lukasz and Yasser more specifically).

     There are probably differing opinions on what constitutes "best practice" for properties/resource bundles and Struts 2, but as long as the set-up you use for your application functions effectively for you, it is probably OK.  I find having a single set of global properties convenient and easy to read, but it might not be as flexible as having multiple/hierarchical property files.

     Greg's proposal to change the order of lookup (scan the global ApplicationResources.properties first) is interesting, but might have some unintended impacts to applications whose behaviour depends on the current lookup order.  If there is a way to introduce the idea without impacting preexisting applications, that would be ideal.

     I wonder if providing an opt-in (either by configuration flag or specifying the provider/factory) LocalizedTextProvider variant, with a lookup order change similar to what Greg proposed, might be a reasonable compromise ? 

     Since the current default LocalizedTextProvider does its look-ups "bottom-up", the new variant (or existing one with behaviour modified via configuration flag) could do its look-ups "top-down" (starting at the global ApplicationResources.properties and then proceeding in an opposite order to the current default).  Essentially, it would be more efficient for single-property-file applications, as in Greg's scenario (vs. the existing one which is more efficient for class/hierarchy text).

     Since developers can implement their own LocalizedTextProvider instances (the Struts Examples https://github.com/apache/struts-examples/ text-provider example provides a starting point), the Struts 2 Core should probably only need to cover the most common usage patterns.  There is already a GlobalLocalizedTextProvider implemented, but it only looks at the global application bundle (so its JavaDoc comments are misleading).

     What do you folks think ?

Regards,

     James.

On 2020/09/15 08:16:53, Lukasz Lenart <lu...@apache.org> wrote: 
> wt., 15 wrz 2020 o 08:41 Yasser Zamani <ya...@apache.org> napisał(a):
> >
> > Hi Lukasz :)
> >
> > Excuse me... do you remember the place where caching occurs please? I
> > found some references of StrutsLocalizedTextProvider.getText and
> > followed up their parents. Also saw TextProviderSupport.java. I couldn't
> > find any cache for founded text :( Maybe because it's dependent to
> > current valueStack and cannot be cached (?)
> 
> This is combination of bundlesMap and missingBundles, also please be
> aware that ResourceBundle.getBundle() does caching as well
> 
> 
> 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
> 
> 

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


Re: Modification to speed up s:text from StrutsLocalizedTextProvider

Posted by Lukasz Lenart <lu...@apache.org>.
wt., 15 wrz 2020 o 08:41 Yasser Zamani <ya...@apache.org> napisał(a):
>
> Hi Lukasz :)
>
> Excuse me... do you remember the place where caching occurs please? I
> found some references of StrutsLocalizedTextProvider.getText and
> followed up their parents. Also saw TextProviderSupport.java. I couldn't
> find any cache for founded text :( Maybe because it's dependent to
> current valueStack and cannot be cached (?)

This is combination of bundlesMap and missingBundles, also please be
aware that ResourceBundle.getBundle() does caching as well


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: Modification to speed up s:text from StrutsLocalizedTextProvider

Posted by Yasser Zamani <ya...@apache.org>.
Hi Lukasz :)

Excuse me... do you remember the place where caching occurs please? I
found some references of StrutsLocalizedTextProvider.getText and
followed up their parents. Also saw TextProviderSupport.java. I couldn't
find any cache for founded text :( Maybe because it's dependent to
current valueStack and cannot be cached (?)

Regards.

On 9/15/2020 10:25 AM, Lukasz Lenart wrote:
> wt., 15 wrz 2020 o 07:49 Yasser Zamani <ya...@apache.org> napisał(a):
>> So generally I think we can have a Map as a cache, if not found in cache
>> then searching and if found after search, saving in cache. I've seen
>> this mechanism in Struts in other places as well.
> 
> This is already done, results of the scan are already cached. The scan
> happens only on application start or each time in devMode.
> 
> 
> Regards
> 

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


Re: Modification to speed up s:text from StrutsLocalizedTextProvider

Posted by Lukasz Lenart <lu...@apache.org>.
wt., 15 wrz 2020 o 07:49 Yasser Zamani <ya...@apache.org> napisał(a):
> So generally I think we can have a Map as a cache, if not found in cache
> then searching and if found after search, saving in cache. I've seen
> this mechanism in Struts in other places as well.

This is already done, results of the scan are already cached. The scan
happens only on application start or each time in devMode.


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: Modification to speed up s:text from StrutsLocalizedTextProvider

Posted by Yasser Zamani <ya...@apache.org>.
Maybe this functionality was needed to allow user to override higher
layers defined values (?) Or maybe another user for any reason claim
that current behavior is wanted.

So generally I think we can have a Map as a cache, if not found in cache
then searching and if found after search, saving in cache. I've seen
this mechanism in Struts in other places as well.

Regards.


On 9/14/2020 1:13 PM, Greg Huber wrote:
> I have a local modification that I do to speed up my app on how I get
> screen text ie <s:text name="screen.title" /> via
> com.opensymphony.xwork2.util.StrutsLocalizedTextProvider.
> 
> By default StrutsLocalizedTextProvider will scan the class packages
> first for the message and then if it cannot find it try
> ApplicationResources.properties.
> 
> I use the ApplicationResources.properties for my screen messages and
> then scatter the validation stuff/messages in the packages/classes.  I
> seem to now have alot of packages for my struts classes, so has resulted
> in a lot of scanning for nothing.
> 
> Also, maybe only having one ApplicationResources.properties is/was not
> good practice, but makes it easy to manage my screen text, rather than
> duplicating them in many locations.  I think the system does try to do
> some location caching, but it is still slow in comparison.
> 
> It is a minor code change, ie scans ApplicationResources.properties
> first, then scans the packages.  I could do a PR to check it out. wdyt?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 

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


Re: Modification to speed up s:text from StrutsLocalizedTextProvider

Posted by Lukasz Lenart <lu...@apache.org>.
pon., 14 wrz 2020 o 10:43 Greg Huber <gr...@gmail.com> napisał(a):
>
> I have a local modification that I do to speed up my app on how I get
> screen text ie <s:text name="screen.title" /> via
> com.opensymphony.xwork2.util.StrutsLocalizedTextProvider.
>
> By default StrutsLocalizedTextProvider will scan the class packages
> first for the message and then if it cannot find it try
> ApplicationResources.properties.
>
> I use the ApplicationResources.properties for my screen messages and
> then scatter the validation stuff/messages in the packages/classes.  I
> seem to now have alot of packages for my struts classes, so has resulted
> in a lot of scanning for nothing.
>
> Also, maybe only having one ApplicationResources.properties is/was not
> good practice, but makes it easy to manage my screen text, rather than
> duplicating them in many locations.  I think the system does try to do
> some location caching, but it is still slow in comparison.
>
> It is a minor code change, ie scans ApplicationResources.properties
> first, then scans the packages.  I could do a PR to check it out. wdyt?

It would be good if we could switch the behaviour using an option in
config, because scanning packages first allows us to override default
texts from ApplicationResources.properties. Changing the order won't
allow this behaviour.


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