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.AbstractBeanFactoryBasedTargetSourceCreator; 22 import org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource; 23 import org.springframework.aop.target.ThreadLocalTargetSource; 24 import org.springframework.metadata.Attributes; 25 26 33 public class AttributesThreadLocalTargetSourceCreator extends AbstractBeanFactoryBasedTargetSourceCreator { 34 35 38 private Attributes attributes; 39 40 44 public AttributesThreadLocalTargetSourceCreator() { 45 } 46 47 51 public AttributesThreadLocalTargetSourceCreator(Attributes attributes) { 52 if (attributes == null) { 53 throw new IllegalArgumentException ("Attributes is required"); 54 } 55 this.attributes = attributes; 56 } 57 58 61 public void setAttributes(Attributes attributes) { 62 this.attributes = attributes; 63 } 64 65 public void afterPropertiesSet() { 66 if (this.attributes == null) { 67 throw new IllegalArgumentException ("'attributes' is required"); 68 } 69 } 70 71 protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource( 72 Class beanClass, String beanName) { 73 74 Collection atts = this.attributes.getAttributes(beanClass, ThreadLocalAttribute.class); 76 if (atts.isEmpty()) { 77 return null; 79 } 80 else { 81 return new ThreadLocalTargetSource(); 82 } 83 } 84 85 } 86 | Popular Tags |