• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Best practice for looking up.  RSS feed

 
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.
 
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!