I just wanted to recap several earlier threads into one. A session bean may
be used to encapsulate business logic that encompasses several entity beans
or to wrapper an entity bean. [No, that's not what I want to discuss.] In
order for the session beans to accomplish this, obviously, they will need a
reference to the entity beans involved.
Sun's "best practice" documents always show the following steps within a
business method in the session bean:
public ShoppingCart getShoppingCart() {
Context initial = new InitialContext();
Object objref = initial.lookup("java:comp/env/ejb/cart");
ShoppingCartHome home =
(ShoppingCartHome)PortableRemoteObject.narrow(objref,
ShoppingCartHome.class);
...
}
Is this *really* a "best practice" scenario? In my ejb test environment this
lookup process is averaging 200ms per business method!? This is if all calls
are executing inprocess. Out of process would certainly be slower. Are they
showing this for ease of display purposes?
Questions
=========
1. For every business method, am I required to initialize a Context object?
2. For every business method, am I required to lookup my object's home
interface? There was a thread regarding this a month back, indicating that
home interfaces could grow stale.
3. Assuming that a home interface is long-lived (meaning always valid unless
the server suffers a catastrophic failure), wouldn't it be more appropriate
to perform the new InitialContext() and the home lookup in the
setSessionContext() method?
Just trying to clarify the best "best practice".
jim
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".