You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by bu...@apache.org on 2012/01/27 07:28:56 UTC
svn commit: r803385 - in /websites/staging/openejb/trunk/content:
sitemap.html tomcat-activemq.html tomcat-jpa.html
Author: buildbot
Date: Fri Jan 27 06:28:56 2012
New Revision: 803385
Log:
Staging update by buildbot for openejb
Modified:
websites/staging/openejb/trunk/content/sitemap.html
websites/staging/openejb/trunk/content/tomcat-activemq.html
websites/staging/openejb/trunk/content/tomcat-jpa.html
Modified: websites/staging/openejb/trunk/content/sitemap.html
==============================================================================
--- websites/staging/openejb/trunk/content/sitemap.html (original)
+++ websites/staging/openejb/trunk/content/sitemap.html Fri Jan 27 06:28:56 2012
@@ -244,7 +244,7 @@
<li><a href="testing-security-example.html">Testing Security Example</a></li>
<li><a href="testing-transactions-example.html">Testing Transactions Example</a></li>
<li><a href="time-saved.html">Time Saved</a></li>
-<li><a href="tomcat-activemq.html">Tomcat JMS</a></li>
+<li><a href="tomcat-activemq.html">Tomcat and ActiveMQ</a></li>
<li><a href="tomcat-cdi.html">Tomcat CDI</a></li>
<li><a href="tomcat-detailed-instructions.html">Tomcat Detailed Instructions</a></li>
<li><a href="tomcat-ejb-refs.html">Tomcat ejb-refs</a></li>
Modified: websites/staging/openejb/trunk/content/tomcat-activemq.html
==============================================================================
--- websites/staging/openejb/trunk/content/tomcat-activemq.html (original)
+++ websites/staging/openejb/trunk/content/tomcat-activemq.html Fri Jan 27 06:28:56 2012
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
- <title>Tomcat JMS</title>
+ <title>Tomcat and ActiveMQ</title>
<meta name="description" content="">
<meta name="author" content="">
@@ -85,7 +85,7 @@
<div class="page-header">
<small><a href=".//index.html">Home</a></small><br>
-<h1>Tomcat JMS</h1>
+<h1>Tomcat and ActiveMQ</h1>
</div>
<p>Tomcat + Java EE = TomEE, the Java Enterprise Edition of Tomcat. With TomEE you get Tomcat with ActiveMQ added and integrated and ready to go!</p>
Modified: websites/staging/openejb/trunk/content/tomcat-jpa.html
==============================================================================
--- websites/staging/openejb/trunk/content/tomcat-jpa.html (original)
+++ websites/staging/openejb/trunk/content/tomcat-jpa.html Fri Jan 27 06:28:56 2012
@@ -93,41 +93,33 @@
<p>In a plain Servlet, Filter or Listener you can do fun things like injection of JPA EntityManager or EntityManagerFactory:</p>
<pre><code>import javax.annotation.Resource;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
import javax.servlet.http.HttpServlet;
-import javax.jms.Topic;
-import javax.jms.Queue;
-import javax.jms.ConnectionFactory;
+import javax.transaction.UserTransaction;
public class MyServet extends HttpServlet {
- @Resource(name = "foo")
- private Topic fooTopic;
+ @Resource
+ private UserTransaction userTransaction;
- @Resource(name = "bar")
- private Queue barQueue;
+ @PersistenceContext
+ private EntityManager entityManager;
- @Resource
- private ConnectionFactory connectionFactory;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//...
- Connection connection = connectionFactory.createConnection();
- connection.start();
-
- // Create a Session
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Create a MessageProducer from the Session to the Topic or Queue
- MessageProducer producer = session.createProducer(fooTopic);
- producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- // Create a message
- TextMessage message = session.createTextMessage("Hello World!");
+ userTransaction.begin();
- // Tell the producer to send the message
- producer.send(message);
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+ } finally {
+ userTransaction.commit();
+ }
//...
}
@@ -135,9 +127,24 @@ public class MyServet extends HttpServle
}
</code></pre>
-<p>No need to add even a single library! In the above scenario even the "foo" Topic and the "bar" Queue would be automatically created with no configuration necessary.</p>
+<p>No need to add even a single library! To make the above work all you need is a <code>WEB-INF/persistence.xml</code> file in your webapp like the following:</p>
+
+<pre><code><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
+</code></pre>
+
+<p>DataSources will automatically be created if they haven't be configured explicitly.</p>
-<p><a href="downloads.html">Download</a> TomEE and you're minutes away from a functioning JMS application on Tomcat.</p>
+<p><a href="downloads.html">Download</a> TomEE and you're minutes away from a functioning JPA application on Tomcat.</p>
<p>Apache TomEE, pronounced "Tommy", is an all-Apache stack aimed at <em>Java EE
6 Web Profile</em> certification where Tomcat is top dog.</p>