This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTA TransactionManager Question  RSS feed

Bob Ciazoratione
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a J2EE application consisting of a Session Facade calling different SLSBs. All the SLSBs which are called by the same thread (= from within the same Session Facade method) should share one object without passing this object explicitly as parameter. The Thread-Local Session pattern is used allowing this object to be shared allong all SLSBs called within the same Thread. This works fine...
Now, when the thread finishes (response is send to the client), the shared object should be cleaned. The thread finishes when the session facade method returns (= when the transaction is committed or rollbacked). In order to clean the shared object when the transaction is commited or rollbacked, the shared object implements the javax.transaction.Synchronization interface and specifies the beforeCompletion() and afterCompletion() methods which contain the clean-up code. When the object-to-share is registered in the Thread-Local, it should also be registered to the TransactionManager. I use the following util class for this:

As you can see, the TransationManager, retrieved from the JNDI context is cached. I have some questions concerning these code:
- Is it possible to cache the TransactionManager retrieved from the JNDI context as above? Is there only one UserTransaction transaction manager within each EJB-JAR module?
- If an EJB-JAR module communicates with different DB schemas, is there still only on TransactionManager that can be cached or should I cache them in a Map with their DataSource?
- Is there any advanced documentation covering this concept?

Note: I use Oracle 9i DB and Oracle 10G App Server...

Thanx In advance, Mates...

Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!