1 16 17 package org.springframework.transaction.interceptor; 18 19 import java.lang.reflect.Method ; 20 import java.util.Collection ; 21 22 import org.springframework.beans.factory.InitializingBean; 23 import org.springframework.metadata.Attributes; 24 import org.springframework.util.Assert; 25 import org.springframework.util.ObjectUtils; 26 27 39 public class AttributesTransactionAttributeSource extends AbstractFallbackTransactionAttributeSource 40 implements InitializingBean { 41 42 45 private Attributes attributes; 46 47 48 52 public AttributesTransactionAttributeSource() { 53 } 54 55 60 public AttributesTransactionAttributeSource(Attributes attributes) { 61 if (attributes == null) { 62 throw new IllegalArgumentException ("Attributes is required"); 63 } 64 this.attributes = attributes; 65 } 66 67 71 public void setAttributes(Attributes attributes) { 72 this.attributes = attributes; 73 } 74 75 public void afterPropertiesSet() { 76 if (this.attributes == null) { 77 throw new IllegalArgumentException ("'attributes' is required"); 78 } 79 } 80 81 82 protected Collection findAllAttributes(Class clazz) { 83 Assert.notNull(this.attributes, "'attributes' is required"); 84 return this.attributes.getAttributes(clazz); 85 } 86 87 protected Collection findAllAttributes(Method method) { 88 Assert.notNull(this.attributes, "'attributes' is required"); 89 return this.attributes.getAttributes(method); 90 } 91 92 93 public boolean equals(Object other) { 94 if (this == other) { 95 return true; 96 } 97 if (!(other instanceof AttributesTransactionAttributeSource)) { 98 return false; 99 } 100 AttributesTransactionAttributeSource otherTas = (AttributesTransactionAttributeSource) other; 101 return ObjectUtils.nullSafeEquals(this.attributes, otherTas.attributes); 102 } 103 104 public int hashCode() { 105 return AttributesTransactionAttributeSource.class.hashCode(); 106 } 107 108 } 109 | Popular Tags |