That thread says it is ok to cache remote home interfaces and not the remote bean reference. This is correct. You should request the bean from the home interface each time. The (relatively) expensive JNDI call to look up the home is what you are trying to avoid.
Thanks Jeanne for the link. But even in that link, they only cache the Home interface and not the Remote interface. So still my question is un answered. Is it possible and feasible to cache references to Remote Interfaces?
Originally posted by Jeanne Boyarsky: EJBHome is the remote home interface. You shouldn't cache the actual remote interface as that is the bean. I meant RemoteHome when I was talking about remote interfaces you can cache above.
Thanks Jeanne. That was what I was looking for. If I cache a RemoteInterface reference what implications that it would bring to my system? I guess if we do this, we would not be returning the instance to the container's pool and very soon when all the references from the container are exhausted just because of our caching....is it something like this?
Originally posted by Jothi Shankar Kumar Sankararaj: Don"t we see this as a setback in EJB 3 as everytime I have to do a JNDI lookup to my Remote Interface but with EJB 2.x, I can avoid such JNDI lookups by caching my Remote Home Interface reference.
What do you guys say?
Why can't you do the JNDI lookup and cache the remote home interface? There is a @RemoteHome annotation so you can still create a remote interface and look it up in the JNDI.
But my client class is not managed, meaning it does not live in EJB aware enviornment. So I cannot use the @RemoteHome annotation. But by the way, is there such an annotation in EJB 3? I heard that there is not more Home interfaces in EJB 3? Did I go wrong somewhere?
@RemoteHome is defined on the server/ejb. Your client uses JNDI the way it always was. I've seen that Home interfaces are not required, not that they are forbidden. The fact that @RemoteHome exists (I read about it in EJB 3 in Action) implies you can still define it.
Originally posted by Jothi Shankar Kumar Sankararaj: Does the spec says that we can have a Home interface defined for EJB 3 Stateless beans?
See this blog entry on sun.com for an example of @RemoteHome. It's written by "the lead architect for the EJB 3.0 container in the Java EE 5 SDK." so he knows what he is talking about. I also read about this annotation in a book.
I'm sure the spec says it is legal. You are welcome to download the spec to verify this if you'd like.