You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@tomee.apache.org by bu...@apache.org on 2012/07/05 20:16:52 UTC
svn commit: r824621 - in /websites/staging/openejb/trunk: cgi-bin/ content/
content/examples-trunk/simple-cmp2/README.html
Author: buildbot
Date: Thu Jul 5 18:16:52 2012
New Revision: 824621
Log:
Staging update by buildbot for openejb
Modified:
websites/staging/openejb/trunk/cgi-bin/ (props changed)
websites/staging/openejb/trunk/content/ (props changed)
websites/staging/openejb/trunk/content/examples-trunk/simple-cmp2/README.html
Propchange: websites/staging/openejb/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Jul 5 18:16:52 2012
@@ -1 +1 @@
-1357498
+1357783
Propchange: websites/staging/openejb/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Jul 5 18:16:52 2012
@@ -1 +1 @@
-1357498
+1357783
Modified: websites/staging/openejb/trunk/content/examples-trunk/simple-cmp2/README.html
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/simple-cmp2/README.html (original)
+++ websites/staging/openejb/trunk/content/examples-trunk/simple-cmp2/README.html Thu Jul 5 18:16:52 2012
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
- <title>Simple Cmp2</title>
+ <title>EJB 2.1 CMP EntityBeans (CMP2)</title>
<meta name="description" content="">
<meta name="author" content="">
@@ -70,7 +70,7 @@
};
function twshare () {
window.open(
- "https://twitter.com/intent/tweet?url="+document.URL+"&text=Simple Cmp2",
+ "https://twitter.com/intent/tweet?url="+document.URL+"&text=EJB 2.1 CMP EntityBeans (CMP2)",
'Share on Twitter',
'width=800,height=526');
};
@@ -143,7 +143,7 @@
</div>
<div class="page-header">
-<h1>Simple Cmp2
+<h1>EJB 2.1 CMP EntityBeans (CMP2)
<div style="float: right; position: relative; bottom: -10px; ">
<a onclick="javascript:gpshare()" class="gp-share sprite" title="share on Google+">share [gp]</a>
@@ -154,35 +154,52 @@
</h1>
</div>
-<p><em>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</em></p>
+<p>OpenEJB, the EJB Container for TomEE and Geronimo, does support all of EJB 1.1 to 3.1, including CMP2.</p>
-<h2>Movie</h2>
+<p>The CMP2 implementation is actually done by adapting the CMP2 bean into a JPA Entity dynamically at deploy time.</p>
-<pre><code>package org.superbiz.cmp2;
+<p>Appropriate subclasses, a JPA persistence.xml file and a mapping.xml file are generated at deployment
+time for the CMP2 EntityBeans and all the Entities will be then run on OpenJPA. This innovative code
+has been used as the sole CMP2 implementation in Geronimo for its J2EE 1.4, JavaEE 5 and JavaEE 6 certifications.</p>
-/**
- * @version $Revision$ $Date$
- */
-public interface Movie extends javax.ejb.EJBLocalObject {
- java.lang.Integer getId();
+<p>The persistence.xml and mapping.xml files generated at deploy time can be saved to disk and included
+in the application, allowing you to:</p>
+
+<ul>
+<li>gain finer control over persistence options</li>
+<li>slowly convert individual entities from CMP2 to JPA</li>
+</ul>
- void setId(java.lang.Integer id);
+<p>Let's see an example.</p>
- String getDirector();
+<h1>Movies application</h1>
- void setDirector(String director);
+<p>The following is a basic EJB 2.1 application consisting of one CMP2 Entity. For those that are reading this example
+out of curiosity and are not familiar with CMP2 or EJB 2.x, each CMP2 Entity is composed of two parts</p>
- String getTitle();
+<ul>
+<li><strong>A Home interface</strong> which has data access methods like "find", "create", and "remove". This is essentially
+what people use <code>@Stateless</code> beans for today, but with difference that you do not need to supply
+the implementation of the interface -- the container will generate one for you. This is partly what inspired
+the creation of the OpenEJB-specific <a href="../dynamic-dao-implementation/README.html">Dynamic DAO</a> feature.</li>
+<li><strong>An abstract EntityBean class</strong> which declares the persistent "properties" of the entity without actually
+declaring any fields. It is the container's job to implement the actual methods and create the appropriate
+fields. OpenEJB will implement this bean as a JPA <code>@Entity</code> bean.</li>
+</ul>
- void setTitle(String title);
+<p>As such a CMP2 EntityBean is really just the description of a persistent object and the description of a
+data-access object. There is no actual code to write.</p>
- int getYear();
+<p>The majority of work in CMP2 is done in the xml:</p>
- void setYear(int year);
-}
-</code></pre>
+<ul>
+<li><strong>ejb-jar.xml</strong> mapping information, which describes the persistent properties of the entity and the queries
+for all <em>Home</em> find, create and remove methods. This information will be converted by OpenEJB into
+a JPA mapping.xml file. All queries in the cmp2 part of the ejb-jar.xml are converted
+into named queries in JPA and generally everything is converted to its JPA equivalent. </li>
+</ul>
-<h2>MovieBean</h2>
+<h2>CMP2 EntityBean, MovieBean</h2>
<pre><code>package org.superbiz.cmp2;
@@ -219,7 +236,7 @@ public abstract class MovieBean implemen
}
</code></pre>
-<h2>Movies</h2>
+<h2>CMP2 Home interface, Movies</h2>
<pre><code>package org.superbiz.cmp2;
@@ -241,7 +258,7 @@ interface Movies extends javax.ejb.EJBLo
}
</code></pre>
-<h2>ejb-jar.xml</h2>
+<h2>CMP2 mapping in ejb-jar.xml</h2>
<pre><code><ejb-jar>
<enterprise-beans>