You can't tell if an EJB is "in cache" in any portable way. EJB is designed around the idea of making that invisible to you, thus enabling the app server vendor to change caching behavior without it breaking your properly-written code.
 
A stateless session bean shows exactly the same "state" to all callers, all the time - generally not a good description of a "cache."
 
A stateful bean is a better fit, but you still have to fill the cache at the beginning of your session with data that is right for that session - the current data from your entity beans). However, you would only need to do this in the ejbActivate method, so it would only be done once (usually; it might get swapped out, in which case you'd get a "cache refresh" on the bean being swapped in later). Since JOnAS doesn't call ejbActivate right now, you'd want to move that cache-init function into a separate method call, so you'd call create() then cache_init()
 
You could fill a data structure in a stateless bean at ejbCreate() time, which might help you. But - accessing another EJB during ejbCreate() on a stateless session bean is "undefined by the EJB architecture" - meaning, it might work but you can't count on it! (Same for direct JDBC access)
 
Wayne Stidolph
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of aamerG
Sent: Tuesday, June 13, 2000 8:55 PM
To: [EMAIL PROTECTED]
Subject: Jonas2.0 caching issue

Hi everyone,
I am deploying a stateless session bean which populates 2 Hashtables from bunch of Entity beans. 
Problem:: the session bean does not seem to be caching itself . we can easily observe the long time it takes to populate the Hashtables everytime the Stateless bean is called . Deploying the bean as Stateful did not increase the performance at all.
Any suggestions ??
How can one tell if the bean is in cache ?
 
Thanks in advance

Reply via email to