In JOnAS, we deploy all our beans in a single ejbjar. This way, we just have a singleton Persistence class that manages the Hibernate SessionFactory and that is shared by all beans.
This may not scale given that generating the interfaces to all beans is really a time-consuming and painful operation, and we may have to split them up. But we have already (for other reasons) verified that we can define a JOnAS startup service, which loads at startup time into the parent classloader, and which can also define the singleton Persistence object at that scope. That works for the entire application server. (Which is fine for us, since our app is the only one on the server, but might not be fine for other environments....)
Cheers,
Rob
|