wood burning stoves 2.0*
The moose likes Struts and the fly likes Shared some object that everyone can use? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Shared some object that everyone can use?" Watch "Shared some object that everyone can use?" New topic
Author

Shared some object that everyone can use?

david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
Hi,

I am maintaining a web application which use struts 1 and web service(WS). I found that there are some WS calls which are very common that every user will repeatly need it (resulted object is same for everyone). Since WS call take times and some function need to do a few WS call in a row, the performance is not good.

1. First solution in my mind is to save the WS call result (object) in the session when the user got it from the WS call for the first time, then try to retrieve it from session whenever the user want to use it again.
2. Second solution: when deploy the application, call those WS functions and save the resulted object somewhere (in session?), then each user can get it when it is needed. I don't know how to do it if this method is applicable.

Not know which solution is better or there is other better solution? Any advices?

Thanks.
John Pradeep.v
Ranch Hand

Joined: Jul 21, 2008
Posts: 59
david arnold wrote:Hi,

I am maintaining a web application which use struts 1 and web service(WS). I found that there are some WS calls which are very common that every user will repeatly need it (resulted object is same for everyone). Since WS call take times and some function need to do a few WS call in a row, the performance is not good.

1. First solution in my mind is to save the WS call result (object) in the session when the user got it from the WS call for the first time, then try to retrieve it from session whenever the user want to use it again.
2. Second solution: when deploy the application, call those WS functions and save the resulted object somewhere (in session?), then each user can get it when it is needed. I don't know how to do it if this method is applicable.

Not know which solution is better or there is other better solution? Any advices?

Thanks.


Looking at your explanation, the data returned by the web service is independent of the user in context. i would suggest you to cache the response using a good lightweight caching framework.

For example, if you have a service "ServiceA" which has operation "getData" which internally makes WS call and returns objects as return value. then it would be a nice idea to intercept the call to getData (using AOP may be) and get the data from internal cache... if you dont find the data in cache then delegate the intercepted call to the actual service and on return place the value in the cache for further use.

This way you wont have stale data in your cache if the web service response changes time to time...

Hope this helps.


John
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Shared some object that everyone can use?