aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r957199 - in /websites/staging/aries/trunk/content: ./ modules/jpaproject.html
Date Mon, 06 Jul 2015 10:30:13 GMT
Author: buildbot
Date: Mon Jul  6 10:30:13 2015
New Revision: 957199

Staging update by buildbot for aries

    websites/staging/aries/trunk/content/   (props changed)

Propchange: websites/staging/aries/trunk/content/
--- cms:source-revision (original)
+++ cms:source-revision Mon Jul  6 10:30:13 2015
@@ -1 +1 @@

Modified: websites/staging/aries/trunk/content/modules/jpaproject.html
--- websites/staging/aries/trunk/content/modules/jpaproject.html (original)
+++ websites/staging/aries/trunk/content/modules/jpaproject.html Mon Jul  6 10:30:13 2015
@@ -303,7 +303,6 @@ h2:hover > .headerlink, h3:hover > .head
   visibility: hidden;
 h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover
> .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink
{ visibility: visible }</style>
-<p>Title: JPAProject</p>
 <h1 id="jpa">JPA<a class="headerlink" href="#jpa" title="Permanent link">&para;</a></h1>
 <p>The Aries JPA project will make it easy for JPA persistence providers such
 as <a href="">Apache OpenJPA</a>
@@ -337,7 +336,7 @@ the bundle) will be searched.</p>
 <p>The persistence bundle typically also contains the JPA entities.</p>
 <h2 id="the-aries-jpa-2-modules">The Aries JPA 2 modules<a class="headerlink" href="#the-aries-jpa-2-modules"
title="Permanent link">&para;</a></h2>
 <p>Aries JPA consists of four bundles.</p>
-<h3 id="the-aries-jpa-container-bundle">The Aries JPA container bundle<a class="headerlink"
href="#the-aries-jpa-container-bundle" title="Permanent link">&para;</a></h3>
+<h3 id="aries-jpa-container-orgapacheariesjpacontainer">Aries JPA container (org.apache.aries.jpa.container)<a
class="headerlink" href="#aries-jpa-container-orgapacheariesjpacontainer" title="Permanent
 <p>The Aries JPA container bundle implements the OSGi JPA service specification. </p>
 <p>It tracks persistence unit bundles and creates an EntityManagerFactory service as
soon as all dependencies are met.</p>
 <p>The EntityManagerFactory services will be registered with the following properties:
@@ -362,18 +361,20 @@ the persistence bundle is removed or ref
 closed for <strong>all</strong> users of the service.</li>
 <p>Aries JPA container is a standalone bundle with no other dependencies.</p>
-<h3 id="the-aries-jpa-api">The Aries JPA API<a class="headerlink" href="#the-aries-jpa-api"
title="Permanent link">&para;</a></h3>
+<h3 id="aries-jpa-api-orgapacheariesjpaapi">Aries JPA API (org.apache.aries.jpa.api)<a
class="headerlink" href="#aries-jpa-api-orgapacheariesjpaapi" title="Permanent link">&para;</a></h3>
 <p>A set of interfaces to make it easier to use JPA in OSGi. It contains two main interfaces:</p>
 <li>EmSupplier: Allows to get a thread safe EntityManager and mark entry and exit of
blocks that access the EntityManager. This
 is rather low level and meant to be used mainly by frameworks.</li>
 <li>JpaTemplate: Allows to write closures that can safely access an EntityManager and
are executed inside a transaction.</li>
-<h3 id="the-aries-jpa-support">The Aries JPA support<a class="headerlink" href="#the-aries-jpa-support"
title="Permanent link">&para;</a></h3>
+<h3 id="aries-jpa-supportorgapacheariesjpasupport">Aries JPA support(<a
class="headerlink" href="#aries-jpa-supportorgapacheariesjpasupport" title="Permanent link">&para;</a></h3>
 <p>For each EntityManagerFactory service this bundle provides additional EmSuppler
and JpaTemplate services.</p>
-<h2 id="the-aries-jpa-blueprint-extension">The Aries JPA blueprint extension<a class="headerlink"
href="#the-aries-jpa-blueprint-extension" title="Permanent link">&para;</a></h2>
-<p>Provides a blueprint extension for @PersistenceUnit and @PersistenceContext injection.</p>
-<p>For more details see the aries jpa blueprint example:</p>
+<h2 id="aries-jpa-blueprint-extension-orgapacheariesjpablueprint">Aries JPA blueprint
extension (org.apache.aries.jpa.blueprint)<a class="headerlink" href="#aries-jpa-blueprint-extension-orgapacheariesjpablueprint"
title="Permanent link">&para;</a></h2>
+<p>Provides a blueprint extension for @PersistenceUnit and @PersistenceContext injection.
+To use the extension add this namespace to your blueprint xmlns:jpa=""
and enable
+annotation support using the element <jpa:enable /> on top level.
+For more details see the aries jpa blueprint example:</p>
 <h1 id="creation-of-a-jpa-project-using-maven">Creation of a JPA project using Maven<a
class="headerlink" href="#creation-of-a-jpa-project-using-maven" title="Permanent link">&para;</a></h1>
 <p>The first step consist in to create a maven module and make the following modifications
to allow to deploy
  it as OSGI bundle on the platform and reference where the persistence XML file must loaded
by the classpath to
@@ -417,7 +418,7 @@ We must define two parameters, the "osgi
 <p>The other elements of the xml file are defined according to JPA specification. </p>
-<p><strong>Step 3 : Inject EntityManager into a bean and make it transactional
+<p><strong>Step 3.1 : Inject EntityManager into a bean and make it transactional
 <p>The goal of this step is to provide a DAO layer that looks like JEE code on the
java level. For this we need to inject
 a thread safe EntityManager and ensure the DAO code is run inside a transational context.</p>
 <p>Aries JPA 1.x used a xml element inside each DAO bean to inject the EntityManager.
This syntax is not suppoerted for Aries JPA 2.x anymore.
@@ -444,10 +445,28 @@ all DAO methods. The scope of the transa
+<p>See tasklist-blueprint example for details.</p>
+<p><strong>Step 3.2 : Use JPATemplate to work with JPA in declarative services
+<p>Inject the JPATemplate using a service reference:</p>
+<div class="codehilite"><pre><span class="p">@</span><span class="n">Reference</span><span
class="p">(</span><span class="n">target</span> <span class="p">=</span>
&quot;<span class="p">(</span><span class="n">osgi</span><span
class="p">.</span><span class="n">unit</span><span class="p">.</span><span
class="n">name</span><span class="p">=</span><span class="n">tasklist</span><span
class="p">)</span>&quot;<span class="p">)</span>
+<span class="n">public</span> <span class="n">void</span> <span
class="n">setJpaTemplate</span><span class="p">(</span><span class="n">JpaTemplate</span>
<span class="n">jpa</span><span class="p">)</span> <span class="p">{</span>
<span class="p">...</span> <span class="p">}</span>
+<p>Use the JPATemplate to work with JPA Entities inside closures.</p>
+<div class="codehilite"><pre><span class="c1">// txExpr if you need to
return an object</span>
+<span class="k">return</span> <span class="n">jpa</span><span
class="p">.</span><span class="n">txExpr</span><span class="p">(</span><span
class="n">TransactionType</span><span class="p">.</span><span class="n">Required</span><span
class="p">,</span> <span class="n">em</span> <span class="o">-&gt;</span>
<span class="n">em</span><span class="p">.</span><span class="n">find</span><span
class="p">(</span><span class="n">Task</span><span class="p">.</span><span
class="k">class</span><span class="p">,</span> <span class="n">id</span><span
+<span class="c1">// tx if you just execute code</span>
+<span class="n">jpa</span><span class="p">.</span><span class="n">tx</span><span
class="p">(</span><span class="n">em</span> <span class="o">-&gt;</span>
<span class="n">em</span><span class="p">.</span><span class="n">persist</span><span
class="p">(</span><span class="k">task</span><span class="p">));</span>
+<p>See the tasklist-ds example for details.</p>
 <p><strong>Step 4 : Package the solution</strong></p>
 <p>To package the solution, execute a "maven clean install" instruction. Installing
Aries JPA and Aries Transaction into arbitrary containers is beyond the scope of this document.
 <p>To keep the installation instructions small we only cover installation into Apache
Karaf 4.x. Karaf provides features for Aries JPA, Aries Transaction, Hibernate and Pax-jdbc
so installation is very easy.
-See the README at</p></div>
+See the README at</p></div>
             <!-- Content -->

View raw message