[jboss-svn-commits] JBL Code SVN: r37255 - in labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app: src/main/java/org/jboss/narayana/quickstarts/ejb and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jul 12 08:58:03 EDT 2011


Author: tomjenkinson
Date: 2011-07-12 08:58:03 -0400 (Tue, 12 Jul 2011)
New Revision: 37255

Modified:
   labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/pom.xml
   labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJB.java
   labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJBImpl.java
   labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/CustomerManager.java
   labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/CustomerManagerManagedBean.java
   labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/CustomerCreationCounter.java
   labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/test/java/TestManagedBeanCustomerManager.java
Log:
JBTM-854 updated to provide more documentation

Modified: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/pom.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/pom.xml	2011-07-11 21:10:09 UTC (rev 37254)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/pom.xml	2011-07-12 12:58:03 UTC (rev 37255)
@@ -1,192 +1,231 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware 
-		LLC, and individual contributors as indicated by the @author tags. See the 
-		copyright.txt in the distribution for a full listing of individual contributors. 
-		This copyrighted material is made available to anyone wishing to use, modify, 
-		copy, or redistribute it subject to the terms and conditions of the GNU Lesser 
-		General Public License, v. 2.1. This program is distributed in the hope that 
-		it will be useful, but WITHOUT A WARRANTY; without even the implied warranty 
-		of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 
-		General Public License for more details. You should have received a copy 
-		of the GNU Lesser General Public License, v.2.1 along with this distribution; 
-		if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 
-		Fifth Floor, Boston, MA 02110-1301, USA. (C) 2009 -->
-<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">
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>org.jboss.narayana.jta.quickstarts</groupId>
-  <artifactId>jee_transactional_app</artifactId>
-  <version>5.0.0.M1-SNAPSHOT</version>
-  <name>basic integration example</name>
-  <description>basic integration example</description>
-  <packaging>war</packaging>
-  <repositories>
-    <repository>
-      <id>jboss-public-repository-group</id>
-      <name>JBoss Public Maven Repository Group</name>
-      <url>https://repository.jboss.org/nexus/content/groups/public/</url>
-      <releases>
-        <enabled>true</enabled>
-      </releases>
-      <snapshots>
-        <enabled>true</enabled>
-      </snapshots>
-    </repository>
-  </repositories>
-  <pluginRepositories>
-    <pluginRepository>
-      <id>jboss-public-repository-group</id>
-      <name>JBoss Public Maven Repository Group</name>
-      <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
-      <layout>default</layout>
-      <releases>
-        <enabled>true</enabled>
-        <updatePolicy>never</updatePolicy>
-      </releases>
-      <snapshots>
-        <enabled>true</enabled>
-        <updatePolicy>never</updatePolicy>
-      </snapshots>
-    </pluginRepository>
-  </pluginRepositories>
+	LLC, and individual contributors as indicated by the @author tags. See the 
+	copyright.txt in the distribution for a full listing of individual contributors. 
+	This copyrighted material is made available to anyone wishing to use, modify, 
+	copy, or redistribute it subject to the terms and conditions of the GNU Lesser 
+	General Public License, v. 2.1. This program is distributed in the hope that 
+	it will be useful, but WITHOUT A WARRANTY; without even the implied warranty 
+	of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 
+	General Public License for more details. You should have received a copy 
+	of the GNU Lesser General Public License, v.2.1 along with this distribution; 
+	if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 
+	Fifth Floor, Boston, MA 02110-1301, USA. (C) 2009 -->
+<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">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.jboss.narayana.jta.quickstarts</groupId>
+	<artifactId>jee_transactional_app</artifactId>
+	<version>5.0.0.M1-SNAPSHOT</version>
+	<name>basic integration example</name>
+	<description>basic integration example</description>
+	<packaging>war</packaging>
+	<repositories>
+		<repository>
+			<id>jboss-public-repository-group</id>
+			<name>JBoss Public Maven Repository Group</name>
+			<url>https://repository.jboss.org/nexus/content/groups/public/</url>
+			<releases>
+				<enabled>true</enabled>
+			</releases>
+			<snapshots>
+				<enabled>true</enabled>
+			</snapshots>
+		</repository>
+	</repositories>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>jboss-public-repository-group</id>
+			<name>JBoss Public Maven Repository Group</name>
+			<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
+			<layout>default</layout>
+			<releases>
+				<enabled>true</enabled>
+				<updatePolicy>never</updatePolicy>
+			</releases>
+			<snapshots>
+				<enabled>true</enabled>
+				<updatePolicy>never</updatePolicy>
+			</snapshots>
+		</pluginRepository>
+	</pluginRepositories>
 
-  <properties>
-    <!-- For arquillian -->
-    <jbossHome>${env.JBOSS_HOME}</jbossHome>
-  </properties>
+	<properties>
+		<!-- For arquillian -->
+		<jbossHome>${env.JBOSS_HOME}</jbossHome>
+	</properties>
 
-  <build>
-      <finalName>${pom.artifactId}</finalName>
-    <plugins>
-      <plugin>
-        <artifactId>maven-war-plugin</artifactId>
-        <configuration>
-          <!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->
-          <failOnMissingWebXml>false</failOnMissingWebXml>
-          <archive>
-            <manifestEntries>
-              <Dependencies>org.jboss.jts</Dependencies>
-            </manifestEntries>
-          </archive>
-        </configuration>
-      </plugin>
-      <!-- JBoss AS plugin to deploy war as a convenience -->
-      <plugin>
-        <groupId>org.jboss.as.plugins</groupId>
-        <artifactId>jboss-as-maven-plugin</artifactId>
-        <version>7.0.0.CR1</version>
-      </plugin>
-         <!-- Compiler plugin enforces Java 1.6 compatibility and activates 
-            annotation processors -->
-         <plugin>
-            <artifactId>maven-compiler-plugin</artifactId>
-            <configuration>
-               <source>1.6</source>
-               <target>1.6</target>
-            </configuration>
-         </plugin>
-    </plugins>
-  </build>
+	<build>
+		<finalName>${pom.artifactId}</finalName>
+		<plugins>
+			<plugin>
+				<artifactId>maven-war-plugin</artifactId>
+				<configuration>
+					<!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->
+					<failOnMissingWebXml>false</failOnMissingWebXml>
+					<archive>
+						<manifestEntries>
+							<Dependencies>org.jboss.jts</Dependencies>
+						</manifestEntries>
+					</archive>
+				</configuration>
+			</plugin>
+			<!-- JBoss AS plugin to deploy war as a convenience -->
+			<plugin>
+				<groupId>org.jboss.as.plugins</groupId>
+				<artifactId>jboss-as-maven-plugin</artifactId>
+				<version>7.0.0.CR1</version>
+			</plugin>
+			<!-- Compiler plugin enforces Java 1.6 compatibility and activates annotation 
+				processors -->
+			<plugin>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.6</source>
+					<target>1.6</target>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
 
-  <dependencyManagement>
-    <dependencies>
-      <!-- Define the version of JBoss' Java EE 6 APIs we want to import. Any dependencies from org.jboss.spec will have their version defined by this BOM -->
-      <!-- JBoss distributes a complete set of Java EE 6 APIs including a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or a collection) of artifacts. We use this here so that we always get the correct versions of artifacts. Here we use the jboss-javaee-web-6.0 stack (you can read this as the JBoss stack of the Java EE Web Profile 6 APIs), and we use version 2.0.0.Beta1 which is the latest release of the stack. You can actually use this stack with any version of JBoss AS that implements Java EE 6, not just JBoss AS 7! -->
-      <dependency>
-        <groupId>org.jboss.spec</groupId>
-        <artifactId>jboss-javaee-web-6.0</artifactId>
-        <version>2.0.0.CR1</version>
-        <type>pom</type>
-        <scope>import</scope>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
+	<dependencyManagement>
+		<dependencies>
+			<!-- Define the version of JBoss' Java EE 6 APIs we want to import. Any 
+				dependencies from org.jboss.spec will have their version defined by this 
+				BOM -->
+			<!-- JBoss distributes a complete set of Java EE 6 APIs including a Bill 
+				of Materials (BOM). A BOM specifies the versions of a "stack" (or a collection) 
+				of artifacts. We use this here so that we always get the correct versions 
+				of artifacts. Here we use the jboss-javaee-web-6.0 stack (you can read this 
+				as the JBoss stack of the Java EE Web Profile 6 APIs), and we use version 
+				2.0.0.Beta1 which is the latest release of the stack. You can actually use 
+				this stack with any version of JBoss AS that implements Java EE 6, not just 
+				JBoss AS 7! -->
+			<dependency>
+				<groupId>org.jboss.spec</groupId>
+				<artifactId>jboss-javaee-web-6.0</artifactId>
+				<version>2.0.0.CR1</version>
+				<type>pom</type>
+				<scope>import</scope>
+			</dependency>
+		</dependencies>
+	</dependencyManagement>
 
-  <dependencies>
+	<dependencies>
+		<!-- Import the JPA API, we use provided scope as the API is included in 
+			JBoss AS 7 -->
+		<dependency>
+			<groupId>org.jboss.spec.javax.transaction</groupId>
+			<artifactId>jboss-transaction-api_1.1_spec</artifactId>
+			<scope>provided</scope>
+		</dependency>
 
-    <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3-ext-api</artifactId>
-      <version>1.1.0</version>
-      <scope>provided</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss.logging</groupId>
-          <artifactId>jboss-logging-spi</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
+		<!-- Import the JSF API, we use provided scope as the API is included in 
+			JBoss AS 7 -->
+		<dependency>
+			<groupId>org.jboss.spec.javax.faces</groupId>
+			<artifactId>jboss-jsf-api_2.0_spec</artifactId>
+			<scope>provided</scope>
+		</dependency>
 
-    <!-- Import the JPA API, we use provided scope as the API is included in JBoss AS 7 -->
-    <dependency>
-      <groupId>org.jboss.spec.javax.transaction</groupId>
-      <artifactId>jboss-transaction-api_1.1_spec</artifactId>
-      <scope>provided</scope>
-    </dependency>
+		<!-- Import the JPA API, we use provided scope as the API is included in 
+			JBoss AS 7 -->
+		<dependency>
+			<groupId>org.hibernate.javax.persistence</groupId>
+			<artifactId>hibernate-jpa-2.0-api</artifactId>
+			<scope>provided</scope>
+		</dependency>
 
-    <!-- Import the JSF API, we use provided scope as the API is included in JBoss AS 7 -->
-    <dependency>
-      <groupId>org.jboss.spec.javax.faces</groupId>
-      <artifactId>jboss-jsf-api_2.0_spec</artifactId>
-      <scope>provided</scope>
-    </dependency>
+		<!-- Import the EJB API, we use provided scope as the API is included in 
+			JBoss AS 7 -->
+		<dependency>
+			<groupId>org.jboss.spec.javax.ejb</groupId>
+			<artifactId>jboss-ejb-api_3.1_spec</artifactId>
+			<scope>provided</scope>
+		</dependency>
 
-    <!-- Import the JPA API, we use provided scope as the API is included in JBoss AS 7 -->
-    <dependency>
-      <groupId>org.hibernate.javax.persistence</groupId>
-      <artifactId>hibernate-jpa-2.0-api</artifactId>
-      <scope>provided</scope>
-    </dependency>
+		<!-- Import the CDI API, we use provided scope as the API is included in 
+			JBoss AS 7 -->
+		<dependency>
+			<groupId>javax.enterprise</groupId>
+			<artifactId>cdi-api</artifactId>
+			<scope>provided</scope>
+		</dependency>
 
-    <!-- Import the EJB API, we use provided scope as the API is included in JBoss AS 7 -->
-    <dependency>
-      <groupId>org.jboss.spec.javax.ejb</groupId>
-      <artifactId>jboss-ejb-api_3.1_spec</artifactId>
-      <scope>provided</scope>
-    </dependency>
+		<!-- For the txoj -->
+		<dependency>
+			<groupId>org.jboss.jbossts</groupId>
+			<artifactId>jbossjta</artifactId>
+			<version>4.15.1.Final</version>
+			<scope>provided</scope>
+			<exclusions>
+				<exclusion>
+					<groupId>org.jboss.logging</groupId>
+					<artifactId>jboss-logging-spi</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
 
-    <!-- For the txoj -->
-    <dependency>
-      <groupId>org.jboss.jbossts</groupId>
-      <artifactId>jbossjta</artifactId>
-      <version>4.15.1.Final</version>
-      <scope>provided</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss.logging</groupId>
-          <artifactId>jboss-logging-spi</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    
-    <!-- Import the injection annotations -->
-    <dependency>
-      <groupId>javax.inject</groupId>
-      <artifactId>javax.inject</artifactId>
-      <version>1</version>
-      <scope>provided</scope>
-    </dependency>
-    
+		<!-- Import the injection annotations -->
+		<dependency>
+			<groupId>javax.inject</groupId>
+			<artifactId>javax.inject</artifactId>
+			<version>1</version>
+			<scope>provided</scope>
+		</dependency>
 
-    <!-- We will provide some tests to check the quickstart deploys ok -->
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.8.1</version>
-      <scope>test</scope>
-    </dependency>
+		<!-- We will provide some tests to check the quickstart deploys ok -->
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.8.1</version>
+			<scope>test</scope>
+		</dependency>
 
-    <!-- Arquillian allows you to test the example inside a container -->
-    <dependency>
-      <groupId>org.jboss.arquillian.junit</groupId>
-      <artifactId>arquillian-junit-container</artifactId>
-      <version>1.0.0.CR1</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.jboss.as</groupId>
-      <artifactId>jboss-as-arquillian-container-managed</artifactId>
-      <version>7.0.0.CR1</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
+		<!-- Arquillian allows you to test the example inside a container -->
+		<dependency>
+			<groupId>org.jboss.arquillian.junit</groupId>
+			<artifactId>arquillian-junit-container</artifactId>
+			<version>1.0.0.CR1</version>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+
+	<profiles>
+		<profile>
+			<!-- An optional Arquillian testing profile that executes tests in your 
+				JBoss AS instance -->
+			<!-- This profile will start a new JBoss AS instance, and execute the 
+				test, shutting it down when done -->
+			<!-- Run with: mvn clean test -Parq-jbossas-managed -->
+			<id>arq-jbossas-managed</id>
+			<!-- Launch this profile by default -->
+			<activation>
+				<activeByDefault>true</activeByDefault>
+			</activation>
+			<dependencies>
+				<dependency>
+					<groupId>org.jboss.as</groupId>
+					<artifactId>jboss-as-arquillian-container-managed</artifactId>
+					<version>7.0.0.CR1</version>
+					<scope>test</scope>
+				</dependency>
+			</dependencies>
+		</profile>
+
+		<profile>
+			<!-- An optional Arquillian testing profile that executes tests in a remote 
+				JBoss AS instance -->
+			<!-- Run with: mvn clean test -Parq-jbossas-remote -->
+			<id>arq-jbossas-remote</id>
+			<dependencies>
+				<dependency>
+					<groupId>org.jboss.as</groupId>
+					<artifactId>jboss-as-arquillian-container-remote</artifactId>
+					<version>7.0.0.CR1</version>
+					<scope>test</scope>
+				</dependency>
+			</dependencies>
+		</profile>
+	</profiles>
 </project>

Modified: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJB.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJB.java	2011-07-11 21:10:09 UTC (rev 37254)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJB.java	2011-07-12 12:58:03 UTC (rev 37255)
@@ -42,10 +42,29 @@
 	 */
 	public int createCustomer(String name) throws NamingException, Exception;
 
+	/**
+	 * List all the customers.
+	 * 
+	 * @return
+	 * @throws NamingException
+	 * @throws NotSupportedException
+	 * @throws SystemException
+	 * @throws SecurityException
+	 * @throws IllegalStateException
+	 * @throws RollbackException
+	 * @throws HeuristicMixedException
+	 * @throws HeuristicRollbackException
+	 */
 	public List<Customer> listCustomers() throws NamingException,
 			NotSupportedException, SystemException, SecurityException,
 			IllegalStateException, RollbackException, HeuristicMixedException,
 			HeuristicRollbackException;
 
+	/**
+	 * Get the total count of customers.
+	 * 
+	 * @return
+	 * @throws Exception
+	 */
 	public int getCustomerCount() throws Exception;
 }

Modified: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJBImpl.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJBImpl.java	2011-07-11 21:10:09 UTC (rev 37254)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJBImpl.java	2011-07-12 12:58:03 UTC (rev 37255)
@@ -25,6 +25,7 @@
 import javax.ejb.Stateless;
 import javax.ejb.TransactionAttribute;
 import javax.ejb.TransactionAttributeType;
+import javax.inject.Inject;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.persistence.EntityManager;
@@ -35,29 +36,33 @@
 import javax.transaction.RollbackException;
 import javax.transaction.SystemException;
 
+import org.jboss.logging.Logger;
+import org.jboss.narayana.quickstarts.jsf.CustomerManagerManagedBean;
 import org.jboss.narayana.quickstarts.txoj.CustomerCreationCounter;
 
 @Stateless
 public class CustomerManagerEJBImpl implements CustomerManagerEJB {
+	private Logger logger = Logger.getLogger(CustomerManagerManagedBean.class
+			.getName());
 
-	private CustomerCreationCounter atomicObject = new CustomerCreationCounter();
+	private CustomerCreationCounter customerCreationCounter = new CustomerCreationCounter();
 
 	@PersistenceContext(name = "my_persistence_ctx")
-	EntityManager em;
+	EntityManager entityManager;
 
 	@TransactionAttribute(TransactionAttributeType.REQUIRED)
 	public int createCustomer(String name) throws Exception {
-		System.out.println("createCustomer transaction is identified as: "
+		logger.debug("createCustomer transaction is identified as: "
 				+ new InitialContext().lookup("java:comp/UserTransaction")
 						.toString());
 
 		// Can do this first because if there is a duplicate it will be rolled
 		// back for us
-		atomicObject.incr(1);
+		customerCreationCounter.incr(1);
 
 		Customer c1 = new Customer();
 		c1.setName(name);
-		em.persist(c1);
+		entityManager.persist(c1);
 
 		return c1.getId();
 	}
@@ -68,17 +73,18 @@
 			NotSupportedException, SystemException, SecurityException,
 			IllegalStateException, RollbackException, HeuristicMixedException,
 			HeuristicRollbackException {
-		System.out.println("listCustomers transaction is identified as: "
+		logger.debug("listCustomers transaction is identified as: "
 				+ new InitialContext().lookup("java:comp/UserTransaction")
 						.toString());
-		return em.createQuery("select c from Customer c").getResultList();
+		return entityManager.createQuery("select c from Customer c")
+				.getResultList();
 	}
 
 	@TransactionAttribute(TransactionAttributeType.REQUIRED)
 	public int getCustomerCount() throws Exception {
-		System.out.println("getCustomerCount transaction is identified as: "
+		logger.debug("getCustomerCount transaction is identified as: "
 				+ new InitialContext().lookup("java:comp/UserTransaction")
 						.toString());
-		return atomicObject.get();
+		return customerCreationCounter.get();
 	}
 }

Modified: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/CustomerManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/CustomerManager.java	2011-07-11 21:10:09 UTC (rev 37254)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/CustomerManager.java	2011-07-12 12:58:03 UTC (rev 37255)
@@ -31,15 +31,43 @@
 
 import org.jboss.narayana.quickstarts.ejb.Customer;
 
+/**
+ * This is the customer manager as seen by the JSF pages. It defines the basic
+ * operations required to add and list customers.
+ */
 public interface CustomerManager {
 
+	/**
+	 * Get the list of current customers.
+	 * 
+	 * @return
+	 * @throws SecurityException
+	 * @throws IllegalStateException
+	 * @throws NamingException
+	 * @throws NotSupportedException
+	 * @throws SystemException
+	 * @throws RollbackException
+	 * @throws HeuristicMixedException
+	 * @throws HeuristicRollbackException
+	 */
 	public List<Customer> getCustomers() throws SecurityException,
 			IllegalStateException, NamingException, NotSupportedException,
 			SystemException, RollbackException, HeuristicMixedException,
 			HeuristicRollbackException;
 
+	/**
+	 * Add a customer to the database.
+	 * 
+	 * @param name
+	 * @return
+	 */
 	public String addCustomer(String name);
 
+	/**
+	 * Get the total count of customers.
+	 * 
+	 * @return
+	 * @throws Exception
+	 */
 	public int getCustomerCount() throws Exception;
-
 }
\ No newline at end of file

Modified: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/CustomerManagerManagedBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/CustomerManagerManagedBean.java	2011-07-11 21:10:09 UTC (rev 37254)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/CustomerManagerManagedBean.java	2011-07-12 12:58:03 UTC (rev 37255)
@@ -22,7 +22,6 @@
 
 import java.util.List;
 
-import javax.ejb.EJB;
 import javax.faces.bean.RequestScoped;
 import javax.inject.Inject;
 import javax.inject.Named;
@@ -34,46 +33,49 @@
 import javax.transaction.SystemException;
 import javax.transaction.UserTransaction;
 
+import org.jboss.logging.Logger;
 import org.jboss.narayana.quickstarts.ejb.Customer;
 import org.jboss.narayana.quickstarts.ejb.CustomerManagerEJB;
 
 @Named("customerManager")
 @RequestScoped
 public class CustomerManagerManagedBean implements CustomerManager {
+	private Logger logger = Logger.getLogger(CustomerManagerManagedBean.class
+			.getName());
 
-	@EJB
-	private CustomerManagerEJB simpleEJB;
+	@Inject
+	private CustomerManagerEJB customerManagerEJB;
 
 	@Inject
-	private UserTransaction utx;
+	private UserTransaction userTransaction;
 
 	public List<Customer> getCustomers() throws SecurityException,
 			IllegalStateException, NamingException, NotSupportedException,
 			SystemException, RollbackException, HeuristicMixedException,
 			HeuristicRollbackException {
-		System.out.println("Getting customers");
-		return simpleEJB.listCustomers();
+		logger.debug("Getting customers");
+		return customerManagerEJB.listCustomers();
 	}
 
 	public String addCustomer(String name) {
-		System.out.println("Adding customer: " + name);
+		logger.debug("Adding customer: " + name);
 		try {
-			utx.begin();
-			System.out.println("Creating customer");
-			simpleEJB.createCustomer(name);
-			utx.commit();
-			System.out.println("Created customer");
+			userTransaction.begin();
+			logger.debug("Creating customer");
+			customerManagerEJB.createCustomer(name);
+			userTransaction.commit();
+			logger.debug("Created customer");
 			return "customerAdded";
 		} catch (Exception e) {
-			e.printStackTrace();
+			logger.debug("Caught a duplicate", e);
 			// Transaction will be marked rollback only anyway utx.rollback();
 			return "customerDuplicate";
 		}
 	}
 
 	public int getCustomerCount() throws Exception {
-		System.out.println("Getting count");
-		int count = simpleEJB.getCustomerCount();
+		logger.debug("Getting count");
+		int count = customerManagerEJB.getCustomerCount();
 		return count;
 	}
 }

Modified: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/CustomerCreationCounter.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/CustomerCreationCounter.java	2011-07-11 21:10:09 UTC (rev 37254)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/CustomerCreationCounter.java	2011-07-12 12:58:03 UTC (rev 37255)
@@ -30,20 +30,32 @@
 import com.arjuna.ats.txoj.LockMode;
 import com.arjuna.ats.txoj.LockResult;
 
+/**
+ * This is an Transactional Object for Java. It behaves like a transaction aware
+ * resource. This particular variation of a TXOJ is not persistent so we do not
+ * need to store the UID.
+ */
 public class CustomerCreationCounter extends LockManager {
 
+	/**
+	 * This is the transactional state of the object.
+	 */
 	private int state;
 
+	/**
+	 * Create the counter.
+	 */
 	public CustomerCreationCounter() {
 		super(ObjectType.RECOVERABLE);
-
 		state = 0;
-
-		// if (!(setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED)) {
-		// throw new Exception("setlock error.");
-		// }
 	}
 
+	/**
+	 * Increment the counter.
+	 * 
+	 * @param value
+	 * @throws Exception
+	 */
 	public void incr(int value) throws Exception {
 		if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED) {
 			state += value;
@@ -52,6 +64,12 @@
 		}
 	}
 
+	/**
+	 * Get the current count of customers
+	 * 
+	 * @return
+	 * @throws Exception
+	 */
 	public int get() throws Exception {
 		if (setlock(new Lock(LockMode.READ), 0) == LockResult.GRANTED) {
 			return state;
@@ -60,6 +78,9 @@
 		}
 	}
 
+	/**
+	 * TXOJ classes must override save_state in order to save their state.
+	 */
 	public boolean save_state(OutputObjectState os, int ot) {
 		boolean result = super.save_state(os, ot);
 
@@ -75,6 +96,10 @@
 		return result;
 	}
 
+	/**
+	 * TXOJ classes must override restore_state in order to have their state
+	 * recovered by transactions.
+	 */
 	public boolean restore_state(InputObjectState os, int ot) {
 		boolean result = super.restore_state(os, ot);
 
@@ -90,7 +115,11 @@
 		return result;
 	}
 
+	/**
+	 * TXOJ classes must override the type method to partition them from other
+	 * classes of <code>LockManager</code>.
+	 */
 	public String type() {
-		return "/StateManager/LockManager/" + this.getClass().getName();
+		return super.type() + this.getClass().getName();
 	}
 }

Modified: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/test/java/TestManagedBeanCustomerManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/test/java/TestManagedBeanCustomerManager.java	2011-07-11 21:10:09 UTC (rev 37254)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/test/java/TestManagedBeanCustomerManager.java	2011-07-12 12:58:03 UTC (rev 37255)
@@ -49,8 +49,8 @@
 	public static WebArchive createDeployment() {
 		WebArchive archive = ShrinkWrap
 				.create(WebArchive.class, "test.war")
-				.addClasses(CustomerManagerEJB.class, CustomerManagerEJBImpl.class,
-						Customer.class)
+				.addClasses(CustomerManagerEJB.class,
+						CustomerManagerEJBImpl.class, Customer.class)
 				.addClasses(CustomerCreationCounter.class)
 				.addClasses(CustomerManager.class,
 						CustomerManagerManagedBean.class)



More information about the jboss-svn-commits mailing list