1 16 17 package org.springframework.aop.framework.autoproxy.metadata; 18 19 import java.util.Collection ; 20 21 import org.springframework.aop.framework.autoproxy.target.AbstractPoolingTargetSourceCreator; 22 import org.springframework.aop.framework.autoproxy.target.PoolingAttribute; 23 import org.springframework.beans.factory.BeanDefinitionStoreException; 24 import org.springframework.metadata.Attributes; 25 26 31 public class AttributesPoolingTargetSourceCreator extends AbstractPoolingTargetSourceCreator { 32 33 36 private Attributes attributes; 37 38 42 public AttributesPoolingTargetSourceCreator() { 43 } 44 45 49 public AttributesPoolingTargetSourceCreator(Attributes attributes) { 50 if (attributes == null) { 51 throw new IllegalArgumentException ("Attributes is required"); 52 } 53 this.attributes = attributes; 54 } 55 56 59 public void setAttributes(Attributes attributes) { 60 this.attributes = attributes; 61 } 62 63 public void afterPropertiesSet() { 64 if (this.attributes == null) { 65 throw new IllegalArgumentException ("'attributes' is required"); 66 } 67 } 68 69 protected PoolingAttribute getPoolingAttribute(Class beanClass, String beanName) { 70 Collection atts = this.attributes.getAttributes(beanClass, PoolingAttribute.class); 72 if (atts.isEmpty()) { 73 return null; 75 } 76 else if (atts.size() > 1) { 77 throw new BeanDefinitionStoreException( 78 "Cannot have more than one pooling attribute on [" + beanClass.getName() + "]"); 79 } 80 else { 81 return (PoolingAttribute) atts.iterator().next(); 82 } 83 } 84 85 } 86 | Popular Tags |