|
soap tutorial | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectadriani.jws.template.db.ObjectPool
adriani.jws.template.db.JDBCConnectionPool
adriani.jws.template.db.MockConnectionPool
public class MockConnectionPool
Mock oriented implementation of the ObjectPool
parent class.
This class is different from the JDBCConnectionPool
pool because here the objects in
the pool are not "java plain old" SQL connections, but instances of the MockConnection
wrapper.
Before ending or closing the application using the pool, the user should call the
shutdown()
method to properly terminate the cleaner thread.
ObjectPool
,
MockConnection
Field Summary |
---|
Fields inherited from class adriani.jws.template.db.JDBCConnectionPool |
---|
alias, con, pwd, supportTns, usr |
Fields inherited from class adriani.jws.template.db.ObjectPool |
---|
expirationTime, leadingName, logger, maximum |
Constructor Summary | |
---|---|
MockConnectionPool(java.lang.String con,
java.lang.String usr,
java.lang.String pwd,
int expirationTime)
Use this constructor if the JDBC driver has been already registered. |
|
MockConnectionPool(java.lang.String driver,
java.lang.String con,
java.lang.String usr,
java.lang.String pwd,
int expirationTime)
Use this constructor when it's necessary to register the JDBC driver (only the first time). |
Method Summary | |
---|---|
java.lang.Object |
create()
Users should not call this method directly. |
void |
expire(java.lang.Object object)
Method used by the ObjectPool class in two different situations: when the object is found
invalid (during a check out operation) or when the Cleaner Thread discards the object (timeout). |
java.sql.Connection |
getConnectionFromMock(java.lang.Object object)
Cast the input object into a MockConnection wrapper and the retrieves the
java.sql.Connection stored in the wrapper. |
protected java.lang.String |
getDatabaseName(java.lang.String tns)
Split the full connect string and return only the last token, describing the database name. |
MockConnection |
getMockConnection()
Users should call this method each time a mock connection is needed. |
void |
returnMockConnection(MockConnection mock)
Users should call this method each time a mock is not needed anymore. |
boolean |
validate(java.lang.Object object)
Method used by the checkOut() method of the ObjectPool class before checking
out an object from the unlocked pool. |
Methods inherited from class adriani.jws.template.db.JDBCConnectionPool |
---|
getConnection, getTNSEntryName, logConnection, returnConnection, setTNSEntryName, setTnsName, shutdown, supportTnsNames |
Methods inherited from class adriani.jws.template.db.ObjectPool |
---|
checkIn, checkOut, cleanUp, finalize, getPoolData, getPoolSize, printObject, setPoolSize |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MockConnectionPool(java.lang.String con, java.lang.String usr, java.lang.String pwd, int expirationTime)
JDBCConnectionPool
),
which forwards action to the super-super class (i.e. ObjectPool
)
that takes care to create and run the cleaner thread.
con
- the connection string of the db, e.g. jdbc:oracle:thin:@192.168.1.10:1533:db_nameusr
- the user name for the SQL connectionpwd
- the password for the SQL connectionexpirationTime
- sleep time of the Cleaner Thread in secondspublic MockConnectionPool(java.lang.String driver, java.lang.String con, java.lang.String usr, java.lang.String pwd, int expirationTime)
Driver
class.
driver
- the JDBC driver, e.g. oracle.jdbc.driver.OracleDriver.con
- the connection string of the db, e.g. jdbc:oracle:thin:@192.168.1.10:1533:db_nameusr
- the user name for the SQL connectionpwd
- the password for the SQL connectionexpirationTime
- sleep time of the Cleaner Thread in secondsMethod Detail |
---|
public MockConnection getMockConnection() throws java.sql.SQLException
getConnection()
method inherited from the
super class, since any java.sql.Connection
object stored in a MockConnectionPool
class is always null.
super.checkOut()
method
java.sql.SQLException
ObjectPool.checkOut()
public void returnMockConnection(MockConnection mock)
returnConnection()
method inherited from the
super class, since any java.sql.Connection
object stored in a MockConnectionPool
class is always null.
mock
- the MockConnection to be returned in the unlocked hashtable
(using super.checkIn()
)ObjectPool.checkIn(Object obj)
public java.lang.Object create() throws java.sql.SQLException
checkOut()
method of the
ObjectPool
class that will invoke this method ONLY IF there isn't any unlocked object in the
pool, in order to create a new one. Notice that this is the only codeblock creating the objects managed
by this pool class (in this case a MockConnection
object).
create
in class JDBCConnectionPool
MockConnection
to the database
java.sql.SQLException
public boolean validate(java.lang.Object object)
checkOut()
method of the ObjectPool
class before checking
out an object from the unlocked pool.
validate
in class JDBCConnectionPool
object
- the MockConnection
to be validatedpublic void expire(java.lang.Object object)
ObjectPool
class in two different situations: when the object is found
invalid (during a check out operation) or when the Cleaner Thread discards the object (timeout).
expire
in class JDBCConnectionPool
object
- the MockConnection
to be destroyedpublic java.sql.Connection getConnectionFromMock(java.lang.Object object)
MockConnection
wrapper and the retrieves the
java.sql.Connection
stored in the wrapper.
object
- an object managed by this pool class (i.e. a MockConnection
instance)
java.sql.Connection
stored in the MockConnection
wrapperprotected java.lang.String getDatabaseName(java.lang.String tns)
getDatabaseName
in class JDBCConnectionPool
tns
- the connect string of the database, e.g. jdbc:oracle:thin:@192.168.3.12:1588:db_name
|
Build 19/03/2014 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |