KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > prose > engine > MethodRedefineRequest


1 package ch.ethz.prose.engine;
2
3 import java.lang.reflect.Method JavaDoc;
4
5 import ch.ethz.jvmai.JoinPointKinds;
6 import ch.ethz.jvmai.ClassSpecific;
7
8 /**
9  * Represents a method redefine request based a <code>MethodRedefineJoinPoint<code>.
10  *
11  * @author Johann Gyger
12  */

13 public class MethodRedefineRequest extends JoinPointRequest implements JoinPointKinds, ClassSpecific {
14
15   protected final Method JavaDoc oldMethod;
16
17   /**
18    * Create a new method redefine request.
19    *
20    * @param oldMethod method that will be redefined
21    * @param newMethod new method (advice)
22    * @param o owner of this request
23    */

24   public MethodRedefineRequest(Method JavaDoc oldMethod, JoinPointManager o) {
25     super(o);
26     this.oldMethod = oldMethod;
27   }
28
29   public int getMask() {
30     return MASK_METHOD_REDEFINE_JP | MASK_CODE_JP;
31   }
32
33   public String JavaDoc getKind() {
34     return KIND_METHOD_REDEFINE_JP;
35   }
36
37   public Class JavaDoc getTargetClass() {
38     return oldMethod.getDeclaringClass();
39   }
40
41   public Method JavaDoc getMethod() {
42     return oldMethod;
43   }
44
45   public boolean equals(Object JavaDoc other) {
46     MethodRedefineRequest otherReq;
47     if (other instanceof MethodRedefineRequest)
48       otherReq = (MethodRedefineRequest) other;
49     else
50       return false;
51     return oldMethod.equals(otherReq.oldMethod);
52   }
53
54   public int hashCode() {
55     return (getMethod().hashCode() + 2);
56   }
57
58   public String JavaDoc toString() {
59     return "MethodRedefineRequest on " + oldMethod.getDeclaringClass().getName() + "." + oldMethod.getName();
60   }
61
62   protected void setWatch(Object JavaDoc listeners) {
63     throw new RuntimeException JavaDoc("Not supported");
64   }
65
66   protected void clearWatch() {
67     throw new RuntimeException JavaDoc("Not supported");
68   }
69
70 }
71
Popular Tags