Pages

Saturday, November 9, 2013

Object pooling with spring framework

This can be done using the following simple code.

<bean id="simpleBeanTarget" class="com.mad.SimpleBean" scope="prototype">
</bean>

<bean id="poolTargetSource" class="org.springframework.aop.target.CommonsPoolTargetSource">               <property name="targetBeanName" value="simpleBeanTarget" />
            <property name="maxSize" value="20" />
</bean>

<bean id="simpleBean" class="org.springframework.aop.framework.ProxyFactoryBean">
           <property name="targetSource" ref="poolTargetSource" />
</bean>

here the simpleBeanTarget is the bean which is pooled. poolTargetSource is the pooling  bean for the simple bean tareget.

No comments:

Post a Comment