First page Back Continue Last page Graphics
Entity Beans
Idle entity bean instances can be passivated
- Instance is thrown back into the pool
- When entity is needed again, an instance is pulled from pool
Important entity
bean design rule:
Entity may be reactivated with a different bean instance!
EntityBean has same two life cycle methods:
Called when bean is swapped into / out of the instance pool
Entity beans may use these in same way as session beans
Notes:
Like stateful session beans, entity beans can also be passivated when idle. The key difference is in how this is done.
A stateful session bean belongs to a single client only, and is not pooled. If that client is idle, no other client can use the bean. So it is serialized to temporary storage and garbage collected, to conserve memory.
An entity bean is shared and pooled. If the entity it represents is not used by any client, the bean instance is thrown back into the pool.
Entity Bean as Taxi
Again the transportation analogy: If a stateful session bean is a private limo, an entity bean is a public taxi. As before, it picks you up for your trip to the airport. What happens when you linger too long at your office? Instead of just killing the engine, the driver drops off your luggage with the dispatcher and goes to pick up other passengers. When you finish your business and are ready to continue your trip, the dispatcher gets a taxi to fetch your bags and then you.
Continued...