I have stateful bean business interface and class as -
am using glassfish 3.0.1. Using administration tool(http://localhost:4848/common/index.jsf) to configure cache for ejb from
" Common Tasks->Configuration->EJB Container"
I have configured the cache related data as -
Max Cache Size: 2
Cache Resize Quantity: 1
Removal Timeout: 5400
Removal Selection Policy: fifo
Cache Idle Timeout: 40
Beans can be accessed successfully 3 times causes "postconstruct" to print 3 times. But it does not passivate if it is idle for more than 40 seconds. I could never see "prepassivate" unless glassfish is shutdown.
Can someone explains why bean does not passivate if it is idle for more than 40 seconds?
Thanks in advance!
I take the liberty of answering your question with a question:
Where have you been able to find something in the EJB specifications that tells you when a stateful session bean should be passivated?
The only statement I have been able to find is this about the stateful session bean lifecycle:
The container’s caching algorithm may decide that the bean instance should be evicted from memory. (This could be done at the end of each method, or by using an LRU policy). The con- tainer invokes the PrePassivate lifecycle callback interceptor method(s) for the bean instance, if any. After this completes, the container saves the instance’s state to secondary stor- age. A session bean can be passivated only between transactions, and not within a transaction.
If you are preparing for the certification, then I would say that you do not need to concern yourself with things that are not explicitly stated by the EJB specification.
In this case, the specification is vague and I would say that it is deliberate, in order to give container implementers some freedom to decide how to handle bean passivisation and activation.
If you really want to know, then perhaps you should study GlassFish documentation and/or GlassFish source code. The latter is the most reliable source for accurate information, but also the most difficult to read and navigate.