[jboss-cvs] JBossAS SVN: r111004 - projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 22 19:47:21 EDT 2011


Author: marius.bogoevici
Date: 2011-03-22 19:47:21 -0400 (Tue, 22 Mar 2011)
New Revision: 111004

Modified:
   projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US/Appendix_A.xml
   projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US/Getting_Started_Introductory_Example.xml
   projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US/Spring_On_JBoss_Best_Practices.xml
Log:
Cleanup

Modified: projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US/Appendix_A.xml
===================================================================
--- projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US/Appendix_A.xml	2011-03-22 22:56:14 UTC (rev 111003)
+++ projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US/Appendix_A.xml	2011-03-22 23:47:21 UTC (rev 111004)
@@ -5,101 +5,124 @@
 %BOOK_ENTITIES;
 ]>
 <appendix>
-  <title id="appendix_maven_deps">Maven dependencies for the introductory
-  example</title>
+  <title id="appendix_maven_deps">POM.xml for the introductory example</title>
 
   <section>
-    <para>In order to </para>
+    <para>In order to</para>
 
-    <programlisting> &lt;dependencies&gt;
-    &lt;dependency&gt;
-      &lt;groupId&gt;junit&lt;/groupId&gt;
-      &lt;artifactId&gt;junit&lt;/artifactId&gt;
-      &lt;version&gt;4.7&lt;/version&gt;
-      &lt;scope&gt;test&lt;/scope&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-    	&lt;groupId&gt;org.hibernate&lt;/groupId&gt;
-    	&lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
-    	&lt;version&gt;3.3.0.GA&lt;/version&gt;
-    	&lt;scope&gt;provided&lt;/scope&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-    	&lt;groupId&gt;org.hibernate&lt;/groupId&gt;
-    	&lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
-    	&lt;version&gt;3.4.0.GA&lt;/version&gt;
-    	&lt;scope&gt;provided&lt;/scope&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-    	&lt;groupId&gt;taglibs&lt;/groupId&gt;
-    	&lt;artifactId&gt;standard&lt;/artifactId&gt;
-    	&lt;version&gt;1.1.2&lt;/version&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-        &lt;groupId&gt;commons-logging&lt;/groupId&gt;
-    	&lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
-    	&lt;version&gt;1.1.1&lt;/version&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-        &lt;groupId&gt;aopalliance&lt;/groupId&gt;
-    	&lt;artifactId&gt;aopalliance&lt;/artifactId&gt;
-    	&lt;version&gt;1.0&lt;/version&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-    	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
-    	&lt;artifactId&gt;spring-asm&lt;/artifactId&gt;
-    	&lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-    	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
-    	&lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
-    	&lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-    	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
-    	&lt;artifactId&gt;spring-expression&lt;/artifactId&gt;
-    	&lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
-    &lt;/dependency&gt;
-     &lt;dependency&gt;
-    	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
-    	&lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
-    	&lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
-    &lt;/dependency&gt;
-     &lt;dependency&gt;
-    	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
-    	&lt;artifactId&gt;spring-context&lt;/artifactId&gt;
-    	&lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
-    &lt;/dependency&gt;
-     &lt;dependency&gt;
-    	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
-    	&lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
-    	&lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-    	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
-    	&lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
-    	&lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-    	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
-    	&lt;artifactId&gt;spring-core&lt;/artifactId&gt;
-    	&lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-    	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
-    	&lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
-    	&lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-    	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
-    	&lt;artifactId&gt;spring-web&lt;/artifactId&gt;
-    	&lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
-    &lt;/dependency&gt;
-    &lt;dependency&gt;
-    	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
-    	&lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
-    	&lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
-    &lt;/dependency&gt;
-  &lt;/dependencies&gt;</programlisting>
+    <programlisting>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
+   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
+   &lt;groupId&gt;org.jboss.snowdrop.getting.started&lt;/groupId&gt;
+   &lt;artifactId&gt;getting-started&lt;/artifactId&gt;
+   &lt;packaging&gt;war&lt;/packaging&gt;
+   &lt;version&gt;1.0&lt;/version&gt;
+   &lt;name&gt;getting-started Maven Webapp&lt;/name&gt;
+   &lt;url&gt;http://maven.apache.org&lt;/url&gt;
+   &lt;dependencies&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;junit&lt;/groupId&gt;
+         &lt;artifactId&gt;junit&lt;/artifactId&gt;
+         &lt;version&gt;4.7&lt;/version&gt;
+         &lt;scope&gt;test&lt;/scope&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
+         &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
+         &lt;version&gt;3.3.0.GA&lt;/version&gt;
+         &lt;scope&gt;provided&lt;/scope&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
+         &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
+         &lt;version&gt;3.4.0.GA&lt;/version&gt;
+         &lt;scope&gt;provided&lt;/scope&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;taglibs&lt;/groupId&gt;
+         &lt;artifactId&gt;standard&lt;/artifactId&gt;
+         &lt;version&gt;1.1.2&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;commons-logging&lt;/groupId&gt;
+         &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
+         &lt;version&gt;1.1.1&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;aopalliance&lt;/groupId&gt;
+         &lt;artifactId&gt;aopalliance&lt;/artifactId&gt;
+         &lt;version&gt;1.0&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-asm&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-expression&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+      &lt;dependency&gt;
+         &lt;groupId&gt;org.springframework&lt;/groupId&gt;
+         &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
+         &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
+      &lt;/dependency&gt;
+   &lt;/dependencies&gt;
+   &lt;build&gt;
+      &lt;finalName&gt;getting-started&lt;/finalName&gt;
+   &lt;/build&gt;
+&lt;/project&gt;
+</programlisting>
   </section>
 </appendix>

Modified: projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US/Getting_Started_Introductory_Example.xml
===================================================================
--- projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US/Getting_Started_Introductory_Example.xml	2011-03-22 22:56:14 UTC (rev 111003)
+++ projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US/Getting_Started_Introductory_Example.xml	2011-03-22 23:47:21 UTC (rev 111004)
@@ -40,21 +40,14 @@
     <section>
       <title>Assumptions and placeholder names</title>
 
-      <para>During this tutorial, we are going to assume that:</para>
+      <para>During this tutorial, we are going to assume that the location of
+      JBoss Enterprise Application is $EAP_HOME, which represents the
+      top-level directory of the extracted distribution (usually
+      <emphasis>jboss-eap-5.1</emphasis>).</para>
 
-      <itemizedlist>
-        <listitem>
-          <para>The location of JBoss Enterprise Application is $EAP_HOME,
-          which represents the top-level directory of the extracted
-          distribution (usually jboss-eap-5.1) ;</para>
-        </listitem>
-
-        <listitem>
-          <para>We use the placeholder &lt;profile&gt; to indicate the JBoss
-          AS profile with which the application is launched (usually
-          default);</para>
-        </listitem>
-      </itemizedlist>
+      <para>We use the placeholder &lt;profile&gt; to indicate the JBoss AS
+      profile with which the application is launched (usually
+      <emphasis>default</emphasis>).</para>
     </section>
   </section>
 
@@ -70,17 +63,17 @@
     <itemizedlist>
       <listitem>
         <para>The general project structure of a Spring-based web
-        application</para>
+        application;</para>
       </listitem>
 
       <listitem>
         <para>A simple set of domain classes, MVC controllers and web
-        pages</para>
+        pages;</para>
       </listitem>
 
       <listitem>
         <para>The data infrastructure configuration (including database, JPA
-        and transactions) for running Spring applications in JBoss</para>
+        and transactions) for running Spring applications in JBoss.</para>
       </listitem>
     </itemizedlist>
   </section>
@@ -180,7 +173,7 @@
               </row>
 
               <row>
-                <entry>Spring Modules</entry>
+                <entry>Spring modules</entry>
 
                 <entrytbl cols="1">
                   <tbody>
@@ -234,11 +227,15 @@
           </tgroup>
         </table></para>
 
-      <para>Appendin</para>
+      <para>You can add these dependencies using the Dependencies tab of the
+      POM editor, or copy them directly to the pom.xml file. An example of the
+      POM file, including the list of dependencies can be found in Appendix
+      A.</para>
 
-      <para>The artifact may not create the Java source folder, so you may
-      have to add it yourself. Go to 'New'-&gt;Source Folder and enter a value
-      of 'src/main/java', and then 'Finish'.</para>
+      <para>When creating the project, the Java source folder may not be added
+      automatically, case in which you have to add it yourself. Go to
+      'New'-&gt;Source Folder and enter a value of 'src/main/java', and then
+      click 'Finish'.</para>
 
       <para>The final step is to add the Spring Project nature to your
       project. While this is not strictly necessary for your application, it
@@ -262,7 +259,7 @@
       <example>
         <title>Domain entity definition</title>
 
-        <para><programlisting>package org.jboss.spring.getting.started.domain;
+        <para><programlisting language="java">package org.jboss.spring.getting.started.domain;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
@@ -310,12 +307,13 @@
       </example>
 
       <para>Data access will be provided through a JPA-based DAO, which will
-      be installed as Spring Bean. The interface for this component is:</para>
+      be installed as a Spring bean. The interface for this component
+      is:</para>
 
       <example>
         <title>Interface for the User DAO</title>
 
-        <para><programlisting>package org.jboss.spring.getting.started.domain;
+        <para><programlisting language="java">package org.jboss.spring.getting.started.domain;
 
 public interface UserDao {
   User getForUsername(String username);
@@ -335,22 +333,33 @@
       Spring supports different transaction propagation modes).</para>
 
       <example>
-        <title></title>
+        <title>UserDao implementation</title>
 
-        <para><programlisting>
+        <para><programlisting language="java">package org.jboss.spring.getting.started.domain;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
 @Service
 public class UserDaoImpl implements UserDao {
 
-  @Autowired
-  private EntityManager entityManager;
+    @PersistenceContext
+    private EntityManager entityManager;
 
-  @Transactional
-  public User getForUsername(String username) {
-   Query query = entityManager.createQuery("select u from User u where u.username = ?");
-   query.setParameter(1, username);
-   return (User)query.getSingleResult();
-  }
-}</programlisting></para>
+    @Transactional
+    public User getForUsername(String username) {
+        Query query = entityManager
+                .createQuery("select u from User u where u.username = ?");
+        query.setParameter(1, username);
+        return (User) query.getSingleResult();
+    }
+
+}
+</programlisting></para>
       </example>
 
       <para>In the web tier, we will need a controller and a web page for
@@ -358,27 +367,38 @@
       first.</para>
 
       <example>
-        <title></title>
+        <title>The MVC Controller class</title>
 
-        <para><programlisting>@Controller
+        <para><programlisting language="java">package org.jboss.spring.getting.started.mvc;
+
+import org.jboss.spring.getting.started.domain.User;
+import org.jboss.spring.getting.started.domain.UserDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+ at Controller
 @RequestMapping("say-hello")
 public class UserController {
 
- @Autowired
- private UserDao userDao;
- 
- @RequestMapping(method = RequestMethod.GET)
- public @ModelAttribute("message") String getInitialMessage()
- {
-  return "Enter a Valid Name";
- }
- 
- @RequestMapping(method = RequestMethod.POST)
- public @ModelAttribute("message") String getGreeting(@RequestParam("username") String username)
- {
-   User user = userDao.getForUsername(username);
-   return "Hello, " + user.getFirstName() + " " + user.getLastName() + "!";
- }
+    @Autowired
+    private UserDao userDao;
+
+    @RequestMapping(method = RequestMethod.GET)
+    public @ModelAttribute("message")
+    String getInitialMessage() {
+        return "Enter a Valid Name";
+    }
+
+    @RequestMapping(method = RequestMethod.POST)
+    public @ModelAttribute("message")
+    String getGreeting(@RequestParam("username") String username) {
+        User user = userDao.getForUsername(username);
+        return "Hello, " + user.getFirstName() + " " + user.getLastName() + "!";
+    }
 }</programlisting></para>
       </example>
 
@@ -414,11 +434,11 @@
       new JSP page as /src/main/webapp/WEB-INF/views/say-hello.jsp.</para>
 
       <example>
-        <title></title>
+        <title>The Web page that renders the results</title>
 
-        <para><programlisting>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
+        <para><programlisting language="jsp">&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
     pageEncoding="UTF-8"%&gt;
-&lt;%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %&gt;
+&lt;%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%&gt;
 &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
 &lt;html&gt;
 &lt;head&gt;
@@ -426,11 +446,10 @@
 &lt;title&gt;Hello&lt;/title&gt;
 &lt;/head&gt;
 &lt;body&gt;
-&lt;form method="post" action="say-hello"&gt;
-Enter username: &lt;input type="text" name="username" value="&lt;c:out value="${username}"/&gt;"&gt;
-&lt;c:out value="${message}"/&gt;
-&lt;p&gt;
-&lt;input type="submit" value="Submit"&gt;
+&lt;form method="post" action="say-hello"&gt;Enter username: &lt;input
+    type="text" name="username" value="&lt;c:out value="${username}"/&gt;"&gt;
+&lt;c:out value="${message}" /&gt;
+&lt;p&gt;&lt;input type="submit" value="Submit"&gt;
 &lt;/form&gt;
 
 &lt;/body&gt;
@@ -445,20 +464,37 @@
       database initialization script and creating a persistence unit.</para>
 
       <para>For creating a database initialization script, add a new file
-      named init-db.sql underneath src/main/resources/.</para>
+      named init-db.sql underneath src/main/resources.</para>
 
       <example>
-        <title></title>
+        <title>The database initialization script</title>
 
-        <para><programlisting></programlisting>As well, we need to create a
-        persistence unit definition file. Create the persistence.xml file
-        underneath src/main/resources/META-INF.</para>
+        <para><programlisting language="sql">DROP TABLE USERS IF EXISTS CASCADE;
+CREATE TABLE USERS (
+  ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL PRIMARY KEY, 
+  USERNAME VARCHAR(255),
+  FIRSTNAME VARCHAR(255),
+  LASTNAME VARCHAR(255));
+  
+INSERT INTO USERS (ID, USERNAME, FIRSTNAME, LASTNAME) VALUES (1, 'jdoe', 'John', 'Doe');
+INSERT INTO USERS (ID, USERNAME, FIRSTNAME, LASTNAME) VALUES (2, 'emuster', 'Erika', 'Mustermann');
+</programlisting>As well, we need to create a persistence unit definition
+        file. Create the persistence.xml file underneath
+        src/main/resources/META-INF.</para>
       </example>
 
       <example>
-        <title></title>
+        <title>The persistence unit definition file</title>
 
-        <para><programlisting></programlisting></para>
+        <para><programlisting language="xml">&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"&gt;
+   &lt;persistence-unit name="helloPU" transaction-type="JTA"&gt;
+       &lt;jta-data-source&gt;java:/DefaultDS&lt;/jta-data-source&gt;
+       &lt;properties&gt;
+            &lt;property name="jboss.entity.manager.jndi.name" value="java:/hello/EntityManager"/&gt;
+            &lt;property name="hibernate.show_sql" value="true"/&gt;
+       &lt;/properties&gt;
+   &lt;/persistence-unit&gt;
+&lt;/persistence&gt;</programlisting></para>
       </example>
     </section>
 
@@ -486,7 +522,10 @@
       <para>For configuring the web application, update the web.xml as
       follows:</para>
 
-      <programlisting>&lt;!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+      <example>
+        <title>The web.xml definition</title>
+
+        <para><programlisting language="xml">&lt;!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
                          "http://java.sun.com/dtd/web-app_2_3.dtd"&gt;
 &lt;web-app&gt;
  &lt;display-name&gt;Getting Started with Spring&lt;/display-name&gt;
@@ -512,7 +551,8 @@
  &lt;/servlet-mapping&gt;
 
 &lt;/web-app&gt;
-</programlisting>
+</programlisting></para>
+      </example>
 
       <para>The ContextLoaderListener will boostrap an application context
       containing the business components, while the DispatcherServlet will
@@ -525,34 +565,33 @@
       the 'Next' option and select the following namespaces: bean, context,
       jbdc, jee and tx. The content of the file is as follows;</para>
 
-      <programlisting>&lt;beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:jee="http://www.springframework.org/schema/jee"
- xmlns:jdbc="http://www.springframework.org/schema/jdbc"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"&gt;
- 
- &lt;context:component-scan base-package="org.jboss.spring.getting.started.domain"/&gt;
- 
- &lt;jee:jndi-lookup jndi-name="java:/DefaultDS" id="dataSource" expected-type="javax.sql.DataSource"/&gt;
- 
- &lt;jee:jndi-lookup jndi-name="java:/hello/EntityManager" id="entityManager" expected-type="javax.persistence.EntityManager"/&gt;
- 
- &lt;tx:jta-transaction-manager/&gt;
- 
- &lt;tx:annotation-driven/&gt;
- 
- &lt;jdbc:initialize-database data-source="dataSource"&gt;
-     &lt;jdbc:script location="classpath*:init-db.sql"/&gt;
- &lt;/jdbc:initialize-database&gt;
- 
+      <programlisting lang="xml">&lt;beans xmlns="http://www.springframework.org/schema/beans"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
+   xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
+   xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
+   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
+        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
+        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
+        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"&gt;
+
+   &lt;context:component-scan base-package="org.jboss.spring.getting.started.domain" /&gt;
+
+   &lt;jee:jndi-lookup jndi-name="java:/DefaultDS" id="dataSource"
+      expected-type="javax.sql.DataSource" /&gt;
+
+   &lt;jee:jndi-lookup jndi-name="java:/hello/EntityManager"
+      id="entityManager" expected-type="javax.persistence.EntityManager" /&gt;
+
+   &lt;tx:jta-transaction-manager /&gt;
+
+   &lt;tx:annotation-driven /&gt;
+
+   &lt;jdbc:initialize-database data-source="dataSource"&gt;
+      &lt;jdbc:script location="classpath*:init-db.sql" /&gt;
+   &lt;/jdbc:initialize-database&gt;
+
 &lt;/beans&gt;</programlisting>
 
       <para>First, we instructed Spring to scan the package
@@ -573,24 +612,28 @@
       context and mvc in the dialog. The configuration file is structured as
       follows:</para>
 
-      <programlisting>&lt;beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
- http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;
+      <example>
+        <title>Dispatcher servlet configuration file</title>
 
- &lt;context:component-scan base-package="org.jboss.spring.getting.started.mvc"/&gt;
- 
- &lt;mvc:annotation-driven/&gt;
- 
- &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
- &lt;property name="prefix" value="/WEB-INF/views/"/&gt;
- &lt;property name="suffix" value=".jsp"&gt;&lt;/property&gt;
- &lt;/bean&gt;
+        <para><programlisting language="xml">&lt;beans xmlns="http://www.springframework.org/schema/beans"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
+   xmlns:mvc="http://www.springframework.org/schema/mvc"
+   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
+        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;
+
+   &lt;context:component-scan base-package="org.jboss.spring.getting.started.mvc" /&gt;
+
+   &lt;mvc:annotation-driven /&gt;
+
+   &lt;bean
+      class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
+      &lt;property name="prefix" value="/WEB-INF/views/" /&gt;
+      &lt;property name="suffix" value=".jsp"&gt;&lt;/property&gt;
+   &lt;/bean&gt;
 &lt;/beans&gt;
-</programlisting>
+</programlisting></para>
+      </example>
 
       <para>Using this context definition, Spring will scan for component
       beans (such as the UserController), and will use the mappings defined by
@@ -633,6 +676,14 @@
         choose a JBoss EAP 5.1 instance and click Finish. If you don't find a
         JBoss EAP instance, please refer to Appendix B for details.</para>
       </simplesect>
+
+      <simplesect>
+        <title>Accessing the running example</title>
+
+        <para>After deploying the example and starting JBoss EAP, the example
+        can be accessed at
+        <uri>http://localhost:8080/getting-started</uri>.</para>
+      </simplesect>
     </section>
   </section>
 

Modified: projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US/Spring_On_JBoss_Best_Practices.xml
===================================================================
--- projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US/Spring_On_JBoss_Best_Practices.xml	2011-03-22 22:56:14 UTC (rev 111003)
+++ projects/docs/enterprise/WFK/Spring_Developer_Guide/en-US/Spring_On_JBoss_Best_Practices.xml	2011-03-22 23:47:21 UTC (rev 111004)
@@ -8,10 +8,9 @@
   <title>Best practices and integration guidelines</title>
 
   <para>The Spring Framework is a flexible environment for developing
-  enterprise applications, with respect to the middleware integration.This
-  means that the developer has the benefit of being able to choose between a
-  number of alternatives when it comes to accessing middleware
-  services.</para>
+  enterprise applications. .This means that the developer has the benefit of
+  being able to choose between a number of alternatives when it comes to
+  accessing middleware services.</para>
 
   <para>JBoss is a feature-rich application server, that provides a complex
   and performant set of middleware services. Spring developers can take
@@ -83,7 +82,7 @@
       <example>
         <title>Defining a managed datasource Spring bean</title>
 
-        <programlisting>&lt;jee:jndi-lookup id="dataSource" jndi-name="java:/ExampleDsJndiName"/&gt;</programlisting>
+        <programlisting lang="xml">&lt;jee:jndi-lookup id="dataSource" jndi-name="java:/ExampleDsJndiName"/&gt;</programlisting>
       </example>
 
       <para>Such a datasource bean can be injected in any regular Spring bean
@@ -105,7 +104,7 @@
       <example>
         <title>SessionFactory bean definition</title>
 
-        <para><programlisting>&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
+        <para><programlisting lang="xml">&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
         &lt;property name="dataSource" ref="dataSource"/&gt;
        ...
 &lt;/bean&gt;</programlisting></para>
@@ -117,7 +116,7 @@
       <example>
         <title>JTA session management setup properties</title>
 
-        <programlisting>hibernate.current_session_context_class=jta
+        <programlisting language="xml">hibernate.current_session_context_class=jta
 hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
 hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory</programlisting>
       </example>
@@ -130,8 +129,7 @@
         <title>Hibernate-based DAO: a SessionFactory is injected directly in
         the bean</title>
 
-        <para><programlisting>public class HibernateAccountDao 
-{
+        <para><programlisting language="java">public class HibernateAccountDao {
   @Autowired SessionFactory sessionFactory;
 
   public List&lt;Account&gt; getAllAccounts() {
@@ -140,6 +138,10 @@
   ...
 }</programlisting></para>
       </example>
+
+      <para>A comprehensive example of using Hibernate-driven data access in
+      Spring-based applications can be found in the Sportsclub demo
+      application, included in the Web Framework Kit distribution.</para>
     </section>
 
     <section>
@@ -154,7 +156,7 @@
       <example>
         <title>Persistence unit definition</title>
 
-        <programlisting>&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"&gt;
+        <programlisting language="xml">&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"&gt;
    &lt;persistence-unit name="sportsclubPU"&gt;
        &lt;jta-data-source&gt;java:/ExampleDsJndiName&lt;/jta-data-source&gt;
        &lt;properties&gt;
@@ -176,7 +178,7 @@
         <title>Spring bean representing a container-managed entity
         manager</title>
 
-        <programlisting>&lt;jee:jndi-lookup id="entityManager" jndi-name="java:/example/em"/&gt;</programlisting>
+        <programlisting language="xml">&lt;jee:jndi-lookup id="entityManager" jndi-name="java:/example/em"/&gt;</programlisting>
       </example>
 
       <para>Such an EntityManager can be used directly if injected in
@@ -186,8 +188,7 @@
         <title>Hibernate-based DAO: a SessionFactory is injected directly in
         the bean</title>
 
-        <para><programlisting>public class HibernateAccountDao 
-{
+        <para><programlisting language="xml">public class HibernateAccountDao {
   @Autowired EntityManager entityManager;
 
   public List&lt;Account&gt; getAllAccounts() {
@@ -206,7 +207,7 @@
       <example>
         <title>Spring bean representing an entity manager factory</title>
 
-        <programlisting>&lt;jee:jndi-lookup id="entityManagerFactory" jndi-name="java:/example/emf"/&gt;</programlisting>
+        <programlisting language="xml">&lt;jee:jndi-lookup id="entityManagerFactory" jndi-name="java:/example/emf"/&gt;</programlisting>
       </example>
 
       <para>In general, for implementing transaction-aware components (for
@@ -216,6 +217,10 @@
       JNDI-bound EntityManager, as it is JTA-synchronized and will be shared
       with non-Spring components that use JPA as well (e.g. EJBs).</para>
 
+      <para>A comprehensive example of using JPA-driven data access in
+      Spring-based applications can be found in the Sportsclub demo
+      application, included in the Web Framework Kit distribution.</para>
+
       <para>One important limitation of working with JNDI-bound EntityManagers
       and EntityManagerFactories is the lack of support for read-only
       transactions in Spring. When declaring transactions, Spring applications
@@ -226,8 +231,8 @@
 
         <programlisting>@Transaction(readOnly = true)
 public List&lt;Account&gt; getAllAccounts() {
-     return entityManager.createQuery("SELECT a FROM Account").getResultList();
-  }</programlisting>
+    return entityManager.createQuery("SELECT a FROM Account").getResultList();
+}</programlisting>
       </example>
 
       <para>A common misconception is that the readOnly flag will prevent the
@@ -256,18 +261,18 @@
       <example>
         <title>A Spring-defined JTA-based entity manager factory</title>
 
-        <para><programlisting>    &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
-        &lt;property name="jpaVendorAdapter"&gt;
-            &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/&gt;
-        &lt;/property&gt;
-        &lt;property name="jpaProperties"&gt;
-            &lt;props&gt;
-                &lt;prop key="hibernate.transaction.manager_lookup_class"&gt;
-                    org.hibernate.transaction.JBossTransactionManagerLookup
-                &lt;/prop&gt;
-            &lt;/props&gt;
-        &lt;/property&gt;
-    &lt;/bean&gt;</programlisting></para>
+        <para><programlisting>&lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
+    &lt;property name="jpaVendorAdapter"&gt;
+        &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/&gt;
+    &lt;/property&gt;
+    &lt;property name="jpaProperties"&gt;
+        &lt;props&gt;
+             &lt;prop key="hibernate.transaction.manager_lookup_class"&gt;
+                 org.hibernate.transaction.JBossTransactionManagerLookup
+             &lt;/prop&gt;
+         &lt;/props&gt;
+    &lt;/property&gt;
+&lt;/bean&gt;</programlisting></para>
 
         <para>The above definition relies upon a META-INF/persistence.xml file
         being provided in the deployment. However, in such a case it may be
@@ -280,7 +285,7 @@
       <example>
         <title>Using an alternative location for persistence.xml</title>
 
-        <para><programlisting lang="XML" language="XML">&lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
+        <para><programlisting lang="XML" language="xml">&lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
    &lt;property name="persistenceXmlLocation" value="classpath*:META-INF/persistence-booking.xml"/&gt;
    &lt;!-- other properties (ommitted) --&gt;
 &lt;/bean&gt;</programlisting></para>
@@ -320,7 +325,7 @@
         <title>Example of a PersistenceUnitPostProcessor implementation that
         adds all classes annotated with @Entity</title>
 
-        <programlisting>package org.springframework.webflow.samples.booking;
+        <programlisting language="java">package org.springframework.webflow.samples.booking;
 
 import java.io.IOException;
 
@@ -367,7 +372,7 @@
             <title>Adding the PersistenceUnitPostProcessor to the context
             definition</title>
 
-            <para><programlisting>&lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
+            <para><programlisting language="xml">&lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
 &lt;!-- other properties --&gt;
   &lt;property name="persistenceUnitPostProcessors"&gt;
     &lt;list&gt;
@@ -384,27 +389,52 @@
     <title>Messaging (JMS) integration</title>
 
     <para>Spring applications have two distinct mechanisms of integrating with
-    JMS. One is by using the JmsTemplate which accessing the JMS API directly
-    for both sending and receiving messages, and the other is by implementing
-    message-driven POJOs. The best practice in JBoss is to use the JmsTemplate
-    for sending messages but not for receiving them, as the
-    message-driven/event-driven paradigm is a superior approach both as a
-    programming style and performance-wise than polling/blocking via
+    JMS. One is by using the JmsTemplate which simplifies the usage of the JMS
+    API for both sending and receiving messages, and the other is by
+    implementing message-driven POJOs.</para>
+
+    <para>The best practice in JBoss is to use the JmsTemplate for sending
+    messages, but not for receiving them, as the message-driven/event-driven
+    paradigm is a superior approach both as a programming style and
+    performance-wise than polling/blocking via
     JmsTemplate.receiveMessage().</para>
 
     <para>Spring applications can implement message-driven POJOs by wiring
     MessageListener beans (or POJOs via a MessageListenerAdapter) into a
-    MessageListenerContainer. MessageListenerContainers come in two flavours:
+    MessageListenerContainer.</para>
+
+    <para>An typical of a message-driven POJO can be seen in example <xref
+    linkend="listing-message-driven-pojo" />.</para>
+
+    <example id="listing-message-driven-pojo">
+      <title>A message-driven POJO is a simple Java class</title>
+
+      <programlisting>
+public class MessageDrivenPojo
+{
+  @Autowire PaymentProcessor paymentProcessor;
+
+  public void pojoHandlerMethod(PaymentNotification paymentNotification)
+  {
+    paymentProcessor.processPayment(paymentNotification.getAccountNumber(), paymentNotification.getAmount());
+  }
+}
+</programlisting>
+    </example>
+
+    <para>Spring provides two dfferent types of MessageListenerContainers:
     'native' JMS and JCA-based. On JBoss AS we recommend using the JCA
     MessageListenerContainer, due to the better integration with the
-    container. In order to minimize the amount of proprietary code, you can
-    use Snowdrop's namespace support for JMS/JCA integration.</para>
+    container, in what concerns message delivery and session, connection, and
+    message consumer management. In order to minimize the amount of
+    proprietary code, you can use Snowdrop's namespace support for JMS/JCA
+    integration (see Snowdrop documentation for details).</para>
 
     <example>
       <title>Using the JCA message listener containers and namespace support
       in JBoss</title>
 
-      <para><programlisting> &lt;jms:jca-listener-container resource-adapter="resourceAdapter" acknowledge="auto"
+      <para><programlisting language="xml"> &lt;jms:jca-listener-container resource-adapter="resourceAdapter" acknowledge="auto"
                                 activation-spec-factory="activationSpecFactory"&gt;
         &lt;jms:listener destination="/someDestination" ref="messageDrivenPojo"
                       method="pojoHandlerMethod"/&gt;
@@ -426,36 +456,19 @@
     converting message content to the expected argument type. For a JCA-based
     container, the invocation will be automatically enrolled in a JTA
     transaction.</para>
-
-    <para>A message-driven POJO is provided in the following listing:</para>
-
-    <para><example>
-        <title>A message-driven POJO is a regular bean type</title>
-
-        <para></para>
-
-        <programlisting>
-public class MessageDrivenPojo
-{
-  @Autowire PaymentProcessor paymentProcessor;
-
-  public void pojoHandlerMethod(PaymentNotification paymentNotification)
-  {
-    paymentProcessor.processPayment(paymentNotification.getAccountNumber(), paymentNotification.getAmount());
-  }
-}
-</programlisting>
-      </example></para>
   </section>
 
   <section>
     <title>Transaction management</title>
 
-    <para>The recommended transaction management strategy for JBoss is by
-    using JTA whose performance is close to native JDBC in single-resource
-    scenarios and XA-capable in multiple-resource scenarios. One of the
-    significant advantages of JTA is integration with other components of the
-    application stack - such as EJBs and third-party components.</para>
+    <para>Transactions are central to data integrity, and using transactions
+    is critical for implementing a robust and reliable applications. The
+    Spring framework In addition to, the transaction manager included with
+    JBoss provides a performance close to native JDBC in single-resource
+    database access scenarios and being XA-capable in multiple-resource
+    scenarios (such as, for example mixing JMa. One of the significant
+    advantages of JTA is integration with other components of the application
+    stack - such as EJBs and third-party components.</para>
 
     <para>Spring provides a declarative transaction model including
     transaction propagation semantics, so that applications can declare
@@ -473,7 +486,7 @@
     <example>
       <title>JTA transaction manager definition in Spring</title>
 
-      <programlisting>&lt;tx:jta-transaction-manager/&gt;</programlisting>
+      <programlisting lang="xml">&lt;tx:jta-transaction-manager/&gt;</programlisting>
     </example>
 
     <para>The use of this transaction manager allows Spring to create JTA
@@ -489,33 +502,8 @@
   </section>
 
   <section>
-    <title>Web Services integration (JAX-WS)</title>
+    <title>EJB integration</title>
 
-    <para>Spring applications can create web services in a variety of way. In
-    the simplest case, Spring applications can register JAX-WS web services
-    out of the box, by simply defining an annotated class and registering it
-    as a servlet.</para>
-
     <para></para>
   </section>
-
-  <section>
-    <title>EJB integration</title>
-
-    <para>This needs content to build.</para>
-  </section>
-
-  <section>
-    <title>Security integration</title>
-
-    <para>This needs content to build</para>
-
-    <para>This needs content to build</para>
-  </section>
-
-  <section>
-    <title>This needs content to build</title>
-
-    <para>This needs content to build.</para>
-  </section>
 </chapter>



More information about the jboss-cvs-commits mailing list