gate.util.spring.xml
Class PooledProxyBeanDefinitionDecorator

java.lang.Object
  extended by gate.util.spring.xml.PooledProxyBeanDefinitionDecorator
All Implemented Interfaces:
org.springframework.beans.factory.xml.BeanDefinitionDecorator

public class PooledProxyBeanDefinitionDecorator
extends Object
implements org.springframework.beans.factory.xml.BeanDefinitionDecorator

Bean decorator to easily create a pool of target beans.

 <bean id="myBean" class="some.pkg.MyBean">
   <property name="gateApplication" ref="app" />
   <gate:pooled-proxy max-size="3" />
 </bean>
 

This replaces the myBean bean with a proxy that delegates to a pool of target objects. The targets are obtained by converting the original myBean definition to a prototype-scoped bean definition and setting that as the targetBeanName of a CommonsPoolTargetSource. The CommonsPoolTargetSource is then used as the target source for a standard ProxyFactoryBean, which is created with the scope specified in the original myBean definition (usually singleton).

If the pooled-proxy element has an attribute proxy-target-class, this value is passed through to the generated ProxyFactoryBean. All other attributes are passed through to the CommonsPoolTargetSource. The element also supports an initial-size attribute. If specified it will pre-populate the pool with this number of instances, which is useful if you want to load several copies of a saved application up-front (the normal behaviour of a Spring pool is to only instantiate the pooled objects as and when they are required).

NOTE In addition to the spring-aop JAR, you also need the Apache commons-pool JAR and its dependencies available to your application in order to use this class.


Field Summary
static String POOL_FILLER_PREFIX
           
static String TARGET_PREFIX
           
static String TARGET_SOURCE_PREFIX
           
 
Constructor Summary
PooledProxyBeanDefinitionDecorator()
           
 
Method Summary
 org.springframework.beans.factory.config.BeanDefinitionHolder decorate(Node node, org.springframework.beans.factory.config.BeanDefinitionHolder definition, org.springframework.beans.factory.xml.ParserContext parserContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TARGET_PREFIX

public static final String TARGET_PREFIX
See Also:
Constant Field Values

TARGET_SOURCE_PREFIX

public static final String TARGET_SOURCE_PREFIX
See Also:
Constant Field Values

POOL_FILLER_PREFIX

public static final String POOL_FILLER_PREFIX
See Also:
Constant Field Values
Constructor Detail

PooledProxyBeanDefinitionDecorator

public PooledProxyBeanDefinitionDecorator()
Method Detail

decorate

public org.springframework.beans.factory.config.BeanDefinitionHolder decorate(Node node,
                                                                              org.springframework.beans.factory.config.BeanDefinitionHolder definition,
                                                                              org.springframework.beans.factory.xml.ParserContext parserContext)
Specified by:
decorate in interface org.springframework.beans.factory.xml.BeanDefinitionDecorator