1 16 17 package org.springframework.aop.target; 18 19 import java.io.Serializable ; 20 21 import org.springframework.aop.TargetSource; 22 import org.springframework.util.Assert; 23 import org.springframework.util.ObjectUtils; 24 25 38 public class SingletonTargetSource implements TargetSource, Serializable { 39 40 41 private static final long serialVersionUID = 9031246629662423738L; 42 43 44 45 private final Object target; 46 47 48 52 public SingletonTargetSource(Object target) { 53 Assert.notNull(target, "Target object must not be null"); 54 this.target = target; 55 } 56 57 58 public Class getTargetClass() { 59 return this.target.getClass(); 60 } 61 62 public Object getTarget() { 63 return this.target; 64 } 65 66 public void releaseTarget(Object target) { 67 } 69 70 public boolean isStatic() { 71 return true; 72 } 73 74 75 79 public boolean equals(Object other) { 80 if (this == other) { 81 return true; 82 } 83 if (!(other instanceof SingletonTargetSource)) { 84 return false; 85 } 86 SingletonTargetSource otherTargetSource = (SingletonTargetSource) other; 87 return this.target.equals(otherTargetSource.target); 88 } 89 90 93 public int hashCode() { 94 return this.target.hashCode(); 95 } 96 97 public String toString() { 98 return "SingletonTargetSource for target object [" + ObjectUtils.identityToString(this.target) + "]"; 99 } 100 101 } 102 | Popular Tags |