KickJava   Java API By Example, From Geeks To Geeks.

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


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
// $Id: MethodEntryRequest.java,v 1.1.1.1 2003/07/02 15:30:51 apopovic Exp $
22
// =====================================================================
23
//
24
// (history at end)
25
//
26

27 package ch.ethz.prose.engine;
28
29 // used packages
30
import java.lang.reflect.Method JavaDoc;
31
32 import ch.ethz.jvmai.JVMAspectInterface;
33 import ch.ethz.jvmai.JoinPointKinds;
34 import ch.ethz.jvmai.ClassSpecific;
35
36 /**
37  * Class MethodEntryRequest is a special kind of
38  * <code>JoinPointRequest</code> which, when inserted into a
39  * <code>JoinPointManager</code> will make the local virtual
40  * machine stop at the location it denotes. A corresponding
41  * <code>MethodEntryEvent</code> will be posted to the listeners
42  * registered in the join point manager.
43  *
44  * @version $Revision: 1.1.1.1 $
45  * @author Andrei Popovici
46  */

47 public
48 class MethodEntryRequest extends JoinPointRequest implements JoinPointKinds,ClassSpecific {
49
50   private final Method JavaDoc method;
51   private final Class JavaDoc methodClass;
52
53   public int getMask()
54     {
55       return MASK_METHOD_ENTRY_JP| MASK_CODE_JP;
56     }
57
58     public String JavaDoc getKind()
59     {
60     return KIND_METHOD_ENTRY_JP;
61     }
62
63   /**
64    * Constructor.
65    * @param m Method to set the watch at.
66    * @param ai Reference to the aspect-interface to set and clear jvmai-watches.
67    * @param ii Reference to the info-interface to query additional information from
68    * the jvmai-system.
69    */

70   public MethodEntryRequest(Method JavaDoc m,JoinPointManager o)
71     {
72     super(o);
73     method = m;
74     methodClass = method.getDeclaringClass();
75     }
76
77     /**
78      * Implements method from ClassSpecific
79      */

80     public Class JavaDoc getTargetClass()
81     {
82     return methodClass;
83     }
84
85   /**
86    * Implements method from MethodSpecific
87    */

88     public Method JavaDoc getMethod()
89     {
90     return method;
91     }
92
93     protected void setWatch(Object JavaDoc listeners)
94     {
95     owner.getAspectInterface().setMethodEntryWatch(method,listeners);
96     }
97
98     protected void clearWatch()
99     {
100     owner.getAspectInterface().clearMethodEntryWatch(method);
101     }
102
103   public boolean equals(Object JavaDoc other)
104     {
105     MethodEntryRequest otherReq;
106     if (other instanceof MethodEntryRequest)
107         otherReq = (MethodEntryRequest)other;
108     else
109         return false;
110     return method.equals(otherReq.method);
111     }
112
113   // the plus 1 guarantees,
114
// that a MethodExitRequest and MethodEntryRequest on the same Method don't have the same hashCode.
115
public int hashCode()
116     {
117       return (getMethod().hashCode() + 1);
118     }
119
120     public String JavaDoc toString()
121     {
122       return "MethodEntryRequest on " + methodClass.getName() + "." + method.getName();
123     }
124
125
126 }
127
128
129 //======================================================================
130
//
131
// $Log: MethodEntryRequest.java,v $
132
// Revision 1.1.1.1 2003/07/02 15:30:51 apopovic
133
// Imported from ETH Zurich
134
//
135
// Revision 1.3 2003/05/20 16:05:04 popovici
136
//
137
// New QueryManager replaces functionality in AspectManager (better Soc)
138
// New 'Surrogate' classes for usage in the QueryManager
139
// The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
140
//
141
// Revision 1.2 2003/05/05 17:46:54 popovici
142
// Refactorization step (runes->prose) cleanup
143
//
144
// Revision 1.1 2003/05/05 13:58:27 popovici
145
// renaming from runes to prose
146
//
147
// Revision 1.9 2003/04/26 18:51:38 popovici
148
// 1 Bug fix which lead to a refactoring step:
149
// 1. the bug: 'JoinPointRequests' used to write to a static list, which survived a startup/teardown;
150
// now this list belongs to the JoinPointManager;
151
// 2. the refactoring: the JoinPointManager now creates (and shares state) with join-points.
152
//
153
// Revision 1.8 2003/04/17 12:49:28 popovici
154
// Refactoring of the crosscut package
155
// ExceptionCut renamed to ThrowCut
156
// McutSignature is now SignaturePattern
157
//
158
// Revision 1.7 2003/04/17 08:47:59 popovici
159
// Important functionality additions
160
// - Cflow specializers
161
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
162
// - Transactional capabilities
163
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
164
// between static and dynamic specializers.
165
// - Functionality pulled up in abstract classes
166
// - Uniformization of advice methods patterns and names
167
//
168
// Revision 1.6 2003/03/04 18:36:05 popovici
169
// Organization of imprts
170
//
171
// Revision 1.5 2003/03/04 11:27:32 popovici
172
// Important refactorization step (march):
173
// - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
174
// - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
175
// structures
176
//
177
// Revision 1.4 2003/01/27 12:46:41 pschoch
178
// HashCode incremented by 1 so it differs from other JoinPointReqest types
179
//
180
// Revision 1.3 2002/03/28 13:48:51 popovici
181
// Mozilla-ified
182
//
183
// Revision 1.2 2002/02/21 12:44:30 popovici
184
// Dispatching efficiency issues:
185
// - Hook methods in the join point manager are now inlined (they
186
// do not use any more 'notifyListeners'
187
// - Aop tags are now of type 'ListenerList' which allows efficient
188
// array iteration
189
// - 'setWatch' methods modifiy to accomodate ListenerLists on EventRequests
190
//
191
// Revision 1.1 2002/02/05 10:03:49 smarkwal
192
// BreakpointEvent and BreakpointRequest replaced by MethodEntry/MethodExit -Request and Event
193
//
194
// Revision 1.1.1.1 2001/11/29 18:13:12 popovici
195
// Sources from runes
196
//
197
// Revision 1.1.2.6 2001/11/21 11:56:19 popovici
198
//
199
// -The sun.tools.agent and ch.ethz.inf.util.JVMDIUtil functionality
200
// replaced with the iks.jvmdi package. References to this old
201
// functionality replaced throughout the code.
202
// -Partial reimplementation of the ch.ethz.inf.iks.runes classes,
203
// part of their functionality moved to the ch.ethz.prose.reflect
204
// abstract classes. New classes and functionality added to the
205
// ch.ethz.prose.reflect package, partially to reflect the
206
// more stable features taken from the iks.runes packages, partially
207
// to reflect the structure of the VM (constant pool, etc). Functionality in
208
// ch.ethz.prose.crosscut and the junit classes adapted to use the
209
// new form of the ch.ethz.prose.reflect package
210
//
211
// Revision 1.1.2.5 2001/03/19 12:10:49 popovici
212
// Constructor made public to allow Simulation tests.
213
//
214
// Revision 1.1.2.4 2001/02/21 13:20:33 popovici
215
// method 'toString' change to be both more verbose and more executive
216
//
217
// Revision 1.1.2.3 2000/11/28 16:27:27 groos
218
// Locatable interface has been removed. Instead, BreakpointRequest extends the interface LocationSpecific. The methods provided by LocationSpecific have been added and implemented.
219
//
220
// Revision 1.1.2.2 2000/10/23 19:05:52 popovici
221
// import declaration changed according to refactorization DEVEL_WS0001;
222
//
223
// Revision 1.1.2.1 2000/10/16 13:04:36 popovici
224
// Initial revision
225
//
226
Popular Tags