-
1. Re: Home Interface and Context Thread Safety
starksm64 Sep 4, 2005 2:36 PM (in response to treespace)The thread safety semantics of the home interface proxies is not defined in the spec, so its an implementation detail.
The Context javadoc is very clear that it is not thread safe:
A Context instance is not guaranteed to be synchronized against concurrent access by multiple threads. Threads that need to access a single Context instance concurrently should synchronize amongst themselves and provide the necessary locking. -
2. Re: Home Interface and Context Thread Safety
treespace Sep 4, 2005 3:26 PM (in response to treespace)That is frustrating because more than one article exists showing cached JNDI contexts and home objects. Based on your information we need to create the context and perform the home lookup every time we need to make EJB calls.
Can you confirm that? Are there more efficient yet still portable and reliable alternatives?
TIA -
3. Re: Home Interface and Context Thread Safety
darranl Sep 4, 2005 5:37 PM (in response to treespace)What is your application that is accessing the JNDI contexts and the home interfaces?
-
4. Re: Home Interface and Context Thread Safety
treespace Sep 4, 2005 5:55 PM (in response to treespace)I wanted to know whether contexts and home interfaces were reentrant independent of any specific application. Scott indicated neither is (being undefined is just as good as not being reentrant if portability is an issue).
I am interested in what alternatives exist outside of a lookup/create call each time you need to access a given EJB independent of any specific application. -
5. Re: Home Interface and Context Thread Safety
darranl Sep 4, 2005 6:15 PM (in response to treespace)The architecture of the application affects what the problem is that needs to be solved and the suitability of different solutions.
-
6. Re: Home Interface and Context Thread Safety
treespace Sep 4, 2005 8:48 PM (in response to treespace)I have a question regarding the reentrancy of the create call on EJB home objects and whether a context lookup is reentrant if its use is restricted to a lookup. It is safe to assume a multi-threaded J2EE application although that might be redundant.
-
7. Re: Home Interface and Context Thread Safety
starksm64 Sep 5, 2005 9:56 AM (in response to treespace)I would expect most Context.lookup implementations to be thread-safe and hence the prevelant caching examples. The reentrancy of an ejb home create does not make sense to me. A create is a stateless call that has nothing to reenter.
-
8. Re: Home Interface and Context Thread Safety
treespace Sep 6, 2005 2:26 PM (in response to treespace)I think therefore I can safely cache the context used for lookups. The other issue is overlapping create calls from multiple threads on an EJB home. That it's stateless is promising but you never know if it's scribbling on class values that preclude overlapping calls. Unless it's stipulated it seems risky to re-use home objects.