org.tentackle.db
Interface DbPool

All Known Implementing Classes:
DefaultDbPool

public interface DbPool

A pool of logical Db connections.

The DbPool manages a pool of Db instances. From an application's point of view, a DbPool resembles to what is known as a "connection pool" in traditional (mostly J2EE) server-based applications. However, because a Db does not necessarily correspond to a physical connection (this is up to a ConnectionManager), a DbPool is one abstraction level above a typical connection pool. In fact, Tentackle servers use a DbPool, but only to optimize caching. The Db instances will run on an MpxConnectionManager, which actually does the multiplexing of physical connections. So don't mix up a DbPool with a multiplexing connection manager!
Of course, you can use a DbPool with a non-multiplexing connection manager. This can make sense in pure web-applications providing their own session management (JSP, for example). For fat-client application servers, however, this is not a good idea, because the client is associated with a Db (in fact two Dbs) for as long as it is logged in and not just for the duration of a rather short-timed http-request/response roundtrip.

Author:
harald

Method Summary
 Db getDb()
          Gets a Db instance from the pool.
 int getMaxSize()
          Gets the maximum poolsize.
 int getSize()
          Gets the current number of Db instances.
 void putDb(Db db)
          Returns a Db instance to the pool.
 void shutdown()
          Closes all databases in the pool, cleans up and makes the pool unusable.
 

Method Detail

getMaxSize

int getMaxSize()
Gets the maximum poolsize.

Returns:
the max. number of concurrent Db instances, 0 = unlimited

getSize

int getSize()
Gets the current number of Db instances.

Returns:
the number of Db managed by this pool

getDb

Db getDb()
         throws DbRuntimeException
Gets a Db instance from the pool.

Returns:
an open Db ready for use, never null
Throws:
DbRuntimeException - if pool is exhausted

putDb

void putDb(Db db)
           throws DbRuntimeException
Returns a Db instance to the pool.

Notice: returning a Db to the pool more than once is allowed.

Parameters:
db - the Db instance
Throws:
DbRuntimeException - if the Db cannot be returned

shutdown

void shutdown()
Closes all databases in the pool, cleans up and makes the pool unusable.



Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de