KickJava   Java API By Example, From Geeks To Geeks.

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


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: MethodExitRequest.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  * Class MethodExitRequest is a special kind of
37  * <code>JoinPointRequest</code> which, when inserted into a
38  * <code>JoinPointManager</code> will make the local virtual
39  * machine stop at the location it denotes. A corresponding
40  * <code>MethodExitEvent</code> will be posted to the listeners
41  * registered in the join point manager.
42  *
43  * @version $Revision: 1.1.1.1 $
44  * @author Andrei Popovici
45  */

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

64   public MethodExitRequest(Method JavaDoc m, JoinPointManager o)
65     {
66       super(o);
67       method = m;
68       methodClass = method.getDeclaringClass();
69     }
70
71   public int getMask()
72     {
73       return MASK_METHOD_EXIT_JP| MASK_CODE_JP;
74     }
75
76   /**
77    * Implements method from ClassSpecific
78    */

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

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