[jboss-svn-commits] JBL Code SVN: r5386 - in labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb: . connection connection/exception

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Aug 1 16:29:00 EDT 2006


Author: mohit309
Date: 2006-08-01 16:28:58 -0400 (Tue, 01 Aug 2006)
New Revision: 5386

Added:
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/AbandonedConnectionTimerTask.java
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionFactory.java
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionPool.java
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionPoolFactory.java
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionProperties.java
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionWrapper.java
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/DefaultConnectionPoolImpl.java
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/DriverConnectionFactory.java
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/FreeConnectionPoolResources.java
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/PasswordDecoder.java
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/PoolDataSource.java
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/exception/
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/exception/ESBConnectionException.java
Log:
Connection Pool Implementation. Added logic for abandoned connection

Added: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/AbandonedConnectionTimerTask.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/AbandonedConnectionTimerTask.java	2006-08-01 19:50:06 UTC (rev 5385)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/AbandonedConnectionTimerTask.java	2006-08-01 20:28:58 UTC (rev 5386)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.soa.esb.connection;
+
+import java.util.TimerTask;
+
+/**
+ * Timer task which will run at scheduled times based on the property set by the user.
+ * This task will remove all unused connections which have elapsed a certain period of time
+ * User: MohitK
+ * Date: Jul 26, 2006
+ */
+public class AbandonedConnectionTimerTask extends TimerTask {
+
+    private DefaultConnectionPoolImpl m_oPool;
+
+    /**
+     * Constructor which takes the pool implementation
+     * @param pool
+     */
+    public AbandonedConnectionTimerTask(DefaultConnectionPoolImpl pool){
+        this.m_oPool = pool;
+    }
+
+    public void run() {
+        synchronized(m_oPool){
+            m_oPool.releaseAbandonedConnections();
+        }
+    }
+
+}

Added: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionFactory.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionFactory.java	2006-08-01 19:50:06 UTC (rev 5385)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionFactory.java	2006-08-01 20:28:58 UTC (rev 5386)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.soa.esb.connection;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Factory interface for creating connections based on different sources such as DataSource, DriverConnection
+ * User: MohitK
+ * Date: Jul 18, 2006
+ */
+public interface ConnectionFactory {
+    /**
+     * Creates a new JDBC Connection. The implementation is left to the classes.
+     * @return Connection
+     * @throws SQLException
+     */
+    public Connection createConnection() throws SQLException;
+}

Added: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionPool.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionPool.java	2006-08-01 19:50:06 UTC (rev 5385)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionPool.java	2006-08-01 20:28:58 UTC (rev 5386)
@@ -0,0 +1,62 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.soa.esb.connection;
+
+import org.jboss.soa.esb.connection.exception.ESBConnectionException;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * TODO
+ * User: MohitK
+ * Date: Jul 18, 2006
+ */
+public interface ConnectionPool {
+    /**
+     * This method is used to create the connection pool and keep it ready
+     * @param prop Properties for the connection pool including connection properties
+     * @throws ESBConnectionException
+     */
+    public void createPool(ConnectionProperties prop) throws ESBConnectionException;
+
+    /**
+     *  This method is called whenever a connection is needed from the pool.
+     * @return Connection to be used
+     * @throws SQLException
+     */
+    public Connection getConnection() throws SQLException;
+
+    /**
+     * This method closes an open connection and returns the connection to the pool.
+     * @param connectionToClose The connection to be returned to the pool.
+     * @throws SQLException
+     */
+    public void closeConnection(Connection connectionToClose) throws SQLException;
+
+    /**
+     * This method is called when the pool needs to be destroyed effectively closing all open connections
+     * @throws SQLException
+     */
+    public void releasePool() throws SQLException;
+
+}

Added: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionPoolFactory.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionPoolFactory.java	2006-08-01 19:50:06 UTC (rev 5385)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionPoolFactory.java	2006-08-01 20:28:58 UTC (rev 5386)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.soa.esb.connection;
+
+import org.jboss.soa.esb.connection.exception.ESBConnectionException;
+
+/**
+ * Factory class to create the connection pool.
+ * User: MohitK
+ * Date: Jul 19, 2006
+ */
+public class ConnectionPoolFactory {
+
+    /**
+     * Factory method to create and return a connection pool based on the property set for the connection pool
+     * implementation. The factory also registers a shut down hook with the JVM so that the connections in the pool
+     * are closed and released with causing connections leaks.
+     * @param connProperties Properties for the connection pool
+     * @return Connection Pool
+     * @throws ESBConnectionException
+     */
+    public static ConnectionPool createPool(ConnectionProperties connProperties) throws ESBConnectionException {
+        String connectionPoolClassName = connProperties.getConnectionPoolClass();
+        try {
+            ConnectionPool pool = (ConnectionPool)Class.forName(connectionPoolClassName).newInstance();
+            pool.createPool(connProperties);
+            FreeConnectionPoolResources freeResourcesThread = new FreeConnectionPoolResources(pool);
+            Runtime.getRuntime().addShutdownHook(freeResourcesThread);
+            return pool;
+        } catch (Throwable t) {
+            System.err.println("ConnectionPoolFactory: Error in Connection Pool");
+            System.err.println(t);
+            throw new ESBConnectionException(t);
+        }
+    }
+}

Added: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionProperties.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionProperties.java	2006-08-01 19:50:06 UTC (rev 5385)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionProperties.java	2006-08-01 20:28:58 UTC (rev 5386)
@@ -0,0 +1,248 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.soa.esb.connection;
+
+import java.util.Properties;
+
+/**
+ * Connection Property class which stores all connection and connection pool properties. It keeps the peroperties ready
+ * so that is can be used by the pool and connection factory
+ * User: MohitK
+ * Date: Jul 18, 2006
+ */
+public class ConnectionProperties {
+
+    private Properties _connectionProperties;
+
+    public static final String DRIVER_CLASSNAME = "driver-class";
+    public static final String CONNECTION_URL = "connection-url";
+    public static final String USERNAME = "user-name";
+    public static final String PASSWORD = "password";
+    public static final String AUTO_COMMIT = "auto-commit";
+    public static final String ISOLATION_LEVEL = "isolation";
+    public static final String MIN_POOL_SIZE = "min-pool-size";
+    public static final String MAX_POOL_SIZE = "max-pool-size";
+    public static final String BLOCKING_CONNECTION_TIME = "blocking-timeout-millis";
+    public static final String CONNECTION_POOL_CLASS = "connection-pool-class";
+    public static final String PASSWORD_DECODER = "password-decrypter";
+    public static final String ABANDONED_CONNECTION_TIMEOUT = "abandoned-connection-timeout";
+    public static final String ABANDONED_CONNECTION_CHECK_INTERVAL = "abandoned-connection-time-interval";
+
+    private boolean _autoCommit;
+    private Integer _isolationLvl;
+    private int _minPoolSize;
+    private int _maxPoolSize;
+    private long _connBlockTime;
+    private String _connectionPoolClass;
+    private String _user;
+    private String _password;
+    private String _connectionUrl;
+    private long _abandonedConnectionTimeout;
+    private long _abandonedConnectionCheckInterval;
+    private String _driverClassName;
+
+
+    public static final String DEFAULT_MIN_POOL_SIZE = "5";
+    public static final String DEFAULT_MAX_POOL_SIZE = "10";
+    public static final String DEFAULT_CONN_BLOCK_TIME_MILLIS = "5000";
+    public static final String DEFAULT_CONNECTION_POOL_CLASS = DefaultConnectionPoolImpl.class.getName();
+    public static final String DEFAULT_ABANDONED_CONNECTION_TIMEOUT = "10000";
+    public static final String DEFAULT_ABANDONED_CONNECTION_CHECK_INTERVAL = "30000";
+
+    public ConnectionProperties(Properties connectionProperties) {
+        this._connectionProperties = connectionProperties;
+        setDriverClassName();
+        setConnectionUrl();
+        setUser();
+        setPassword();
+        setConnectionPoolClass();
+        setAutoCommit();
+        setIsolationLevel();
+        setMinPoolSize();
+        setMaxPoolSize();
+        setBlockingConnectionTime();
+        setAbandonedConnectionTimeOut();
+        setAbandonedConnectionCheckInterval();
+    }
+
+    private void setDriverClassName() {
+        _driverClassName = _connectionProperties.getProperty(DRIVER_CLASSNAME);
+        if (_driverClassName == null) {
+            _driverClassName = System.getProperty(DRIVER_CLASSNAME);
+        }
+    }
+
+    protected String getDriverClassName() {
+        return _driverClassName;
+    }
+
+    protected String getConnectionUrl() {
+        return _connectionUrl;
+    }
+
+    private void setConnectionUrl() {
+        _connectionUrl = _connectionProperties.getProperty(CONNECTION_URL);
+        if (_connectionUrl == null) {
+            _connectionUrl = System.getProperty(CONNECTION_URL);
+        }
+    }
+
+    protected boolean getAutoCommit() {
+        return _autoCommit;
+    }
+
+    protected Integer getIsolationLevel() {
+        return _isolationLvl;
+    }
+
+    private void setIsolationLevel() {
+        String isolation = (String) _connectionProperties.get(ISOLATION_LEVEL);
+        if (isolation == null) {
+            isolation = System.getProperty(ISOLATION_LEVEL);
+        }
+        this._isolationLvl = (isolation != null) ? new Integer(isolation) : null;
+    }
+
+    protected int getMinPoolSize() {
+        return _minPoolSize;
+    }
+
+    protected int getMaxPoolSize() {
+        return _maxPoolSize;
+    }
+
+    private void setMinPoolSize() {
+        String strPoolSize = _connectionProperties.getProperty(MIN_POOL_SIZE);
+        if (strPoolSize == null) {
+            strPoolSize = System.getProperty(MIN_POOL_SIZE, DEFAULT_MIN_POOL_SIZE);
+            this._minPoolSize = Integer.parseInt(strPoolSize);
+        }
+    }
+
+    private void setMaxPoolSize() {
+        String strPoolSize = (String) _connectionProperties.get(MAX_POOL_SIZE);
+        if (strPoolSize == null) {
+            strPoolSize = System.getProperty(MAX_POOL_SIZE, DEFAULT_MAX_POOL_SIZE);
+            this._maxPoolSize = Integer.parseInt(strPoolSize);
+        }
+    }
+
+    private void setBlockingConnectionTime() {
+        String strBlockTimeMillis = (String) _connectionProperties.get(BLOCKING_CONNECTION_TIME);
+        if (strBlockTimeMillis == null) {
+            strBlockTimeMillis = System.getProperty(BLOCKING_CONNECTION_TIME, DEFAULT_CONN_BLOCK_TIME_MILLIS);
+            this._connBlockTime = Integer.parseInt(strBlockTimeMillis);
+        }
+    }
+
+    protected long getConnectionBlockTimeInMillis() {
+        return _connBlockTime;
+    }
+
+    private void setAutoCommit() {
+        String autoCommit = (String) _connectionProperties.get(AUTO_COMMIT);
+        if (autoCommit == null || autoCommit.equals("false")) {
+            _autoCommit = Boolean.FALSE;
+        } else {
+            _autoCommit = Boolean.TRUE;
+        }
+    }
+
+    private void setConnectionPoolClass() {
+        _connectionPoolClass = _connectionProperties.getProperty(CONNECTION_POOL_CLASS);
+        if (_connectionPoolClass == null) {
+            _connectionPoolClass = System.getProperty(CONNECTION_POOL_CLASS, DEFAULT_CONNECTION_POOL_CLASS);
+        }
+    }
+
+
+    protected String getUser() {
+        return _user;
+    }
+
+    public void setUser() {
+        this._user = _connectionProperties.getProperty(USERNAME);
+        if (_user == null) {
+            _user = System.getProperty(USERNAME);
+        }
+    }
+
+    protected String getPassword() {
+        return _password;
+    }
+
+    protected void setPassword() {
+        this._password = _connectionProperties.getProperty(PASSWORD);
+        if (_password == null) {
+            _password = System.getProperty(PASSWORD);
+        }
+        String strPasswordDecoder = _connectionProperties.getProperty(PASSWORD_DECODER);
+        if (strPasswordDecoder == null) {
+            strPasswordDecoder = System.getProperty(PASSWORD_DECODER);
+        }
+        if (strPasswordDecoder != null) {
+            try {
+                PasswordDecoder decoder = (PasswordDecoder) Class.forName(strPasswordDecoder).newInstance();
+                this._password = decoder.decode(_password);
+            } catch (InstantiationException e) {
+                System.err.println("Error in creating instance of Password Decoder Class:-" + strPasswordDecoder);
+                System.err.println(e);
+            } catch (IllegalAccessException e) {
+                System.err.println("Error in creating instance of Password Decoder Class:-" + strPasswordDecoder);
+                System.err.println(e);
+            } catch (ClassNotFoundException e) {
+                System.err.println("Password Decoder Class:-" + strPasswordDecoder + " not found in Classpath");
+                System.err.println("Please check the property:-" + PASSWORD_DECODER);
+                System.err.println(e);
+            }
+        }
+    }
+
+    protected String getConnectionPoolClass() {
+        return _connectionPoolClass;
+    }
+
+    private void setAbandonedConnectionTimeOut() {
+        String strAbandonedConnectionTimeout = _connectionProperties.getProperty(ABANDONED_CONNECTION_TIMEOUT);
+        if (strAbandonedConnectionTimeout == null) {
+            strAbandonedConnectionTimeout = System.getProperty(ABANDONED_CONNECTION_TIMEOUT, DEFAULT_ABANDONED_CONNECTION_TIMEOUT);
+        }
+        this._abandonedConnectionTimeout = Long.parseLong(strAbandonedConnectionTimeout);
+    }
+
+    private void setAbandonedConnectionCheckInterval() {
+        String strAbandonedConnectionCheckInterval = _connectionProperties.getProperty(ABANDONED_CONNECTION_CHECK_INTERVAL);
+        if (strAbandonedConnectionCheckInterval == null || strAbandonedConnectionCheckInterval.trim().length() == 0) {
+            strAbandonedConnectionCheckInterval = System.getProperty(ABANDONED_CONNECTION_CHECK_INTERVAL, DEFAULT_ABANDONED_CONNECTION_CHECK_INTERVAL);
+        }
+        this._abandonedConnectionCheckInterval = Long.parseLong(strAbandonedConnectionCheckInterval);
+    }
+
+    protected long getAbandonedConnectionTimeOut(){
+        return this._abandonedConnectionTimeout;
+    }
+
+    protected long getAbandonedConnectionCheckInterval(){
+        return this._abandonedConnectionCheckInterval;
+    }
+
+}

Added: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionWrapper.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionWrapper.java	2006-08-01 19:50:06 UTC (rev 5385)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/ConnectionWrapper.java	2006-08-01 20:28:58 UTC (rev 5386)
@@ -0,0 +1,319 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.soa.esb.connection;
+
+import java.sql.*;
+import java.util.Map;
+
+/**
+ * Wrapper class which encapsulates @link Connection
+ * User: MohitK
+ * Date: Jul 18, 2006
+ */
+public class ConnectionWrapper implements Connection {
+
+    private Connection _originalHeavyConnection;
+    private ConnectionPool _connectionPool;
+    private boolean _isClosed = false;
+    private long _activatedTime;
+
+    public ConnectionWrapper(Connection originalHeavyConnection, ConnectionPool pool) throws SQLException {
+        if (originalHeavyConnection == null) {
+            throw new SQLException("Original Connection is Null");
+        }
+        this._originalHeavyConnection = originalHeavyConnection;
+        if (pool == null) {
+            throw new SQLException("Connection Pool is null");
+        }
+        this._connectionPool = pool;
+    }
+
+    public Statement createStatement() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.createStatement();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public PreparedStatement prepareStatement(String sql) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.prepareStatement(sql);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public CallableStatement prepareCall(String sql) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.prepareCall(sql);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public String nativeSQL(String sql) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.nativeSQL(sql);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public void setAutoCommit(boolean autoCommit) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            _originalHeavyConnection.setAutoCommit(autoCommit);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+
+    }
+
+    public boolean getAutoCommit() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.getAutoCommit();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public void commit() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            _originalHeavyConnection.commit();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public void rollback() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            _originalHeavyConnection.rollback();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public synchronized void close() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            _connectionPool.closeConnection(this);
+        }
+        this._isClosed = true;
+    }
+
+    public boolean isClosed() throws SQLException {
+        return _isClosed;
+    }
+
+    public DatabaseMetaData getMetaData() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.getMetaData();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public void setReadOnly(boolean readOnly) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            _originalHeavyConnection.setReadOnly(readOnly);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public boolean isReadOnly() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.isReadOnly();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public void setCatalog(String catalog) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            _originalHeavyConnection.setCatalog(catalog);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public String getCatalog() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.getCatalog();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public void setTransactionIsolation(int level) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            _originalHeavyConnection.setTransactionIsolation(level);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public int getTransactionIsolation() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.getTransactionIsolation();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public SQLWarning getWarnings() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.getWarnings();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public void clearWarnings() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            _originalHeavyConnection.clearWarnings();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.createStatement(resultSetType, resultSetConcurrency);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.prepareStatement(sql, resultSetType, resultSetConcurrency);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.prepareCall(sql, resultSetType, resultSetConcurrency);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public Map<String, Class<?>> getTypeMap() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.getTypeMap();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            _originalHeavyConnection.setTypeMap(map);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public void setHoldability(int holdability) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            _originalHeavyConnection.setHoldability(holdability);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public int getHoldability() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.getHoldability();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public Savepoint setSavepoint() throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.setSavepoint();
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public Savepoint setSavepoint(String name) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.setSavepoint(name);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public void rollback(Savepoint savepoint) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            _originalHeavyConnection.rollback(savepoint);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            _originalHeavyConnection.releaseSavepoint(savepoint);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.prepareStatement(sql, autoGeneratedKeys);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public PreparedStatement prepareStatement(String sql, int columnIndexes[]) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.prepareStatement(sql, columnIndexes);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    public PreparedStatement prepareStatement(String sql, String columnNames[]) throws SQLException {
+        if (_originalHeavyConnection != null) {
+            return _originalHeavyConnection.prepareStatement(sql, columnNames);
+        } else
+            throw new SQLException("Connection closed due to inactivity");
+    }
+
+    protected synchronized Connection getActualConnection() {
+        return _originalHeavyConnection;
+    }
+
+    protected long getActivatedTime() {
+        return _activatedTime;
+    }
+
+    protected void setActivatedTime(long activedTime) {
+        this._activatedTime = activedTime;
+    }
+
+    protected String getName() {
+        return _originalHeavyConnection.toString();
+    }
+
+    protected void setOriginalConnection(Connection conn) {
+        this._originalHeavyConnection = conn;
+    }
+}

Added: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/DefaultConnectionPoolImpl.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/DefaultConnectionPoolImpl.java	2006-08-01 19:50:06 UTC (rev 5385)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/DefaultConnectionPoolImpl.java	2006-08-01 20:28:58 UTC (rev 5386)
@@ -0,0 +1,202 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.soa.esb.connection;
+
+import org.jboss.soa.esb.connection.exception.ESBConnectionException;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.Stack;
+import java.util.Timer;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Default connection pool implementation class when there is none specified by the user in @link ConnectionProperties
+ * User: MohitK
+ * Date: Jul 18, 2006
+ */
+public class DefaultConnectionPoolImpl implements ConnectionPool {
+
+    private final Stack<ConnectionWrapper> m_oConnectionStack = new Stack<ConnectionWrapper>();
+    private final ConcurrentHashMap<String, ConnectionWrapper> m_oUsedConnectionMap = new ConcurrentHashMap<String, ConnectionWrapper>();
+    private int m_iConnCountInPool;
+    private ConnectionProperties m_oConnProperties;
+    private ConnectionFactory _connectionFactory;
+
+    /**
+     * @see org.jboss.soa.esb.connection.ConnectionPool#createPool(ConnectionProperties)
+     *
+     */
+    public void createPool(ConnectionProperties prop) throws ESBConnectionException {
+        this.m_oConnProperties = prop;
+        try {
+            initPool();
+            AbandonedConnectionTimerTask abandonedConnTask = new AbandonedConnectionTimerTask(this);
+            Timer abandonedTimer = new Timer(":AbandonedConnectionPoolScheduler:@" + this.toString(), true);
+            abandonedTimer.schedule(abandonedConnTask, prop.getAbandonedConnectionCheckInterval(), prop.getAbandonedConnectionCheckInterval());
+        } catch (SQLException e) {
+            throw new ESBConnectionException("DefaultConnectionPoolImpl: Error in creating Connection Pool", e);
+        }
+    }
+
+    private void initPool() throws SQLException {
+
+        if (_connectionFactory == null) {
+            Properties properties = new Properties();
+            properties.put("user", m_oConnProperties.getUser());
+            properties.put("password", m_oConnProperties.getPassword());
+            _connectionFactory = new DriverConnectionFactory(getDriver(m_oConnProperties.getDriverClassName()), m_oConnProperties.getConnectionUrl(), properties);
+        }
+        while (m_iConnCountInPool < m_oConnProperties.getMinPoolSize()) {
+            synchronized (m_oConnectionStack) {
+                m_oConnectionStack.add(new ConnectionWrapper(_connectionFactory.createConnection(), this));
+                m_iConnCountInPool++;
+            }
+        }
+    }
+
+    private Driver getDriver(String driverClassName) throws SQLException {
+        if (driverClassName != null) {
+            try {
+                Class.forName(driverClassName);
+            } catch (Throwable e) {
+                System.err.println("DefaultConnectionPoolImpl: Error in loading class " + driverClassName + " to create connection pool");
+                System.err.println(e);
+                throw new SQLException("DefaultConnectionPoolImpl: Error in loading class " + driverClassName + " to create connection pool");
+            }
+            return DriverManager.getDriver(m_oConnProperties.getConnectionUrl());
+        }
+        throw new SQLException("DefaultConnectionPoolImpl: Driver Class could not be loaded");
+    }
+
+    /**
+     * @see org.jboss.soa.esb.connection.ConnectionPool#getConnection()
+     *
+     */
+    public synchronized Connection getConnection() throws SQLException {
+        ConnectionWrapper newPoolConnection;
+        if (!m_oConnectionStack.isEmpty()) {
+            newPoolConnection = m_oConnectionStack.pop();
+            m_oUsedConnectionMap.put(newPoolConnection.getName(), newPoolConnection);
+        } else if (m_iConnCountInPool < m_oConnProperties.getMaxPoolSize()) {
+            newPoolConnection = new ConnectionWrapper(_connectionFactory.createConnection(), this);
+            m_oUsedConnectionMap.put(newPoolConnection.getName(), newPoolConnection);
+            m_iConnCountInPool++;
+        } else {
+            try {
+                Thread.sleep(m_oConnProperties.getConnectionBlockTimeInMillis());
+            } catch (InterruptedException e) {
+                //Do Nothing
+            }
+            if (!m_oConnectionStack.empty()) {
+                newPoolConnection = m_oConnectionStack.pop();
+                m_oUsedConnectionMap.put(newPoolConnection.getName(), newPoolConnection);
+            } else {
+                throw new SQLException("Connection Pool exhausted. Please increase number of connections");
+            }
+
+        }
+        Integer isolation = m_oConnProperties.getIsolationLevel();
+        if (isolation != null) newPoolConnection.setTransactionIsolation(isolation);
+        newPoolConnection.setAutoCommit(m_oConnProperties.getAutoCommit());
+        newPoolConnection.setActivatedTime(System.currentTimeMillis());
+        return newPoolConnection;
+    }
+
+    /**
+     * @see ConnectionPool;
+     */
+    public void closeConnection(Connection connectionToClose) {
+        synchronized (m_oConnectionStack) {
+            m_oConnectionStack.push((ConnectionWrapper) connectionToClose);
+        }
+        m_oUsedConnectionMap.remove(connectionToClose);
+    }
+
+    /**
+     * @see ConnectionPool#releasePool()
+     */
+    public void releasePool() {
+        try {
+            synchronized (m_oConnectionStack) {
+                for (ConnectionWrapper connection : m_oConnectionStack) {
+                    Connection origConn = connection.getActualConnection();
+                    origConn.close();
+                    m_iConnCountInPool--;
+                }
+            }
+            Enumeration<ConnectionWrapper> connectionWrapperEnum = m_oUsedConnectionMap.elements();
+            while (connectionWrapperEnum.hasMoreElements()) {
+                ConnectionWrapper connectionWrapper = connectionWrapperEnum.nextElement();
+                Connection con = connectionWrapper.getActualConnection();
+                String name = connectionWrapper.getName();
+                if (con != null && !con.isClosed()) {
+                    con.close();
+                }
+                m_iConnCountInPool--;
+                m_oUsedConnectionMap.remove(name);
+            }
+        } catch (SQLException e) {
+            System.err.println("DefaultConnectionPoolImpl: Error in closing physical Connection");
+            System.err.println(e);
+        }
+    }
+
+    protected void finalize() throws Throwable {
+        super.finalize();
+        releasePool();
+    }
+
+    /**
+     * This method will release all abandoned connections from the pool.
+     *
+     */
+    protected synchronized void releaseAbandonedConnections() {
+
+        Enumeration<ConnectionWrapper> connectionWrapperEnum = m_oUsedConnectionMap.elements();
+        while (connectionWrapperEnum.hasMoreElements()) {
+            ConnectionWrapper connectionWrapper = connectionWrapperEnum.nextElement();
+            long activedTime = connectionWrapper.getActivatedTime();
+            long currentTime = System.currentTimeMillis();
+            if ((currentTime - activedTime) > m_oConnProperties.getAbandonedConnectionTimeOut()) {
+                try {
+                    System.out.println("Removing abandoned Connection:-" + connectionWrapper);
+                    Connection actualConnection = connectionWrapper.getActualConnection();
+                    m_oUsedConnectionMap.remove(connectionWrapper.getName());
+                    connectionWrapper.setOriginalConnection(null);
+                    connectionWrapper = null;
+                    connectionWrapper = new ConnectionWrapper(actualConnection, this);
+                    synchronized (m_oConnectionStack) {
+                        m_oConnectionStack.push(connectionWrapper);
+                    }
+                } catch (SQLException e) {
+                    System.err.println("Error in releasing abandoned connection from Pool");
+                    e.printStackTrace(System.err);
+                }
+            }
+        }
+    }
+}

Added: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/DriverConnectionFactory.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/DriverConnectionFactory.java	2006-08-01 19:50:06 UTC (rev 5385)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/DriverConnectionFactory.java	2006-08-01 20:28:58 UTC (rev 5386)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.soa.esb.connection;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Driver;
+import java.util.Properties;
+
+/**
+ * Driver implementation of Connection Factory
+ * User: MohitK
+ * Date: Jul 18, 2006
+ */
+public class DriverConnectionFactory implements ConnectionFactory{
+
+    private Driver _driver;
+    private String _driverUrl;
+    private Properties _properties;
+
+    public DriverConnectionFactory(Driver driver,String driverUrl,Properties connectionProps){
+        this._driver=driver;
+        this._driverUrl=driverUrl;
+        this._properties=connectionProps;
+
+    }
+
+    /**
+     *
+     * @see org.jboss.soa.esb.connection.ConnectionFactory#createConnection()
+     */
+    public Connection createConnection() throws SQLException {
+        return _driver.connect(_driverUrl,_properties);
+    }
+
+}

Added: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/FreeConnectionPoolResources.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/FreeConnectionPoolResources.java	2006-08-01 19:50:06 UTC (rev 5385)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/FreeConnectionPoolResources.java	2006-08-01 20:28:58 UTC (rev 5386)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.soa.esb.connection;
+
+/**
+ * Shutdown Hook into the JVM. The class will be invoked by the JVM when the JVM is shutting down.
+ * Used to free connection resources and destroy the connection pool.
+ * User: MohitK
+ * Date: Jul 22, 2006
+ */
+public class FreeConnectionPoolResources extends Thread {
+
+    ConnectionPool pool;
+
+    public FreeConnectionPoolResources(ConnectionPool pool) {
+        this.pool = pool;
+    }
+
+    public void run() {
+        try {
+            pool.releasePool();
+        } catch (Exception e) {
+            System.err.println("Error in freeing resources");
+        }
+    }
+
+}

Added: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/PasswordDecoder.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/PasswordDecoder.java	2006-08-01 19:50:06 UTC (rev 5385)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/PasswordDecoder.java	2006-08-01 20:28:58 UTC (rev 5386)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.soa.esb.connection;
+
+/**
+ * Interface to be implemented by classes when they need to return the DB password for the connection by using their own
+ * algorithm. Called by the connection pool
+ * User: MohitK
+ * Date: Jul 21, 2006
+ */
+public interface PasswordDecoder {
+    /**
+     * This method decodes the password for JDBC Connection, it will be called when setting JDBC connection properties.
+     * Users who need to decode the password need to implement this interface and write their own
+     * decoding logic to send the actual DB password. If this method returns null
+     * @param encodedPassword The encoded password sent by JDBC framework
+     * @return Decoded password.
+     */
+    public String decode(String encodedPassword);
+}

Added: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/PoolDataSource.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/PoolDataSource.java	2006-08-01 19:50:06 UTC (rev 5385)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/PoolDataSource.java	2006-08-01 20:28:58 UTC (rev 5386)
@@ -0,0 +1,113 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.soa.esb.connection;
+
+import org.jboss.soa.esb.connection.exception.ESBConnectionException;
+
+import javax.sql.DataSource;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Properties;
+
+/**
+ * Implementation if Datasource for getting connections from pool.
+ * User: MohitK
+ * Date: Jul 19, 2006
+ */
+public class PoolDataSource implements DataSource {
+
+    private ConnectionPool _pool;
+    private PrintWriter _logWriter = new PrintWriter(System.out);
+    private int _loginTimeOut;
+    private final Properties _connProps = new Properties();
+    ConnectionProperties _connectionProperties;
+
+    private synchronized ConnectionPool createConnectionPool() throws SQLException {
+        if (_pool == null) {
+            try {
+                if (_connProps != null) {
+                    _connectionProperties = new ConnectionProperties(_connProps);
+                    _pool = ConnectionPoolFactory.createPool(_connectionProperties);
+                }
+            } catch (ESBConnectionException e) {
+                _logWriter.println("PoolDataSource: Error in creating Connection Pool");
+                throw new SQLException("Error in Connection Pool Creation");
+            }
+        }
+        return _pool;
+    }
+
+
+    public Properties getConnectionProperties() {
+        return _connProps;
+    }
+
+    public void setConnectionProperties(Properties _connProperties) {
+        _connProps.putAll(_connProperties);
+    }
+
+    /**
+     * @see  javax.sql.DataSource#getConnection()
+     */
+    public Connection getConnection() throws SQLException {
+        return createConnectionPool().getConnection();
+    }
+
+    /**
+     * @see  javax.sql.DataSource#getConnection(String, String)
+     */
+    public Connection getConnection(String username, String password) throws SQLException {
+        synchronized(_connProps){
+            _connProps.setProperty(ConnectionProperties.USERNAME, username);
+            _connProps.setProperty(ConnectionProperties.PASSWORD, password);
+        }
+        return createConnectionPool().getConnection();
+    }
+
+    /**
+     * @see  javax.sql.DataSource#getLogWriter()
+     */
+    public PrintWriter getLogWriter() throws SQLException {
+        return null;
+    }
+    /**
+     * @see  javax.sql.DataSource#setLogWriter(java.io.PrintWriter)
+     */
+    public void setLogWriter(PrintWriter out) throws SQLException {
+        this._logWriter = out;
+    }
+    /**
+     * @see  javax.sql.DataSource#setLoginTimeout(int)
+    */
+    public void setLoginTimeout(int seconds) throws SQLException {
+        this._loginTimeOut = seconds;
+    }
+
+    /**
+     * @see  javax.sql.DataSource#getLoginTimeout()
+     */
+    public int getLoginTimeout() throws SQLException {
+        return _loginTimeOut;
+    }
+
+}

Added: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/exception/ESBConnectionException.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/exception/ESBConnectionException.java	2006-08-01 19:50:06 UTC (rev 5385)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/connection/exception/ESBConnectionException.java	2006-08-01 20:28:58 UTC (rev 5386)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.soa.esb.connection.exception;
+
+/**
+ * This exception is thrown when Connection Pool fails to initialize
+ * User: MohitK
+ * Date: Jul 21, 2006
+ */
+public class ESBConnectionException extends Exception{
+    public ESBConnectionException() {
+        super();
+    }
+
+    public ESBConnectionException(String message) {
+        super(message);
+    }
+
+    public ESBConnectionException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public ESBConnectionException(Throwable cause) {
+        super(cause);
+    }
+}




More information about the jboss-svn-commits mailing list