Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Best practice for looking up.  RSS feed

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all.
imagine the following scenario.
I have a stateless bean that acts as a session facade for entity bean.
as you know, this facade will try to locate entity's home.
usually I put the code that looks for entity's home in the setSessionContext( ) method.
when using a statefull bean as a facade, we can look for entity's home in ejbCreate( ) method and set the home reference to null in ejbPassivate( ) method and look up for the home again in ejbActiviate( ) method.
my question is, which approach is better :
using setSessionContext( ) or
using ejbCreate( ) and ejbPassivate( ) and ejbActivate( ) methods.
(I mean better for performance and memory)
are there circumnstances that I should use a specific way ?
thanks.
 
Brian Tinnel
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I would wonder why you feel it necessary to null the home interface during ejbPassivate only if you set it during ejbCreate. For one thing, you don't really need to null it at all, it will be properly serialized/deserialized which can save you a lookup during ejbActivate. But if you really don't want it passivated, does it eally matter where it was set?

As to whether to set the home interface during setSessionContext or ejbCreate, that is pretty much your call. I normally do not put initialization code in setSessionContext, I prefer to use ejbCreate for that.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!