• 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Best practice for looking up.  RSS feed

 
clojure forum advocate
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.
 
Hug your destiny! And hug this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!