blob: 361e43733f62e2696c77b62783690579674207da [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="middle-tier" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The Middle Tier</title>
<section id="middle-tier.introduction">
<title>Introduction</title>
<para>
@greenpages@&rsquo; middle-tier provides implementations of the <literal>Directory</literal> and <literal>Listing</literal>
interfaces that can be used by the Web bundle.
The implementation will use EclipseLink JPA to access a database via a <literal>DataSource</literal> published in the
OSGi service registry.
</para>
<section id="middle-tier.introduction.database">
<title>The database</title>
<para>
The @greenpages@ application uses a very simple database that contains a single table.
The table, named <literal>LISTING</literal>, consists of four columns:
<informaltable pgwide="0">
<tgroup cols="4">
<tbody>
<row>
<entry><literal>LISTING_NUMBER</literal></entry>
<entry><literal>FIRST_NAME</literal></entry>
<entry><literal>LAST_NAME</literal></entry>
<entry><literal>EMAIL_ADDRESS</literal></entry>
</row>
</tbody>
</tgroup>
</informaltable>
Scripts are provided with the sample source code (in <literal>$GREENPAGES_HOME/db</literal>) to start, create, and populate the database.
These will be used during the creation of the middle tier.
</para>
</section>
<section id="middle-tier.introduction.jpa">
<title>Using JPA</title>
<para>
The middle tier will provide JPA-based implementations of the <literal>Directory</literal> and <literal>Listing</literal> interfaces with the four
attributes of a <literal>Listing</literal> (first name, last name, email address, and id) being mapped to the corresponding columns in the
<literal>LISTING</literal>.
JPA will be used to implement the queries that search the database and return <literal>Listings</literal>.
</para>
</section>
<section id="middle-tier.introduction.structure">
<title>Structure</title>
<para>
The middle tier consists of two bundles, <literal>greenpages.jpa</literal> that publishes a <literal>Directory</literal>
implementation for consumption by the Web bundle, and <literal>greenpages.db</literal> to configure and publish the
<literal>DataSource</literal> used to access the database.
</para>
<mediaobject>
<imageobject role="fo">
<imagedata fileref="images/middle-tier/structure.png" format="PNG" align="center" width="10cm"/>
</imageobject>
<imageobject role="html">
<imagedata fileref="images/middle-tier/structure.png" format="PNG" align="center"/>
</imageobject>
</mediaobject>
</section>
</section>
<xi:include href="create-db-project.xml"/>
<xi:include href="building-jpa-module.xml"/>
<xi:include href="trying-it-out.xml"/>
<xi:include href="applying-best-practices.xml"/>
</chapter>