18.4 More Suggestions for Tuning EJBs

A few additional tuning suggestions for EJBs are listed here:

  • Beans.instantiate( ) incurs a filesystem check to create new bean instances in some application servers. You can use the Factory pattern with new to avoid the filesystem check.

  • Tune the message-driven beans' pool size to optimize the concurrent processing of messages.

  • Use initialization and finalization methods to cache bean-specific resources. Good initialization locations are setSessionContext( ) , ejbCreate( ), setEntityContext( ), and setMesssageDrivenContext( ); good finalization locations are ejbRemove( ) and unSetEntityContext( ). Failures to allocate or deallocate resources need to be handled.