[jboss-svn-commits] JBL Code SVN: r37252 - in labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src: main/java/org/jboss/narayana/quickstarts/jsf and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jul 7 10:55:19 EDT 2011
Author: tomjenkinson
Date: 2011-07-07 10:55:19 -0400 (Thu, 07 Jul 2011)
New Revision: 37252
Added:
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/CustomerManagerManagedBean.java
labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/CustomerCreationCounter.java
Removed:
labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/SimpleEJB.java
labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/SimpleEJBImpl.java
labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/ManagedBeanCustomerManager.java
labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/AtomicObject.java
Modified:
labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/test/java/TestManagedBeanCustomerManager.java
Log:
JBTM-854 updated to rename the classes to be more descriptive
Copied: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJB.java (from rev 37251, labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/SimpleEJB.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJB.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJB.java 2011-07-07 14:55:19 UTC (rev 37252)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * 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) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.narayana.quickstarts.ejb;
+
+import java.util.List;
+
+import javax.naming.NamingException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+/**
+ * A simple example to show some transactional business logic.
+ */
+public interface CustomerManagerEJB {
+ /**
+ * The business logic.
+ *
+ * @return
+ * @throws NamingException
+ * @throws Exception
+ */
+ public int createCustomer(String name) throws NamingException, Exception;
+
+ public List<Customer> listCustomers() throws NamingException,
+ NotSupportedException, SystemException, SecurityException,
+ IllegalStateException, RollbackException, HeuristicMixedException,
+ HeuristicRollbackException;
+
+ public int getCustomerCount() throws Exception;
+}
Copied: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJBImpl.java (from rev 37251, labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/SimpleEJBImpl.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJBImpl.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/CustomerManagerEJBImpl.java 2011-07-07 14:55:19 UTC (rev 37252)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * 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) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.narayana.quickstarts.ejb;
+
+import java.util.List;
+
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import org.jboss.narayana.quickstarts.txoj.CustomerCreationCounter;
+
+ at Stateless
+public class CustomerManagerEJBImpl implements CustomerManagerEJB {
+
+ private CustomerCreationCounter atomicObject = new CustomerCreationCounter();
+
+ @PersistenceContext(name = "my_persistence_ctx")
+ EntityManager em;
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ public int createCustomer(String name) throws Exception {
+ System.out.println("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);
+
+ Customer c1 = new Customer();
+ c1.setName(name);
+ em.persist(c1);
+
+ return c1.getId();
+ }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ @SuppressWarnings("unchecked")
+ public List<Customer> listCustomers() throws NamingException,
+ NotSupportedException, SystemException, SecurityException,
+ IllegalStateException, RollbackException, HeuristicMixedException,
+ HeuristicRollbackException {
+ System.out.println("listCustomers transaction is identified as: "
+ + new InitialContext().lookup("java:comp/UserTransaction")
+ .toString());
+ return em.createQuery("select c from Customer c").getResultList();
+ }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ public int getCustomerCount() throws Exception {
+ System.out.println("getCustomerCount transaction is identified as: "
+ + new InitialContext().lookup("java:comp/UserTransaction")
+ .toString());
+ return atomicObject.get();
+ }
+}
Deleted: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/SimpleEJB.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/SimpleEJB.java 2011-07-07 10:35:59 UTC (rev 37251)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/SimpleEJB.java 2011-07-07 14:55:19 UTC (rev 37252)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates,
- * 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) 2011,
- * @author JBoss, by Red Hat.
- */
-package org.jboss.narayana.quickstarts.ejb;
-
-import java.util.List;
-
-import javax.naming.NamingException;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-
-/**
- * A simple example to show some transactional business logic.
- */
-public interface SimpleEJB {
- /**
- * The business logic.
- *
- * @return
- * @throws NamingException
- * @throws Exception
- */
- public int createCustomer(String name) throws NamingException, Exception;
-
- public List<Customer> listCustomers() throws NamingException,
- NotSupportedException, SystemException, SecurityException,
- IllegalStateException, RollbackException, HeuristicMixedException,
- HeuristicRollbackException;
-
- public int getCustomerCount() throws Exception;
-}
Deleted: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/SimpleEJBImpl.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/SimpleEJBImpl.java 2011-07-07 10:35:59 UTC (rev 37251)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/ejb/SimpleEJBImpl.java 2011-07-07 14:55:19 UTC (rev 37252)
@@ -1,84 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates,
- * 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) 2011,
- * @author JBoss, by Red Hat.
- */
-package org.jboss.narayana.quickstarts.ejb;
-
-import java.util.List;
-
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-
-import org.jboss.narayana.quickstarts.txoj.AtomicObject;
-
- at Stateless
-public class SimpleEJBImpl implements SimpleEJB {
-
- private AtomicObject atomicObject = new AtomicObject();
-
- @PersistenceContext(name = "my_persistence_ctx")
- EntityManager em;
-
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
- public int createCustomer(String name) throws Exception {
- System.out.println("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);
-
- Customer c1 = new Customer();
- c1.setName(name);
- em.persist(c1);
-
- return c1.getId();
- }
-
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
- @SuppressWarnings("unchecked")
- public List<Customer> listCustomers() throws NamingException,
- NotSupportedException, SystemException, SecurityException,
- IllegalStateException, RollbackException, HeuristicMixedException,
- HeuristicRollbackException {
- System.out.println("listCustomers transaction is identified as: "
- + new InitialContext().lookup("java:comp/UserTransaction")
- .toString());
- return em.createQuery("select c from Customer c").getResultList();
- }
-
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
- public int getCustomerCount() throws Exception {
- System.out.println("getCustomerCount transaction is identified as: "
- + new InitialContext().lookup("java:comp/UserTransaction")
- .toString());
- return atomicObject.get();
- }
-}
Copied: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/CustomerManagerManagedBean.java (from rev 37251, labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/ManagedBeanCustomerManager.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/CustomerManagerManagedBean.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/CustomerManagerManagedBean.java 2011-07-07 14:55:19 UTC (rev 37252)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * 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) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.narayana.quickstarts.jsf;
+
+import java.util.List;
+
+import javax.ejb.EJB;
+import javax.faces.bean.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.NamingException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
+import org.jboss.narayana.quickstarts.ejb.Customer;
+import org.jboss.narayana.quickstarts.ejb.CustomerManagerEJB;
+
+ at Named("customerManager")
+ at RequestScoped
+public class CustomerManagerManagedBean implements CustomerManager {
+
+ @EJB
+ private CustomerManagerEJB simpleEJB;
+
+ @Inject
+ private UserTransaction utx;
+
+ public List<Customer> getCustomers() throws SecurityException,
+ IllegalStateException, NamingException, NotSupportedException,
+ SystemException, RollbackException, HeuristicMixedException,
+ HeuristicRollbackException {
+ System.out.println("Getting customers");
+ return simpleEJB.listCustomers();
+ }
+
+ public String addCustomer(String name) {
+ System.out.println("Adding customer: " + name);
+ try {
+ utx.begin();
+ System.out.println("Creating customer");
+ simpleEJB.createCustomer(name);
+ utx.commit();
+ System.out.println("Created customer");
+ return "customerAdded";
+ } catch (Exception e) {
+ e.printStackTrace();
+ // 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();
+ return count;
+ }
+}
Deleted: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/ManagedBeanCustomerManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/ManagedBeanCustomerManager.java 2011-07-07 10:35:59 UTC (rev 37251)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/jsf/ManagedBeanCustomerManager.java 2011-07-07 14:55:19 UTC (rev 37252)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates,
- * 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) 2011,
- * @author JBoss, by Red Hat.
- */
-package org.jboss.narayana.quickstarts.jsf;
-
-import java.util.List;
-
-import javax.ejb.EJB;
-import javax.faces.bean.RequestScoped;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.NamingException;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.UserTransaction;
-
-import org.jboss.narayana.quickstarts.ejb.Customer;
-import org.jboss.narayana.quickstarts.ejb.SimpleEJB;
-
- at Named("customerManager")
- at RequestScoped
-public class ManagedBeanCustomerManager implements CustomerManager {
-
- @EJB
- private SimpleEJB simpleEJB;
-
- @Inject
- private UserTransaction utx;
-
- public List<Customer> getCustomers() throws SecurityException,
- IllegalStateException, NamingException, NotSupportedException,
- SystemException, RollbackException, HeuristicMixedException,
- HeuristicRollbackException {
- System.out.println("Getting customers");
- return simpleEJB.listCustomers();
- }
-
- public String addCustomer(String name) {
- System.out.println("Adding customer: " + name);
- try {
- utx.begin();
- System.out.println("Creating customer");
- simpleEJB.createCustomer(name);
- utx.commit();
- System.out.println("Created customer");
- return "customerAdded";
- } catch (Exception e) {
- e.printStackTrace();
- // 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();
- return count;
- }
-}
Deleted: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/AtomicObject.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/AtomicObject.java 2011-07-07 10:35:59 UTC (rev 37251)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/AtomicObject.java 2011-07-07 14:55:19 UTC (rev 37252)
@@ -1,214 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates,
- * 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) 2011,
- * @author JBoss, by Red Hat.
- */
-package org.jboss.narayana.quickstarts.txoj;
-
-import java.io.IOException;
-
-import com.arjuna.ats.arjuna.AtomicAction;
-import com.arjuna.ats.arjuna.ObjectModel;
-import com.arjuna.ats.arjuna.ObjectType;
-import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.arjuna.coordinator.ActionStatus;
-import com.arjuna.ats.arjuna.state.InputObjectState;
-import com.arjuna.ats.arjuna.state.OutputObjectState;
-import com.arjuna.ats.txoj.Lock;
-import com.arjuna.ats.txoj.LockManager;
-import com.arjuna.ats.txoj.LockMode;
-import com.arjuna.ats.txoj.LockResult;
-
-public class AtomicObject extends LockManager {
-
- private int state;
-
- private boolean printDebug;
- private int retry = 0;
-
- public AtomicObject() {
- this(ObjectModel.SINGLE);
- System.out.println("Creating new atomic object");
- }
-
- public AtomicObject(int om) {
- super(ObjectType.ANDPERSISTENT, om);
-
- state = 0;
-
- AtomicAction A = new AtomicAction();
-
- A.begin();
-
- if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED) {
- if (A.commit() == ActionStatus.COMMITTED)
- System.out.println("Created persistent object " + get_uid());
- else
- System.out.println("Action.commit error.");
- } else {
- A.abort();
-
- System.out.println("setlock error.");
- }
-
- String debug = System.getProperty("DEBUG", null);
-
- if (debug != null)
- printDebug = true;
- }
-
- public AtomicObject(Uid u) {
- this(u, ObjectModel.SINGLE);
- }
-
- public AtomicObject(Uid u, int om) {
- super(u, ObjectType.ANDPERSISTENT, om);
-
- state = -1;
-
- AtomicAction A = new AtomicAction();
-
- A.begin();
-
- if (setlock(new Lock(LockMode.READ), 0) == LockResult.GRANTED) {
- System.out.println("Recreated object " + u);
- A.commit();
- } else {
- System.out.println("Error recreating object " + u);
- A.abort();
- }
-
- String debug = System.getProperty("DEBUG", null);
-
- if (debug != null)
- printDebug = true;
- }
-
- public int getRetry() {
- return retry;
- }
-
- public void setRetry(int t) {
- retry = t;
- }
-
- public void terminate() {
- super.terminate();
- }
-
- public void incr(int value) throws Exception {
- AtomicAction A = new AtomicAction();
-
- A.begin();
-
- if (setlock(new Lock(LockMode.WRITE), retry) == LockResult.GRANTED) {
- state += value;
-
- if (A.commit() != ActionStatus.COMMITTED)
- throw new Exception("Action commit error.");
- else
- return;
- } else {
- if (printDebug)
- System.out.println("Error - could not set write lock.");
- }
-
- A.abort();
-
- throw new Exception("Write lock error.");
- }
-
- public void set(int value) throws Exception {
- AtomicAction A = new AtomicAction();
-
- A.begin();
-
- if (setlock(new Lock(LockMode.WRITE), retry) == LockResult.GRANTED) {
- state = value;
-
- if (A.commit() != ActionStatus.COMMITTED)
- throw new Exception("Action commit error.");
- else
- return;
- } else {
- if (printDebug)
- System.out.println("Error - could not set write lock.");
- }
-
- A.abort();
-
- throw new Exception("Write lock error.");
- }
-
- public int get() throws Exception {
- AtomicAction A = new AtomicAction();
- int value = -1;
-
- A.begin();
-
- if (setlock(new Lock(LockMode.READ), retry) == LockResult.GRANTED) {
- value = state;
-
- if (A.commit() == ActionStatus.COMMITTED)
- return value;
- else
- throw new Exception("Action commit error.");
- } else {
- if (printDebug)
- System.out.println("Error - could not set read lock.");
- }
-
- A.abort();
-
- throw new Exception("Read lock error.");
- }
-
- public boolean save_state(OutputObjectState os, int ot) {
- boolean result = super.save_state(os, ot);
-
- if (!result)
- return false;
-
- try {
- os.packInt(state);
- } catch (IOException e) {
- result = false;
- }
-
- return result;
- }
-
- public boolean restore_state(InputObjectState os, int ot) {
- boolean result = super.restore_state(os, ot);
-
- if (!result)
- return false;
-
- try {
- state = os.unpackInt();
- } catch (IOException e) {
- result = false;
- }
-
- return result;
- }
-
- public String type() {
- return "/StateManager/LockManager/AtomicObject";
- }
-}
Copied: labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/CustomerCreationCounter.java (from rev 37251, labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/AtomicObject.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/CustomerCreationCounter.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/main/java/org/jboss/narayana/quickstarts/txoj/CustomerCreationCounter.java 2011-07-07 14:55:19 UTC (rev 37252)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * 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) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.narayana.quickstarts.txoj;
+
+import java.io.IOException;
+
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.txoj.Lock;
+import com.arjuna.ats.txoj.LockManager;
+import com.arjuna.ats.txoj.LockMode;
+import com.arjuna.ats.txoj.LockResult;
+
+public class CustomerCreationCounter extends LockManager {
+
+ private int state;
+
+ public CustomerCreationCounter() {
+ super(ObjectType.RECOVERABLE);
+
+ state = 0;
+
+ // if (!(setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED)) {
+ // throw new Exception("setlock error.");
+ // }
+ }
+
+ public void incr(int value) throws Exception {
+ if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED) {
+ state += value;
+ } else {
+ throw new Exception("Error - could not set write lock.");
+ }
+ }
+
+ public int get() throws Exception {
+ if (setlock(new Lock(LockMode.READ), 0) == LockResult.GRANTED) {
+ return state;
+ } else {
+ throw new Exception("Error - could not set read lock.");
+ }
+ }
+
+ public boolean save_state(OutputObjectState os, int ot) {
+ boolean result = super.save_state(os, ot);
+
+ if (!result)
+ return false;
+
+ try {
+ os.packInt(state);
+ } catch (IOException e) {
+ result = false;
+ }
+
+ return result;
+ }
+
+ public boolean restore_state(InputObjectState os, int ot) {
+ boolean result = super.restore_state(os, ot);
+
+ if (!result)
+ return false;
+
+ try {
+ state = os.unpackInt();
+ } catch (IOException e) {
+ result = false;
+ }
+
+ return result;
+ }
+
+ public String type() {
+ return "/StateManager/LockManager/" + 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-07 10:35:59 UTC (rev 37251)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/jee_transactional_app/src/test/java/TestManagedBeanCustomerManager.java 2011-07-07 14:55:19 UTC (rev 37252)
@@ -27,11 +27,11 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.narayana.quickstarts.ejb.Customer;
-import org.jboss.narayana.quickstarts.ejb.SimpleEJB;
-import org.jboss.narayana.quickstarts.ejb.SimpleEJBImpl;
+import org.jboss.narayana.quickstarts.ejb.CustomerManagerEJB;
+import org.jboss.narayana.quickstarts.ejb.CustomerManagerEJBImpl;
import org.jboss.narayana.quickstarts.jsf.CustomerManager;
-import org.jboss.narayana.quickstarts.jsf.ManagedBeanCustomerManager;
-import org.jboss.narayana.quickstarts.txoj.AtomicObject;
+import org.jboss.narayana.quickstarts.jsf.CustomerManagerManagedBean;
+import org.jboss.narayana.quickstarts.txoj.CustomerCreationCounter;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
@@ -43,17 +43,17 @@
@RunWith(Arquillian.class)
public class TestManagedBeanCustomerManager {
@Inject
- private ManagedBeanCustomerManager managedBeanCustomerManager;
+ private CustomerManagerManagedBean managedBeanCustomerManager;
@Deployment
public static WebArchive createDeployment() {
WebArchive archive = ShrinkWrap
.create(WebArchive.class, "test.war")
- .addClasses(SimpleEJB.class, SimpleEJBImpl.class,
+ .addClasses(CustomerManagerEJB.class, CustomerManagerEJBImpl.class,
Customer.class)
- .addClasses(AtomicObject.class)
+ .addClasses(CustomerCreationCounter.class)
.addClasses(CustomerManager.class,
- ManagedBeanCustomerManager.class)
+ CustomerManagerManagedBean.class)
.addAsResource("META-INF/persistence.xml",
"META-INF/persistence.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
More information about the jboss-svn-commits
mailing list