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 GlobalMaxOnlyStatementCache extends GooGooStatementCache 30 { 31 int max_statements; 33 Deathmarch globalDeathmarch = new Deathmarch(); 34 35 public GlobalMaxOnlyStatementCache(AsynchronousRunner blockingTaskAsyncRunner, int max_statements) 36 { 37 super( blockingTaskAsyncRunner ); 38 this.max_statements = max_statements; 39 } 40 41 protected ConnectionStatementManager createConnectionStatementManager() 43 { return new SimpleConnectionStatementManager(); } 44 45 void addStatementToDeathmarches( Object pstmt, Connection physicalConnection ) 47 { globalDeathmarch.deathmarchStatement( pstmt ); } 48 49 void removeStatementFromDeathmarches( Object pstmt, Connection physicalConnection ) 50 { globalDeathmarch.undeathmarchStatement( pstmt ); } 51 52 boolean prepareAssimilateNewStatement(Connection pcon) 53 { 54 int global_size = this.countCachedStatements(); 55 return ( global_size < max_statements || (global_size == max_statements && globalDeathmarch.cullNext()) ); 56 } 57 } 58 | Popular Tags |