This content has been marked as final.
Show 1 reply
-
1. Re: Environment and contexts
tom.baeyens Aug 22, 2007 3:01 AM (in response to mvaldes)we don't know yet how to leverage the block context
Application context is static. The same objects are shared for all the threads and all the transactions. E.g. hibernate session factory.
For a block context the objects that are created only live for the duration of the try-finally block. E.g. a session. Each new environment will have a new block context cache, but it will use the same set of descriptors. Typically, a try-finally environment block represents a transaction. So the block context gives you lazy creation of the resources and it remember to give you the same resource if you ask it twice in the same transaction. Just the behaviour as you want it for a hibernate session. And the same goes for all other transactional resources.
These are some of the features that are given by the container in enterprise environments. E.g. A DataSource will give you the exact same connection if you ask it twice within the same transaction.
let me know what questions are left