Marco,
You can cache the reference to the remote object. The spec does not prohibit
this. This will not pose any problem even if the same reference is used
concurrently as the spec allows for this by requiring the container to
handle this case. See extract from EJB 1.1 spec below:
"Clients are not allowed to make concurrent calls to a stateful session
object. If a client-invoked business method is in progress on an instance
when another client-invoked call, from the same or different client, arrives
at the same instance of a stateful session bean class, the container may
throw the
java.rmi.RemoteException to the second client [4] , if the client is a
remote client, or the javax.ejb.EJBException, if the client is a local
client. This restriction does not apply to a state-less session bean because
the container routes each request to a different instance of the session
bean class."
Whether this would result in any preformance benefits will actaully depend
on the implementation of the Home Object. If the home objects internally
caches the Remote Object Reference then there would be no performance
benefit. If this is not the case then you will hit the server , possibly an
additional remote call on create which will be expensive.
Regards,
Amit Khanna.
----- Original Message -----
From: "Marco Mistroni" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 29, 2002 11:33 AM
Subject: Caching Stateless SessionBean in a servlet
Hi all,
i have one basic question to ask to
J2EE gurus.
my app is made of JSP model 2 architecture (JSP + servlet) that
calls some Stateless Sessionbean.
Since JNDI lookup is expensive, i am caching the EJBHome in
the servlet.
Now, that means that all the time that i want to use my stateless
Sessionbean i must call home.create().
Will i save anything (in terms of resources/time etc) if i cache
also the Remote interface of the Sessionbean??
I mean, in the servlet i cache MyEJBHome and MyEJB, so i won't have
to call all the time MyEJBHome.create().
I have read the EJB spec (i am still using 1.1), but this particular
issue is not addressed (please correct me if i am wrong).
As far as i have understood, i won't get any advantage
in caching also the Remote interface of my EJB, since the Container
can easily create new EJBs or reuse already created ones.
But, i'd like to have your opinion on the issue..
thanx in advance and regarsd
marco
=========================
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".
===========================================================================
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".