[jboss-svn-commits] JBL Code SVN: r31508 - in labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance: synchronization and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Feb 9 06:32:40 EST 2010
Author: whitingjr
Date: 2010-02-09 06:32:40 -0500 (Tue, 09 Feb 2010)
New Revision: 31508
Added:
labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/synchronization/
labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/synchronization/SessionSynchronization.java
Log:
Added synch class.
Added: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/synchronization/SessionSynchronization.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/synchronization/SessionSynchronization.java (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/synchronization/SessionSynchronization.java 2010-02-09 11:32:40 UTC (rev 31508)
@@ -0,0 +1,66 @@
+ /*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jbossts.performance.synchronization;
+
+import javax.persistence.EntityManager;
+import javax.transaction.Synchronization;
+
+import org.apache.log4j.Logger;
+import org.hibernate.Transaction;
+
+/**
+ *
+ * A SessionSynchronization object to flush the persistence context associated
+ * with a transaction.
+ *
+ * @author <a href="jwhiting at redhat.com">Jeremy Whiting</a>
+ * @version $Revision: 1.1 $
+ */
+public class SessionSynchronization implements Synchronization
+{
+ private final Logger logger = Logger.getLogger(SessionSynchronization.class);
+ private EntityManager manager;
+ private boolean closeAtTxCompletion;
+
+ public SessionSynchronization(EntityManager session, Transaction tx, boolean close)
+ {
+ this.manager = session;
+ closeAtTxCompletion = close;
+ }
+
+ public void beforeCompletion()
+ {
+ /* This implementation assumes everything is ok and various statuses do no not need checking.*/
+ this.manager.flush();
+ }
+
+ public void afterCompletion(int status)
+ {
+ if (closeAtTxCompletion)
+ {
+ logger.debug("************** closing entity managersession **************");
+ manager.close();
+ }
+ }
+
+}
More information about the jboss-svn-commits
mailing list