|
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
|
- Jonas2.0 caching issue aamerG
- Wayne Stidolph
