KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > inf > iks > jvmai > jvmdi > MethodExecutionJoinPointImpl


1 //
2
// This file is part of the prose package.
3
//
4
// The contents of this file are subject to the Mozilla Public License
5
// Version 1.1 (the "License"); you may not use this file except in
6
// compliance with the License. You may obtain a copy of the License at
7
// http://www.mozilla.org/MPL/
8
//
9
// Software distributed under the License is distributed on an "AS IS" basis,
10
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
// for the specific language governing rights and limitations under the
12
// License.
13
//
14
// The Original Code is prose.
15
//
16
// The Initial Developer of the Original Code is Andrei Popovici. Portions
17
// created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
18
// All Rights Reserved.
19
//
20
// Contributor(s):
21
package ch.ethz.inf.iks.jvmai.jvmdi;
22
23 import ch.ethz.jvmai.MethodEntryJoinPoint;
24 import ch.ethz.jvmai.MethodExitJoinPoint;
25 import ch.ethz.jvmai.JoinPointKinds;
26
27 /** Class MethodExecutionJoinPointImpl is
28  * simply the implementation for the MethodEntry and MethodExit
29  * join point kinds.
30  */

31 public class MethodExecutionJoinPointImpl
32 extends CodeJoinPointImpl
33 implements MethodEntryJoinPoint,MethodExitJoinPoint,JoinPointKinds
34 {
35
36   private int mask;
37   protected void setKind(boolean isEntryJP)
38     {
39     isEntryJoinPoint=isEntryJP;
40     if(isEntryJoinPoint)
41       mask = MASK_CODE_JP | MASK_METHOD_ENTRY_JP;
42     else
43       mask = MASK_CODE_JP | MASK_METHOD_EXIT_JP;
44
45     }
46
47     private boolean isEntryJoinPoint;
48     protected MethodExecutionJoinPointImpl(ControlFlow cf, JoinPointContext ctx)
49     {
50     super(cf,ctx);
51     }
52
53     public void setArg(int position, Object JavaDoc value)
54     {
55     context.setLocalValue(value,position);
56     }
57
58   public int getMask()
59     {
60       return mask;
61     }
62
63     public String JavaDoc getKind()
64     {
65     if (isEntryJoinPoint)
66         return MethodEntryJoinPoint.KIND;
67     else
68         return MethodExitJoinPoint.KIND;
69     }
70
71     public Object JavaDoc getResult()
72     {
73     throw new RuntimeException JavaDoc("MethodExit getResult not implemented");
74     }
75
76     public void setResult(Object JavaDoc result)
77     {
78     throw new RuntimeException JavaDoc("MethodExit setResult not implemented");
79     }
80
81
82     // in a method entry/exit joinpoint, the target is actually known: THIS
83
public Object JavaDoc getTarget()
84     {
85     return getThis();
86     }
87
88     /**
89      * implements method of interface ClassSpecific
90      */

91     public Class JavaDoc getTargetClass()
92     {
93     return getMethod().getDeclaringClass();
94     }
95 }
96
Popular Tags