1 15 16 package com.jdon.controller.pool; 17 18 import org.apache.commons.pool.impl.GenericObjectPool; 19 20 29 public class CommonsPoolAdapter implements Pool { 30 private GenericObjectPool pool; 31 32 public CommonsPoolAdapter(GenericObjectPool pool){ 33 34 this.pool = pool; 35 } 36 37 public void setMaxPoolSize(int maxPoolSize){ 38 pool.setMaxActive(maxPoolSize); 39 } 40 41 public int getMaxPoolSize(){ 42 return this.getMaxPoolSize(); 43 } 44 45 public Object acquirePoolable() throws Exception { 46 return this.pool.borrowObject(); 47 } 48 49 public void releasePoolable(Object object) throws Exception { 50 this.pool.returnObject(object); 51 } 52 53 public int getNumActive(){ 54 return this.pool.getNumActive(); 55 } 56 57 public int getNumIdle(){ 58 return this.pool.getNumIdle(); 59 } 60 61 } 62 | Popular Tags |