[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
the home instance of the accessed EJB is stored as an instance variable in the first EJB.
Reid - SCJP2 (April 2002)
Originally posted by Joe Ess:
There is also a home instance singelton, which stores a single home instance for each EJB as a static variable and provides static methods to obtain them.
Reid - SCJP2 (April 2002)
Originally posted by Jeanne Boyarsky:
Joe,
As far as I know, it's still fairly standard to cache EJB Home instances as the lookup time is relatively expensive. This doesn't translate to having an Initial Context singleton though.
Originally posted by Mark Spritzler:
While you might have cache of home interfaces. Sometimes I have seen people store the Session object or Session information in a Stateless Session Bean, and this is very wrong.
Originally posted by Reid M. Pinchback:
If I understand you correctly, static (class level) mutable variables are holding references to EJB homes, and these statics, either directly or indirectly are used to provide values to EJB instances? That is insane and clearly violates the EJB spec.
Originally posted by Joe Ess:
There's a ServiceHome object. He creates a home instance for each EJB's. If you needed, say, a User EJB representing a particular user, you'd call ServiceHome.getUserHome() to get the home instance and use that UserHome instance to do a userHome.findUserById(). I think that's fairly common usage. I'm just felt uncomfortable with the persistence of the Home instances.
Reid - SCJP2 (April 2002)
By the way, all this caching certainly isn't for performance purposes. This application, while large, is low volume.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Originally posted by Reid M. Pinchback:
If they are *instance* variables that are being cached then yes that is a reasonable and common practice for improving performance. If they are *static* variables, then it is a bad practice and violates the spec for substantive reasons (like thread safety).
Originally posted by Roger Chung-Wee:
So, what's the purpose of doing caching?
Originally posted by Joe Ess:
Should there be a unique instance for each home for each instance of an EJB? That wouldn't be difficult to change.
Reid - SCJP2 (April 2002)
Originally posted by Joe Ess:
So the context-ejb relationship is not like, say, a database connection and result set. I can safely dispose of the context and keep my home instances?
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |