This week's book giveaway is in the Testing forum. We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line! See this thread for details.
I have a question about where to put the container managed transaction within the business tier patterns. For example, chapter 7 of "Core J2EE Patterns" explains the ApplicationService pattern. So, for example you can have:
SLSBFacade->ApplicationService-> DAO or Entity
Chapter 7 has said that an ApplicationService is a POJO. So where is the transaction method? SLSBFacade is too generic to put detailed transaction handling. Should the following be used instead?
SLSBFacade->SLSBApplicationService->ApplicationService-> DAO or Entity
Thanks for responding. According to "Core J2EE Patterns", the session facade should have little or no business logic. One of the ApplicationService POJOs that I have must: 1) execute a task, 2) then execute 2 more tasks within a transaction. If one of the last 2 tasks fail then they must be rolled back, and the task in 1) must be undone. The task in 1) is performed on a different system and cannot be in the same transaction context as the tasks in 2). I was thinking that the code to handle the transactions is too involved in the business logic to put in the session facade.
I want to 1) call an external credit card service to pay for an order, 2) persist the order in a local database. If 2) fails, I want to 'unpay' for the order (i.e. 'rollback' 1)). I don't want 1) in the transaction...only 2). If 2) fails, it will get rolled back, and 1) will get unpaid.
My plan was for the facade to call a method in a POGO.