I recently had an interesting task where a chunk of data had to be shared across different webapps in order for the application to do its job appropriately. The first thing that came to my mind was to implement caching and use that as the in-memory storage for storing frequently used data. By doing this we can store all the shared data and fetch it from the cache. However I was not very sure and this prompted me to have a discussion as well with couple of my friends and they felt that caching was a good idea too. They also suggested that i could also merge the other webapps into one single webapp. This was not an option as the other webapps were third party tools and the requirement was to only work on a very small portion of the third party tools.
If you guys have done it differently or have a better idea do let me know!! Another way of sharing session data is to add crossContext="true" to the context.xml in Tomcat which would allow you to access another context from a given context. The ServletContext would then be used as the in-memory storage for frequently used data. However if this approach is taken one would need to implement thread safety properly. Also according to the Servlet Specification Session is scoped to a ServletContext and ServletContext is per webapp and it is an in-memory or an object container if you like for the owning webapp. Hence this is a bad practice and probably not the best approach.
Wednesday, January 9, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment