1 22 23 24 package com.mchange.v2.c3p0.stmt; 25 26 import java.sql.*; 27 import com.mchange.v2.async.AsynchronousRunner; 28 29 public final class PerConnectionMaxOnlyStatementCache extends GooGooStatementCache 30 { 31 int max_statements_per_connection; 33 DeathmarchConnectionStatementManager dcsm; 34 35 public PerConnectionMaxOnlyStatementCache(AsynchronousRunner blockingTaskAsyncRunner, int max_statements_per_connection) 36 { 37 super( blockingTaskAsyncRunner ); 38 this.max_statements_per_connection = max_statements_per_connection; 39 } 40 41 protected ConnectionStatementManager createConnectionStatementManager() 43 { return (this.dcsm = new DeathmarchConnectionStatementManager()); } 44 45 void addStatementToDeathmarches( Object pstmt, Connection physicalConnection ) 47 { dcsm.getDeathmarch( physicalConnection ).deathmarchStatement( pstmt ); } 48 49 void removeStatementFromDeathmarches( Object pstmt, Connection physicalConnection ) 50 { dcsm.getDeathmarch( physicalConnection ).undeathmarchStatement( pstmt ); } 51 52 boolean prepareAssimilateNewStatement(Connection pcon) 53 { 54 int cxn_stmt_count = dcsm.getNumStatementsForConnection( pcon ); 55 return ( cxn_stmt_count < max_statements_per_connection || (cxn_stmt_count == max_statements_per_connection && dcsm.getDeathmarch( pcon ).cullNext()) ); 56 } 57 } 58 | Popular Tags |