[jboss-svn-commits] JBL Code SVN: r9939 - labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Mar 3 16:10:12 EST 2007
Author: daniel.brum at jboss.com
Date: 2007-03-03 16:10:12 -0500 (Sat, 03 Mar 2007)
New Revision: 9939
Removed:
labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManager.java
labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManagerDBCP.java
Modified:
labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java
Log:
support for multiple connection pool managers
Deleted: labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManager.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManager.java 2007-03-03 21:09:54 UTC (rev 9938)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManager.java 2007-03-03 21:10:12 UTC (rev 9939)
@@ -1,136 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * 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) 2005-2006,
- * @author daniel.brum at jboss.com
- */
-
-package org.jboss.internal.soa.esb.persistence.format.db;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.common.Configuration;
-
-import com.mchange.v2.c3p0.ComboPooledDataSource;
-
-public class DBConnectionManager
-{
-
- private static DBConnectionManager instance = null;
-
- protected ComboPooledDataSource pooledDS = null;
-
- private static final Object foo = new Integer(0);
-
- private static Logger _logger = Logger.getLogger(DBConnectionManager.class);
-
- protected DBConnectionManager ()
- {
- }
-
- public static DBConnectionManager getInstance ()
- {
- if (null != instance)
- {
- return instance;
- }
-
- synchronized (foo)
- {
- if (null != instance)
- return instance;
-
- try
- {
- instance = new DBConnectionManager();
- instance.init();
- }
- catch (Exception e)
- {
- _logger.error("Could not initialise instance.", e);
-
- return null;
- }
-
- return instance;
- }
- }
-
- private void init () throws ConfigurationException
- {
- _logger.info("Initializing DBConnectionManager");
- pooledDS = new ComboPooledDataSource();
-
- try
- {
- pooledDS.setDriverClass(Configuration.getStoreDriver());
- pooledDS.setJdbcUrl(Configuration.getStoreUrl());
- pooledDS.setUser(Configuration.getStoreUser());
- pooledDS.setPassword(Configuration.getStorePwd());
- pooledDS.setMinPoolSize(Integer.valueOf(Configuration
- .getStorePoolMinSize()));
- pooledDS.setInitialPoolSize(Integer.valueOf(Configuration
- .getStorePoolInitialSize()));
- pooledDS.setMaxPoolSize(Integer.valueOf(Configuration
- .getStorePoolMaxSize()));
- pooledDS.setAutomaticTestTable(Configuration.getStorePoolTestTable());
- pooledDS.setCheckoutTimeout(Integer.valueOf(Configuration
- .getStorePoolTimeoutMillis()));
- }
- catch (Exception ex)
- {
- throw new ConfigurationException(ex);
- }
- }
-
- public Connection getConnection () throws SQLException
- {
- Connection conn = null;
-
- // TODO: figure out why this is neccessary - pool should never return
- // null if DB is up and can connect
- // testing showed null was being returned from pool in QA test
- // MessageStoreTest
-
- while (true)
- {
- if (null != pooledDS)
- {
- if (null != (conn = pooledDS.getConnection()))
- break;
- else
- _logger.error("Null pooledDS");
- }
-
- try
- {
- // TODO magic number
-
- Thread.sleep(1000);
- }
- catch (Exception e)
- {
- }
- }
-
- return conn;
- }
-
-}
Deleted: labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManagerDBCP.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManagerDBCP.java 2007-03-03 21:09:54 UTC (rev 9938)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBConnectionManagerDBCP.java 2007-03-03 21:10:12 UTC (rev 9939)
@@ -1,119 +0,0 @@
-//THIS CLASS IS NOT USED RIGHT NOW
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * 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) 2005-2006,
- * @author daniel.brum at jboss.com
- */
-
-package org.jboss.internal.soa.esb.persistence.format.db;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import org.apache.commons.dbcp.ConnectionFactory;
-import org.apache.commons.dbcp.DriverManagerConnectionFactory;
-import org.apache.commons.dbcp.PoolableConnectionFactory;
-import org.apache.commons.dbcp.PoolingDataSource;
-import org.apache.commons.pool.ObjectPool;
-import org.apache.commons.pool.impl.GenericObjectPool;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.common.Configuration;
-
-/*
- * the DBConnectionManager class (singleton) is used by classes implenting the
- * MessageStore interface to obtain a connection to the persistence store
- * database. This class uses the Apache Commons DB Connection Pooling to handle
- * all aspects of managing the connections in a pool. $author Daniel Brum
- */
-
-public class DBConnectionManagerDBCP
-{
-
- private static DBConnectionManagerDBCP instance = null;
-
- private PoolingDataSource dataSource = null;
-
- protected DBConnectionManagerDBCP ()
- {
- }
-
- public static DBConnectionManagerDBCP getInstance ()
- {
- if (null == instance)
- {
- try
- {
- instance = new DBConnectionManagerDBCP();
- instance.init();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- return null;
- }
- }
- return instance;
- }
-
- private void init () throws ConfigurationException
- {
- try
- {
- String connectURL = Configuration.getStoreUrl();
- Class.forName(Configuration.getStoreDriver());
-
- ObjectPool connectionPool = new GenericObjectPool(null);
-
- ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(
- connectURL, Configuration.getStoreUser(), Configuration
- .getStorePwd());
-
- @SuppressWarnings("unused")
- PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
- connectionFactory, connectionPool, null, null, false, false);
-
- int poolSize = Integer.valueOf(Configuration.getStorePoolInitialSize());
-
- // add the max # of connections into the pool
- for (int i = 0; i < poolSize; i++)
- {
- try
- {
- connectionPool.addObject();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- dataSource = new PoolingDataSource(connectionPool);
- }
- catch (ClassNotFoundException ex)
- {
- throw new ConfigurationException(ex);
- }
- }
-
- public Connection getConnection () throws SQLException
- {
- return dataSource.getConnection();
- }
-
-}
Modified: labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java 2007-03-03 21:09:54 UTC (rev 9938)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java 2007-03-03 21:10:12 UTC (rev 9939)
@@ -29,8 +29,11 @@
import java.sql.SQLException;
import java.util.UUID;
+import org.jboss.internal.soa.esb.persistence.manager.ConnectionManager;
import org.jboss.internal.soa.esb.thirdparty.Base64;
import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.persistence.manager.ConnectionManagerException;
+import org.jboss.soa.esb.persistence.manager.ConnectionManagerFactory;
import org.jboss.soa.esb.services.persistence.MessageStore;
import org.jboss.soa.esb.services.persistence.MessageStoreException;
import org.jboss.soa.esb.util.Util;
@@ -38,7 +41,7 @@
public class DBMessageStoreImpl implements MessageStore
{
- protected DBConnectionManager mgr = null;
+ protected ConnectionManager mgr = null;
protected Connection conn = null;
@@ -46,9 +49,15 @@
protected PreparedStatement ps = null;
- public DBMessageStoreImpl ()
+ public DBMessageStoreImpl()
{
- mgr = DBConnectionManager.getInstance();
+ try {
+ mgr = ConnectionManagerFactory.getConnectionManager();
+ } catch (ConnectionManagerException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
}
public synchronized URI addMessage (Message message) throws MessageStoreException
More information about the jboss-svn-commits
mailing list