org.objectweb.easybeans.component.jdbcpool
Class JDBCPoolComponent

java.lang.Object
  extended by org.objectweb.easybeans.component.jdbcpool.JDBCPoolComponent
All Implemented Interfaces:
EZBComponent

public class JDBCPoolComponent
extends java.lang.Object
implements EZBComponent

Defines a component that creates a JDBC pool in order to use it in EasyBeans.

Author:
Florent Benoit

Field Summary
private  int checkLevel
          Level of checking on connections when got from the pool.
private  ConnectionManager connectionManager
          Connection manager object.
private static int DEFAULT_CHECK_LEVEL
          Default prepared statement.
private static int DEFAULT_MAX_POOL
          Default max pool.
private static int DEFAULT_MIN_POOL
          Default min pool.
private static java.lang.String DEFAULT_PASSWORD
          Default password.
private static int DEFAULT_PSTMT
          Default prepared statement.
private static java.lang.String DEFAULT_USER
          Default username.
private  java.lang.String driver
          Name of the driver class to use.
private  java.lang.String jndiName
          JNDI name.
private static JLog logger
          Logger.
private  java.lang.String password
          Password.
private  int poolMax
          Pool max.
private  int poolMin
          Pool min.
private  int pstmtMax
          Max of prepared statement.
private  java.lang.String url
          URL for accessing to the database.
private  java.lang.String username
          Username.
private  boolean useTM
          Use transaction or not ?
 
Constructor Summary
JDBCPoolComponent()
          Default constructor.
 
Method Summary
 int getCheckLevel()
           
 java.lang.String getDriver()
           
 java.lang.String getJndiName()
           
 int getPoolMax()
           
 int getPoolMin()
           
 int getPstmtMax()
           
 java.lang.String getUrl()
           
 java.lang.String getUsername()
           
 void init()
          Init method.
This method is called before the start method.
 boolean isUseTM()
           
 void setCheckLevel(int checkLevel)
          Sets the JDBC check level.
 void setDriver(java.lang.String driver)
          Sets the name of the JDBC driver.
 void setJndiName(java.lang.String jndiName)
          Sets the JNDI name.
 void setPassword(java.lang.String password)
          Sets the password to use.
 void setPoolMax(int poolMax)
          The maximum size of the JDBC pool.
 void setPoolMin(int poolMin)
          The minimum size of the JDBC pool.
 void setPstmtMax(int pstmtMax)
          Set the max cache of prepared statement.
 void setUrl(java.lang.String url)
          Sets the connection's URL.
 void setUsername(java.lang.String username)
          Sets the username that is used to get a connection.
 void setUseTM(boolean useTM)
          Is that the pool will use transaction or not.
 void start()
          Start method.
This method is called after the init method.
 void stop()
          Stop method.
This method is called when component needs to be stopped.
private  void validate()
          Validate current data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static JLog logger
Logger.


DEFAULT_USER

private static final java.lang.String DEFAULT_USER
Default username.

See Also:
Constant Field Values

DEFAULT_PASSWORD

private static final java.lang.String DEFAULT_PASSWORD
Default password.

See Also:
Constant Field Values

DEFAULT_MIN_POOL

private static final int DEFAULT_MIN_POOL
Default min pool.

See Also:
Constant Field Values

DEFAULT_MAX_POOL

private static final int DEFAULT_MAX_POOL
Default max pool.

See Also:
Constant Field Values

DEFAULT_PSTMT

private static final int DEFAULT_PSTMT
Default prepared statement.

See Also:
Constant Field Values

DEFAULT_CHECK_LEVEL

private static final int DEFAULT_CHECK_LEVEL
Default prepared statement.

See Also:
Constant Field Values

checkLevel

private int checkLevel
Level of checking on connections when got from the pool. this avoids reusing bad connections because too old, for example when database was restarted... 0 = no checking 1 = check that still physically opened. 2 = try a null statement.


connectionManager

private ConnectionManager connectionManager
Connection manager object.


jndiName

private java.lang.String jndiName
JNDI name.


username

private java.lang.String username
Username.


password

private java.lang.String password
Password.


url

private java.lang.String url
URL for accessing to the database.


driver

private java.lang.String driver
Name of the driver class to use.


useTM

private boolean useTM
Use transaction or not ?


poolMin

private int poolMin
Pool min.


poolMax

private int poolMax
Pool max.


pstmtMax

private int pstmtMax
Max of prepared statement.

Constructor Detail

JDBCPoolComponent

public JDBCPoolComponent()
Default constructor.

Method Detail

init

public void init()
          throws EZBComponentException
Init method.
This method is called before the start method.

Specified by:
init in interface EZBComponent
Throws:
EZBComponentException - if the initialization has failed.

validate

private void validate()
               throws EZBComponentException
Validate current data.

Throws:
EZBComponentException - if validation fails.

start

public void start()
           throws EZBComponentException
Start method.
This method is called after the init method.

Specified by:
start in interface EZBComponent
Throws:
EZBComponentException - if the start has failed.

stop

public void stop()
          throws EZBComponentException
Stop method.
This method is called when component needs to be stopped.

Specified by:
stop in interface EZBComponent
Throws:
EZBComponentException - if the stop is failing.

setDriver

public void setDriver(java.lang.String driver)
Sets the name of the JDBC driver.

Parameters:
driver - the driver's name

getDriver

public java.lang.String getDriver()
Returns:
the name of the JDBC driver.

setJndiName

public void setJndiName(java.lang.String jndiName)
Sets the JNDI name.

Parameters:
jndiName - the name to bind the datasource

getJndiName

public java.lang.String getJndiName()
Returns:
the name that is bound in the datasource

setPassword

public void setPassword(java.lang.String password)
Sets the password to use.

Parameters:
password - the password for the url connection.

setPoolMax

public void setPoolMax(int poolMax)
The maximum size of the JDBC pool.

Parameters:
poolMax - the value of the pool's max.

getPoolMax

public int getPoolMax()
Returns:
the maximum size of the JDBC pool.

setPoolMin

public void setPoolMin(int poolMin)
The minimum size of the JDBC pool.

Parameters:
poolMin - the value of the pool's min.

getPoolMin

public int getPoolMin()
Returns:
the minimum size of the JDBC pool.

setPstmtMax

public void setPstmtMax(int pstmtMax)
Set the max cache of prepared statement.

Parameters:
pstmtMax - the max value for prepare statement.

getPstmtMax

public int getPstmtMax()
Returns:
the minimum size of the JDBC pool.

setUrl

public void setUrl(java.lang.String url)
Sets the connection's URL.

Parameters:
url - the URL used for the connection.

getUrl

public java.lang.String getUrl()
Returns:
the URL used for the connection.

setUsername

public void setUsername(java.lang.String username)
Sets the username that is used to get a connection.

Parameters:
username - the name of the user.

getUsername

public java.lang.String getUsername()
Returns:
the username that is used to get a connection.

setUseTM

public void setUseTM(boolean useTM)
Is that the pool will use transaction or not.

Parameters:
useTM - the true/false value.

isUseTM

public boolean isUseTM()
Returns:
true if this pool will use transaction (else false).

getCheckLevel

public int getCheckLevel()
Returns:
connection checking level

setCheckLevel

public void setCheckLevel(int checkLevel)
Sets the JDBC check level.

Parameters:
checkLevel - jdbc connection checking level.