Java Reference
In-Depth Information
The Aries JPA container makes use of the metadata required by the JPA service specifi-
cation, but provides managed resources rather than unmanaged ones. By using depen-
dency injection, an enterprise application can integrate with managed JPA using a
single line of XML . The resulting code will automatically participate in JTA transactions
and will have its lifecycle managed by the container.
How does this all look in action? Let's start by extending your Fancy Foods applica-
tion with some persistent data.
Building a persistent application
The Fancy Foods application you've written is a nice application. It's got clean and ele-
gant modularization and a fully dynamic architecture. New translations can be dropped
in, and it has a nice push-based model for publishing special offers. Nonetheless, you
may have a bothersome feeling that something is missing. The only Food instance in the
entire system is one hardcoded box of chocolates. Not quite a superstore yet! We prob-
ably won't have to work hard to persuade you that a food shop needs more food, and
that the most sensible way to manage ever-growing stock lists, variable prices, fluctuating
inventory levels, and complex systems of categorization is with a database.
Setting up a datasource
Before you can do anything exciting with databases, you need to set up a datasource.
The datasource is a mechanism for talking to the backend database from Java code.
All that's required is a garden-variety datasource, but the pattern for setting it up may
be new to you. Application servers usually support using an administrative console or
series of configuration files for defining datasources. The platform you're using is a
bare-bones runtime, so it doesn't have a user interface for datasources—or any graph-
ical user interface at all, in fact.
Luckily, some of the generic wiring utilities provided by enterprise OSG i work well
for configuring datasources. You'll use Blueprint to help out (figure 3.2). As you con-
tinue through the topic, you'll see this is a common pattern.
blueprin t
Figure 3.2 The datasource bundle is about as simple as a useful bundle could be. It has a manifest
and a Blueprint file, but nothing else.
Search WWH ::

Custom Search