• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Best practice for looking up.

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
My pie came with a little toothpic holding up this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic