Using multiple singleton beans

Multiple singletons can be useful when it becomes necessary or desirable to represent multiple objects in an application that need to be shared across the application. In this recipe, we will expand upon the previous recipe's SingletonExample application by adding a GameBean.

The second singleton is called GameBean and maintains the state of the game. It is assumed that player information maintained in the PlayerBean and this EJB, and its supporting files, need to be created before the GameBean is created. The GameBean will use the player files or initialized database to support the game.

Getting ready

Adding multiple singleton session beans to an application generally requires:

  1. Adding multiple beans annotated with the ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.