- Simple implementation of EJB container:
- When an entity bean is created, create the corresponding instance
- When the entity bean is removed, delete (allow to be garbage collected) the instance
- Problem:
- Entity beans typically have a long lifetime
- Over time, more and more instances accumulate in memory
- Most instances are not actively being used
- Better implementation
- Create a fixed size pool of instances
- When a request arrives:
- Choose an unused instance and associate it with the bean's PK
- Use ejbLoad() to sync the bean with the DB
- Execute the method
- Return the bean to the pool
|