[jboss-svn-commits] JBL Code SVN: r31828 - in labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task: pooling and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Feb 24 10:05:15 EST 2010


Author: whitingjr
Date: 2010-02-24 10:05:14 -0500 (Wed, 24 Feb 2010)
New Revision: 31828

Added:
   labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/
   labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/ConnectionHandler.java
   labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/PooledConnectionHandler.java
   labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/RawConnection.java
Log:
Added connection handling classes.

Added: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/ConnectionHandler.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/ConnectionHandler.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/ConnectionHandler.java	2010-02-24 15:05:14 UTC (rev 31828)
@@ -0,0 +1,32 @@
+ /*
+  * 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.task.pooling;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public interface ConnectionHandler
+{
+   public Connection getConnectionA() throws SQLException;
+   public Connection getConnectionB() throws SQLException;
+}

Added: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/PooledConnectionHandler.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/PooledConnectionHandler.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/PooledConnectionHandler.java	2010-02-24 15:05:14 UTC (rev 31828)
@@ -0,0 +1,55 @@
+ /*
+  * 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.task.pooling;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+public class PooledConnectionHandler implements ConnectionHandler
+{
+   private final DataSource dataSourceA;
+   private final DataSource dataSourceB;
+   
+   public PooledConnectionHandler(DataSource resA, DataSource resB)
+   {
+      this.dataSourceA = resA;
+      this.dataSourceB = resB;
+   }
+   
+   @Override
+   public Connection getConnectionA()
+      throws SQLException
+   {
+      return this.dataSourceA.getConnection();
+   }
+
+   @Override
+   public Connection getConnectionB()
+   throws SQLException
+   {
+      return this.dataSourceB.getConnection();
+   }
+
+}

Added: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/RawConnection.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/RawConnection.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/task/pooling/RawConnection.java	2010-02-24 15:05:14 UTC (rev 31828)
@@ -0,0 +1,71 @@
+ /*
+  * 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.task.pooling;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+/**
+ * This object provides Connection objects using lazy loading. This 
+ * is necessary to ensure the Connection objects are loaded in
+ * separate threads just before demand.
+ * 
+ * @author <a href="jwhiting at redhat.com">Jeremy Whiting</a>
+ * @version $Revision: 1.1 $
+ */
+public class RawConnection implements ConnectionHandler
+{
+   private final DataSource resA;
+   private final DataSource resB;
+   private Connection connectionA;
+   private Connection connectionB;
+   
+   public RawConnection(final DataSource dataSourceA, final DataSource dataSourceB)
+   {
+      this.resA = dataSourceA;
+      this.resB = dataSourceB;
+   }
+   
+   @Override
+   public Connection getConnectionA() throws SQLException
+   {
+      if (null == connectionA)
+      {
+         this.connectionA = resA.getConnection();
+      }
+      return this.connectionA;
+   }
+
+   @Override
+   public Connection getConnectionB() throws SQLException
+   {
+      if (null == connectionB)
+      {
+         this.connectionB = this.resB.getConnection();
+      }
+      return this.connectionB;
+   }
+
+}



More information about the jboss-svn-commits mailing list