1 package dynaop.observer; 2 3 import java.io.Serializable ; 4 5 import dynaop.Interceptor; 6 import dynaop.Invocation; 7 8 15 public class SubjectInterceptor implements Interceptor, Serializable { 16 17 private Object argument; 18 19 public SubjectInterceptor() { 20 } 21 22 public SubjectInterceptor(Object argument) { 23 this.argument = argument; 24 } 25 26 30 protected Object createArgument(Subject subject, 31 Invocation invocation, Object result) { 32 return this.argument; 33 } 34 35 public Object intercept(Invocation invocation) throws Throwable { 36 Object result = invocation.proceed(); 37 38 Subject subject = (Subject) invocation.getProxy(); 39 subject.notifyObservers(createArgument(subject, invocation, result)); 40 41 return result; 42 } 43 } 44 | Popular Tags |