1 16 17 package org.springframework.aop.target; 18 19 import org.springframework.aop.support.DefaultIntroductionAdvisor; 20 import org.springframework.aop.support.DelegatingIntroductionInterceptor; 21 import org.springframework.beans.BeansException; 22 import org.springframework.beans.factory.BeanFactory; 23 import org.springframework.beans.factory.BeanInitializationException; 24 import org.springframework.beans.factory.DisposableBean; 25 26 53 public abstract class AbstractPoolingTargetSource extends AbstractPrototypeBasedTargetSource 54 implements PoolingConfig, DisposableBean { 55 56 57 private int maxSize = -1; 58 59 60 64 public void setMaxSize(int maxSize) { 65 this.maxSize = maxSize; 66 } 67 68 71 public int getMaxSize() { 72 return this.maxSize; 73 } 74 75 76 public final void setBeanFactory(BeanFactory beanFactory) throws BeansException { 77 super.setBeanFactory(beanFactory); 78 try { 79 createPool(); 80 } 81 catch (Throwable ex) { 82 throw new BeanInitializationException("Could not create instance pool for TargetSource", ex); 83 } 84 } 85 86 87 91 protected abstract void createPool() throws Exception ; 92 93 99 public abstract Object getTarget() throws Exception ; 100 101 108 public abstract void releaseTarget(Object target) throws Exception ; 109 110 111 115 public DefaultIntroductionAdvisor getPoolingConfigMixin() { 116 DelegatingIntroductionInterceptor dii = new DelegatingIntroductionInterceptor(this); 117 return new DefaultIntroductionAdvisor(dii, PoolingConfig.class); 118 } 119 120 } 121 | Popular Tags |