Browse Source

DATAJPA-211 - Documented CDI integration.

Added brief section on how to use the CDI extension. Poslished documentation in general: updated copyright year, removed revision history, fixed links to Maven repositories, added missing section ids to create stable links, improved CSS for HTML rendering, improved PDF rendering.
pull/16/merge
Oliver Gierke 14 years ago
parent
commit
4e3dfdfd02
  1. 17
      src/docbkx/index.xml
  2. 6
      src/docbkx/preface.xml
  3. 90
      src/docbkx/reference/jpa.xml
  4. 317
      src/docbkx/resources/css/html.css
  5. 7
      src/docbkx/resources/xsl/fopdf.xsl

17
src/docbkx/index.xml

@ -33,24 +33,11 @@ @@ -33,24 +33,11 @@
<pubdate />
<copyright>
<year>2008-2011</year>
<year>2008-2012</year>
<holder>The original authors</holder>
</copyright>
<revhistory>
<revision>
<date>09.02.2011</date>
<author>
<firstname>Oliver</firstname>
<surname>Gierke</surname>
</author>
<revremark>Initial port from Hades documentation</revremark>
</revision>
</revhistory>
</bookinfo>
<toc />

6
src/docbkx/preface.xml

@ -20,17 +20,17 @@ @@ -20,17 +20,17 @@
<listitem>
<para>Release repository - <ulink
url="http://maven.springframework.org/release">http://maven.springframework.org/release</ulink></para>
url="http://repo.springsource.org/libs-release">http://repo.springsource.org/libs-release</ulink></para>
</listitem>
<listitem>
<para>Milestone repository - <ulink
url="http://maven.springframework.org/milestone">http://maven.springframework.org/milestone</ulink></para>
url="http://repo.springsource.org/libs-milestone">http://repo.springsource.org/libs-milestone</ulink></para>
</listitem>
<listitem>
<para>Snapshot repository - <ulink
url="http://maven.springframework.org/snapshot">http://maven.springframework.org/snapshot</ulink></para>
url="http://repo.springsource.org/libs-snapshot">http://repo.springsource.org/libs-snapshot</ulink></para>
</listitem>
</itemizedlist>
</section>

90
src/docbkx/reference/jpa.xml

@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
</example>
<para>Using this element looks up Spring Data repositories as described
in <xref linkend="repositories.create-instances" />. Beyond that it
in <xref linkend="repositories.create-instances"/>. Beyond that it
activates persistence exception translation for all beans annotated with
<interfacename>@Repository</interfacename> to let exceptions being
thrown by the JPA presistence providers be converted into Spring's
@ -111,10 +111,10 @@ @@ -111,10 +111,10 @@
name parser does not support the keyword one wants to use or the
method name would get unnecessarily ugly. So you can either use JPA
named queries through a naming convention (see <xref
linkend="jpa.query-methods.named-queries" /> for more information) or
linkend="jpa.query-methods.named-queries"/> for more information) or
rather annotate your query method with
<interfacename>@Query</interfacename> (see <xref
linkend="jpa.query-methods.at-query" /> for details).</para>
linkend="jpa.query-methods.at-query"/> for details).</para>
</simplesect>
</section>
@ -122,7 +122,7 @@ @@ -122,7 +122,7 @@
<title>Query creation</title>
<para>Generally the query creation mechanism for JPA works as described
in <xref linkend="repositories.query-methods" />. Here's a short example
in <xref linkend="repositories.query-methods"/>. Here's a short example
of what a JPA query method translates into:<example>
<title>Query creation from method names</title>
@ -136,7 +136,7 @@ @@ -136,7 +136,7 @@
<para>Spring Data JPA will do a property check and traverse nested
properties as described in <xref
linkend="repositories.query-methods.property-expressions" />. Here's
linkend="repositories.query-methods.property-expressions"/>. Here's
an overview of the keywords supported for JPA and what a method
containing that keyword essentially translates to.</para>
</example></para>
@ -145,11 +145,11 @@ @@ -145,11 +145,11 @@
<title>Supported keywords inside method names</title>
<tgroup cols="3">
<colspec colwidth="1*" />
<colspec colwidth="1*"/>
<colspec colwidth="2*" />
<colspec colwidth="2*"/>
<colspec colwidth="3*" />
<colspec colwidth="3*"/>
<thead>
<row>
@ -337,7 +337,7 @@ @@ -337,7 +337,7 @@
of <interfacename>Collection</interfacename> as parameter as well as
arrays or varargs. For other syntactical versions of the very same
logical operator check <xref
linkend="repository-query-keywords" />.</para>
linkend="repository-query-keywords"/>.</para>
</note></para>
</section>
@ -489,10 +489,10 @@ public class User { @@ -489,10 +489,10 @@ public class User {
<para>All the sections above describe how to declare queries to access a
given entity or collection of entities. Of course you can add custom
modifying behaviour by using facilities described in <xref
linkend="repositories.custom-implementations" />. As this approach is feasible for
comprehensive custom functionality, you can achieve the execution of
modifying queries that actually only need parameter binding by
annotating the query method with <code>@Modifying</code>:</para>
linkend="repositories.custom-implementations"/>. As this approach is
feasible for comprehensive custom functionality, you can achieve the
execution of modifying queries that actually only need parameter binding
by annotating the query method with <code>@Modifying</code>:</para>
<example>
<title>Declaring manipulating queries</title>
@ -569,11 +569,8 @@ int setFixedFirstnameFor(String firstname, String lastname);</programlisting> @@ -569,11 +569,8 @@ int setFixedFirstnameFor(String firstname, String lastname);</programlisting>
<para>The additional interface carries methods that allow you to execute
<interfacename>Specification</interfacename>s in a variety of ways.</para>
For example, the
<code>readAll</code>
method will return all entities that match the specification:
<para>For example, the <code>readAll</code> method will return all
entities that match the specification: </para>
<programlisting language="java">List&lt;T&gt; readAll(Specification&lt;T&gt; spec);</programlisting>
@ -779,8 +776,8 @@ public interface UserRepository extends JpaRepository&lt;User, Long&gt; { @@ -779,8 +776,8 @@ public interface UserRepository extends JpaRepository&lt;User, Long&gt; {
</section>
</section>
<section>
<title id="locking">Locking</title>
<section id="locking">
<title>Locking</title>
<para>To specify the lock mode to be used the
<interfacename>@Lock</interfacename> annotation can be used on query
@ -915,7 +912,7 @@ public interface UserRepository extends JpaRepository&lt;User, Long&gt; { @@ -915,7 +912,7 @@ public interface UserRepository extends JpaRepository&lt;User, Long&gt; {
<section id="jpa.misc">
<title>Miscellaneous</title>
<section>
<section id="jpa.misc.merging-persistence-units">
<title>Merging persistence units</title>
<para>Spring supports having multiple persistence units out of the box.
@ -936,7 +933,7 @@ public interface UserRepository extends JpaRepository&lt;User, Long&gt; { @@ -936,7 +933,7 @@ public interface UserRepository extends JpaRepository&lt;User, Long&gt; {
</example>
</section>
<section>
<section id="jpa.misc.entity-scanning">
<title>Classpath scanning for @Entity classes and JPA mapping
files</title>
@ -975,5 +972,54 @@ public interface UserRepository extends JpaRepository&lt;User, Long&gt; { @@ -975,5 +972,54 @@ public interface UserRepository extends JpaRepository&lt;User, Long&gt; {
for details.</para>
</note>
</section>
<section id="jpd.misc.cdi-integration">
<title>CDI integration</title>
<para>Instances of the repository interfaces are usually created by a
container, which Spring is the most natural choice when working with
Spring Data. There's sophisticated support to easily set up Spring to
create bean instances documented in <xref
linkend="repositories.create-instances"/>. As of version 1.1.0 Spring
Data JPA ships with a custom CDI extension that allows using the
repository abstraction in CDI environments. The extension is part of the
JAR so all you need to do to activate it is dropping the Spring Data JPA
JAR into your classpath.</para>
<para>You can now set up the infrastructure by implementing a CDI
<interfacename>Producer</interfacename> for the
<classname>EntityManagerFactory</classname>:</para>
<programlisting language="java">class EntityManagerFactoryProducer {
@Produces
@ApplicationScoped
public EntityManagerFactory createEntityManagerFactory() {
return Persistence.createEntityManagerFactory("my-presistence-unit");
}
public void close(@Disposes EntityManagerFactory entityManagerFactory) {
entityManagerFactory.close();
}
}</programlisting>
<para>The Spring Data JPA CDI extension will pick up all
<interfacename>EntityManager</interfacename>s availables as CDI beans
and create a proxy for a Spring Data repository whenever an bean of a
repository type is requested by the container. Thus obtaining an
instance of a Spring Data repository is a matter of declaring an
<interfacename>@Inject</interfacename>ed property:</para>
<programlisting language="java">class RepositoryClient {
@Inject
PersonRepository repository;
public void businessMethod() {
List&lt;Person&gt; people = repository.findAll();
}
}</programlisting>
</section>
</section>
</chapter>

317
src/docbkx/resources/css/html.css

@ -1,246 +1,68 @@ @@ -1,246 +1,68 @@
@IMPORT url("highlight.css");
body {
text-align: justify;
margin-right: 2em;
margin-left: 2em;
}
a,
a[accesskey^="h"],
a[accesskey^="n"],
a[accesskey^="u"],
a[accesskey^="p"] {
font-family: Verdana, Arial, helvetica, sans-serif;
font-size: 12px;
color: #003399;
html {
padding: 0pt;
margin: 0pt;
}
a:active {
color: #003399;
body {
margin-left: 15%;
margin-right: 15%;
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
}
a:visited {
color: #888888;
div {
margin: 0pt;
}
p {
font-family: Verdana, Arial, sans-serif;
}
dt {
font-family: Verdana, Arial, sans-serif;
font-size: 12px;
}
p, dl, dt, dd, blockquote {
color: #000000;
margin-bottom: 3px;
margin-top: 3px;
padding-top: 0;
}
ol, ul, p {
margin-top: 6px;
margin-bottom: 6px;
}
p, blockquote {
font-size: 90%;
}
p.releaseinfo {
font-size: 100%;
font-weight: bold;
font-family: Verdana, Arial, helvetica, sans-serif;
padding-top: 10px;
}
p.pubdate {
font-size: 120%;
font-weight: bold;
font-family: Verdana, Arial, helvetica, sans-serif;
}
td {
font-size: 80%;
}
td, th, span {
color: #000000;
text-align: justify;
line-height: 1.3em;
}
td[width^="40%"] {
font-family: Verdana, Arial, helvetica, sans-serif;
font-size: 12px;
color: #003399;
}
table[summary^="Navigation header"] tbody tr th[colspan^="3"] {
font-family: Verdana, Arial, helvetica, sans-serif;
}
blockquote {
margin-right: 0;
}
h1, h2, h3, h4, h6 {
color: #000000;
font-weight: 500;
margin-top: 0;
padding-top: 14px;
font-family: Verdana, Arial, helvetica, sans-serif;
margin-bottom: 0;
}
h2.title {
font-weight: 800;
margin-bottom: 8px;
}
h2.subtitle {
font-weight: 800;
margin-bottom: 20px;
}
.firstname, .surname {
font-size: 12px;
font-family: Verdana, Arial, helvetica, sans-serif;
}
table {
border-collapse: collapse;
border-spacing: 0;
border: 1px black;
empty-cells: hide;
margin: 10px 0 30px 50px;
width: 90%;
}
div.table {
margin: 30px 0 10px 0;
border: 1px dashed gray;
padding: 10px;
}
div .table-contents table {
border: 1px solid black;
}
div.table > p.title {
padding-left: 10px;
}
table[summary^="Navigation footer"] {
border-collapse: collapse;
border-spacing: 0;
border: 1px black;
empty-cells: hide;
margin: 0px;
width: 100%;
}
table[summary^="Note"],
table[summary^="Warning"],
table[summary^="Tip"] {
border-collapse: collapse;
border-spacing: 0;
border: 1px black;
empty-cells: hide;
margin: 10px 0px 10px -20px;
width: 100%;
}
td {
padding: 4pt;
font-family: Verdana, Arial, helvetica, sans-serif;
}
div.warning TD {
text-align: justify;
}
h1 {
font-size: 150%;
}
h2 {
font-size: 110%;
}
h3 {
font-size: 100%; font-weight: bold;
}
h4 {
font-size: 90%; font-weight: bold;
}
h5 {
font-size: 90%; font-style: italic;
}
h6 {
font-size: 100%; font-style: italic;
}
tt {
font-size: 110%;
font-family: "Courier New", Courier, monospace;
color: #000000;
}
.navheader, .navfooter {
border: none;
hr {
border: 1px solid gray;
background: gray;
}
div.navfooter table {
border-style: dashed;
border-color: gray;
border-width: 1px 1px 1px 1px;
background-color: #cde48d;
h1,h2,h3,h4,h5 {
color: #234623;
font-weight: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
margin-bottom: 0em;
margin-top: 2em;
}
pre {
font-size: 110%;
padding: 5px;
border-style: solid;
border-width: 1px;
border-color: #CCCCCC;
background-color: #f3f5e9;
line-height: 1.0;
color: black;
}
ul, ol, li {
list-style: disc;
table code {
font-size: 110%;
}
hr {
width: 100%;
height: 1px;
background-color: #CCCCCC;
border-width: 0;
padding: 0;
pre.programlisting {
font-size: 1em;
padding: 3pt 3pt;
border: 1pt solid black;
background: #eeeeee;
clear: both;
}
.variablelist {
padding-top: 10px;
padding-bottom: 10px;
margin: 0;
}
.term {
font-weight:bold;
div.table {
margin: 1em;
padding: 0.5em;
text-align: center;
}
.mediaobject {
padding-top: 30px;
padding-bottom: 30px;
div.table table {
display: table;
width: 100%;
}
.legalnotice {
font-family: Verdana, Arial, helvetica, sans-serif;
font-size: 12px;
font-style: italic;
div.table td {
padding-left: 7px;
padding-right: 7px;
}
.sidebar {
@ -253,53 +75,36 @@ hr { @@ -253,53 +75,36 @@ hr {
font-size: 14px;
}
.property {
font-family: "Courier New", Courier, monospace;
}
a code {
font-family: Verdana, Arial, monospace;
font-size: 12px;
}
td code {
font-size: 110%;
}
div.note * td,
div.tip * td,
div.warning * td,
div.calloutlist * td {
text-align: justify;
font-size: 100%;
}
.programlisting {
clear: both;
.mediaobject {
padding-top: 30px;
padding-bottom: 30px;
}
.programlisting .interfacename,
.programlisting .literal,
.programlisting .classname {
font-size: 95%;
.legalnotice {
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-size: 12px;
font-style: italic;
}
.title .interfacename,
.title .literal,
.title .classname {
font-size: 130%;
p.releaseinfo {
font-size: 100%;
font-weight: bold;
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
padding-top: 10px;
}
/* everything in a <lineannotation/> is displayed in a coloured, comment-like font */
.programlisting * .lineannotation,
.programlisting * .lineannotation * {
color: green;
p.pubdate {
font-size: 120%;
font-weight: bold;
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
}
.question * p {
font-size: 100%;
span.productname {
font-size: 200%;
font-weight: bold;
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
}
.answer * p {
font-size: 100%;
code {
font-size: 125%;
}

7
src/docbkx/resources/xsl/fopdf.xsl

@ -23,11 +23,6 @@ @@ -23,11 +23,6 @@
<fo:table-body>
<fo:table-row>
<fo:table-cell text-align="center">
<!-- Logo
<fo:block>
<fo:external-graphic src="file:src/docbkx/resources/images/s2_box_logo.png"/>
</fo:block>
-->
<fo:block font-family="Helvetica" font-size="22pt" padding-before="10mm">
<xsl:value-of select="bookinfo/subtitle"/>
</fo:block>
@ -62,7 +57,7 @@ @@ -62,7 +57,7 @@
</xsl:for-each>
</fo:block>
<fo:block font-family="Helvetica" font-size="12pt" padding="10mm">
<xsl:text>Copyright &#xA9; 2011</xsl:text>
<xsl:text>Copyright &#xA9; 2012</xsl:text>
</fo:block>
<fo:block font-family="Helvetica" font-size="10pt" padding="1mm">

Loading…
Cancel
Save