Considering performance is it good to use spring @value in struts actions

180 Views Asked by At

In an struts 2 (with spring plugin) + spring 4 ....

One can use spring @value in the actions to read property files (formally know as property-placeholder). We use this feature a lot to get our application configuration items from property files. A sample code is like:

@Value("#{'${City.Names}'.split(',')}") 
private List<String> cityNames;

#In the spring property files
CityNames=Tehran,Isfahan

On the other hand, the Struts 2 Action objects are instantiated for each request (as mentioned in https://struts.apache.org/docs/comparing-struts-1-and-2.html)

So it means that the spring always make a new action which cause that the spring run the spring EL ${City.Names}'.split(',') for every request. So considering the performance, using @value in action is not a good approach.

Is it correct ?! If it is not, then how does it handled ?!

Please consider that in the real case some of our spring EL s are complicated and time consuming..

0

There are 0 best solutions below