org.huihoo.jfox.pool.connection
Class SimpleConnectionPool

org.huihoo.jfox.service.ComponentSupport
  |
  +--org.huihoo.jfox.pool.connection.SimpleConnectionPool
All Implemented Interfaces:
Component, ComponentSupportMBean, ConnectionPool, Loggable, ObjectPoolMBean, Persistentable, java.io.Serializable, SimpleConnectionPoolMBean

public class SimpleConnectionPool
extends ComponentSupport
implements SimpleConnectionPoolMBean, ConnectionPool

Get connections from this pool, all connections get from this pool can be recycled for resue.

Author:
Kelvin Wu
See Also:
Serialized Form

Fields inherited from class org.huihoo.jfox.service.ComponentSupport
logger, name, objectName, proxyInstance, sequence, server, state
 
Constructor Summary
SimpleConnectionPool(java.lang.String dbDriver, java.lang.String dbURL, java.lang.String user, java.lang.String password)
          Default constructor
 
Method Summary
 void clear()
          Clears any objects sitting idle in the pool, releasing any associated resources
protected  void doDestroy()
          do actually destory action
protected  void doInit()
          do actually create action
 java.sql.Connection getConnection()
          Get the pooled connection that will be used by user.
 java.lang.String getDbDriver()
           
 java.lang.String getDbURL()
           
 java.lang.String getObjectClass()
          get the pooled object's class type, it return by object pool's factory
 ObjectFactory getObjectFactory()
          get the factory use to create new instances
 java.lang.String getPassword()
           
 int getRest()
          get the count of rest object
 java.lang.String getUser()
           
 int getWorking()
          get the count of working object
 void setDbDriver(java.lang.String driver)
           
 void setDbURL(java.lang.String dbUrl)
           
 void setPassword(java.lang.String password)
           
 void setUser(java.lang.String user)
           
 
Methods inherited from class org.huihoo.jfox.service.ComponentSupport
destroy, getLogger, getName, getObjectName, getProxyInstance, getState, handleNotification, init, parseName, postDeregister, postRegister, preDeregister, preRegister, setLogger, setName
 
Methods inherited from interface org.huihoo.jfox.service.ComponentSupportMBean
getObjectName, getProxyInstance
 
Methods inherited from interface org.huihoo.jfox.service.Component
destroy, getName, getState, init
 
Methods inherited from interface org.huihoo.jfox.service.Loggable
getLogger
 

Constructor Detail

SimpleConnectionPool

public SimpleConnectionPool(java.lang.String dbDriver,
                            java.lang.String dbURL,
                            java.lang.String user,
                            java.lang.String password)
                     throws java.lang.Exception
Default constructor
Parameters:
dbDriver - database driver class name.
dbURL - database url for connect to the database.
user - user name.
password - password
Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws java.lang.Exception
Get the pooled connection that will be used by user.
Specified by:
getConnection in interface ConnectionPool
Returns:
Connection that will be used by user

doInit

protected void doInit()
               throws java.lang.Exception
Description copied from class: ComponentSupport
do actually create action
Overrides:
doInit in class ComponentSupport

doDestroy

protected void doDestroy()
                  throws java.lang.Exception
Description copied from class: ComponentSupport
do actually destory action
Overrides:
doDestroy in class ComponentSupport

clear

public void clear()
Description copied from interface: ObjectPoolMBean
Clears any objects sitting idle in the pool, releasing any associated resources
Specified by:
clear in interface ObjectPoolMBean

getObjectFactory

public ObjectFactory getObjectFactory()
Description copied from interface: ObjectPoolMBean
get the factory use to create new instances
Specified by:
getObjectFactory in interface ObjectPoolMBean

getObjectClass

public java.lang.String getObjectClass()
Description copied from interface: ObjectPoolMBean
get the pooled object's class type, it return by object pool's factory
Specified by:
getObjectClass in interface ObjectPoolMBean
Following copied from interface: org.huihoo.jfox.pool.ObjectPoolMBean
Returns:
 

getWorking

public int getWorking()
Description copied from interface: ObjectPoolMBean
get the count of working object
Specified by:
getWorking in interface ObjectPoolMBean
Following copied from interface: org.huihoo.jfox.pool.ObjectPoolMBean
Returns:
 

getRest

public int getRest()
Description copied from interface: ObjectPoolMBean
get the count of rest object
Specified by:
getRest in interface ObjectPoolMBean
Following copied from interface: org.huihoo.jfox.pool.ObjectPoolMBean
Returns:
 

setDbURL

public void setDbURL(java.lang.String dbUrl)
Specified by:
setDbURL in interface SimpleConnectionPoolMBean

getDbURL

public java.lang.String getDbURL()
Specified by:
getDbURL in interface SimpleConnectionPoolMBean

setDbDriver

public void setDbDriver(java.lang.String driver)
Specified by:
setDbDriver in interface SimpleConnectionPoolMBean

getDbDriver

public java.lang.String getDbDriver()
Specified by:
getDbDriver in interface SimpleConnectionPoolMBean

setUser

public void setUser(java.lang.String user)
Specified by:
setUser in interface SimpleConnectionPoolMBean

getUser

public java.lang.String getUser()
Specified by:
getUser in interface SimpleConnectionPoolMBean

setPassword

public void setPassword(java.lang.String password)
Specified by:
setPassword in interface SimpleConnectionPoolMBean

getPassword

public java.lang.String getPassword()
Specified by:
getPassword in interface SimpleConnectionPoolMBean