• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Business Delegate for caching

 
Ashu Sharma
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

One of the use of business delegate is that it can be used to cache the results and improve performance avoiding the round-trip to business layer.
Now suppose i am using the Stateful session beans and maintaining the session via them how will BD will be able to get hold of the cached results without accessing the SFSB.
One approach will be that i put the results in session but then sun does not recommend that(http://java.sun.com/blueprints/qanda/web_tier/session_state.html)

Please guide me how a caching scheme can be implemented in a Business Delegate

Thanks
Ashu Sharma
 
Luciano A. Pozzo
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that just the references to remote business services can be cached. So, you do not need do the lookup every time that you need it.

About the cache of the user data, you set it in your stateful, and bind the stateful reference in your http session.
 
Luciano A. Pozzo
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess that now I understood. This resource may help you:

http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.html


Look how the ResourceDelegate interacts with the ResourceSession.

But, in my opinion, the business delegate is an obsolete pattern, it's better use dependency injection instead of business delegate/service locator, and store the session bean in the httpsession.
 
Ashu Sharma
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Luciano,

Thanks for pointing out to the resource. I had read that a lot times before but never gone through the code which gave me a good understanding how caching can be implemented

On the other note,Though you are right that we may do away with BD and SL but there is no harm in keeping them for the reasons explained in following articles.

http://www.javalobby.org/articles/service-locator/


http://www.adam-bien.com/roller/abien/entry/j2ee_patterns_were_antipatterns_but


Thanks
Ashutosh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic