Java Reference
In-Depth Information
Figure 3.19 With appropriately scoped transactions, an attempt to buy chocolate that's beyond a cus-
tomer's means won't result in a change to their balance or to the chocolate inventory levels.
the load directory and then uses the OSG i API to update the application with the
new code without having to restart anything. If you try a second time to buy lots of
chocolates, the result is much more reasonable (figure 3.19).
Is the shop enterprise-ready now?
We're cheerfully ignoring security hereā€”as well as lots of other things. For example,
it's still possible to remove stock or charge accounts without a surrounding transac-
tion. This could easily be fixed by changing the transaction strategies for the remove-
Stock and chargeToAccount methods from Required to Mandatory . Given these
issues, we don't suggest you take this code literally as the basis of your high-turnover
online shopping website. On the bright side, if you did, the transactional integrity
would be pretty good and the modularity and dynamism would be excellent .
Although JTA is most closely associated with JPA and database access, it's not just for
container-managed persistence classes. Any method, or set of methods, can be signed
up for container-managed transactions.
3.4
Summary
A lot of code appeared in this chapter, so the Fancy Foods application is doing some
powerful stuff now. It's not quite ready to make your fortune as an enterprise-grade
cheese management system, but it's a lot closer than it was in chapter 2. You've got
persistence fully integrated into your architecture without compromising modularity
or dynamism. You know how to read from a database in a single line of code, and how
to cocoon whole swathes of code in transactions with a single line of XML .
At this stage, the application has enough going on that it's no longer a few bun-
dles. Let's move on to consider some of the patterns OSG i offers for packaging these
more complex bundle groupings into self-contained applications.
 
Search WWH ::




Custom Search