The JNDI Context can be changed by different containers or by setting different
options in a given container, possibly at runtime. E.g., enabling JMS in jboss appears
to reset the jndi InitialContext. Cf.
http://www.theserverside.com/discussion/thread.jsp?thread_id=229 for discussion of
Home caching, but there is no clear-cut winning strategy. Very much an open issue, as
far as I can tell.
I use a wrapping class for every Entity Bean class that caches the Home but falls back
to the standard formula for obtaining the Home in the event of any access exception.
No such exceptions have been encountered so far in limited testing, but I am leery of
deploying such a solution. Advice would be appreciated.
Maxime Poulin wrote:
> Hi all !
>
> I have some questions regarding caching and optimisation, and some code
> style...
> Here is the description, it is a very standard client-ejb program. We
> have the JSPs and servlets which are accessed by the clients to perform
> queries. The queries are passed to our API, which in turn connect to the EJB
> server where all the business logic is performed.
>
> Which means that it is in my API objects that I access the beans. When I
> first started the project, I didn't have a lot of knowledge on EJBs but now
> I am going back to that code for some cleanups and some questions popped to
> me.
>
> Regarding caching :
> Creating an initial context might take some time and when I coded my
> API objects, I decided to cache the initial context. This way, I didn't have
> to recreate it each time, thus saving some cycles. But is this really a good
> idea ? Like suppose I have 2 containers, C1 and C2. I create an initial
> context and access a bean on C1. If a few minutes later C1 fails, will my
> bean calls still work ? I mean, is my InitialContext bound to a specific EJB
> Container or is it dynamic ? So is it a good idea to cache the initial
> context (so it is used by all my API objects) ?
>
> If I should not cache the initial context, would it be a better idea
> to cache the home interface to my beans ?
>
> So simply put, should I cache the context, the home interface or
> anything or just let the system do its magical work all by itself ?
>
> Maxime.
>
> ===========================================================================
> 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".
--
Fred Loney
Spirited Software, Inc.
[EMAIL PROTECTED]
===========================================================================
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".