001: //
002: // This file is part of the prose package.
003: //
004: // The contents of this file are subject to the Mozilla Public License
005: // Version 1.1 (the "License"); you may not use this file except in
006: // compliance with the License. You may obtain a copy of the License at
007: // http://www.mozilla.org/MPL/
008: //
009: // Software distributed under the License is distributed on an "AS IS" basis,
010: // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011: // for the specific language governing rights and limitations under the
012: // License.
013: //
014: // The Original Code is prose.
015: //
016: // The Initial Developer of the Original Code is Andrei Popovici. Portions
017: // created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
018: // All Rights Reserved.
019: //
020: // Contributor(s):
021: // $Id: MethodExitRequest.java,v 1.1.1.1 2003/07/02 15:30:51 apopovic Exp $
022: // =====================================================================
023: //
024: // (history at end)
025: //
026:
027: package ch.ethz.prose.engine;
028:
029: // used packages
030: import java.lang.reflect.Method;
031: import ch.ethz.jvmai.JoinPointKinds;
032: import ch.ethz.jvmai.ClassSpecific;
033:
034: /**
035: * Class MethodExitRequest is a special kind of
036: * <code>JoinPointRequest</code> which, when inserted into a
037: * <code>JoinPointManager</code> will make the local virtual
038: * machine stop at the location it denotes. A corresponding
039: * <code>MethodExitEvent</code> will be posted to the listeners
040: * registered in the join point manager.
041: *
042: * @version $Revision: 1.1.1.1 $
043: * @author Andrei Popovici
044: */
045: public class MethodExitRequest extends JoinPointRequest implements
046: JoinPointKinds, ClassSpecific {
047:
048: private final Method method;
049: private final Class methodClass;
050:
051: public String getKind() {
052: return KIND_METHOD_EXIT_JP;
053: }
054:
055: /**
056: * Constructor.
057: * @param m Method to set the watch at.
058: * @param o Reference to the JoinPointManager to set and clear jvmai-watches.
059: */
060: public MethodExitRequest(Method m, JoinPointManager o) {
061: super (o);
062: method = m;
063: methodClass = method.getDeclaringClass();
064: }
065:
066: public int getMask() {
067: return MASK_METHOD_EXIT_JP | MASK_CODE_JP;
068: }
069:
070: /**
071: * Implements method from ClassSpecific
072: */
073: public Class getTargetClass() {
074: return methodClass;
075: }
076:
077: /**
078: * Implements method from MethodSpecific
079: */
080: public Method getMethod() {
081: return method;
082: }
083:
084: protected void setWatch(Object listeners) {
085: owner.getAspectInterface()
086: .setMethodExitWatch(method, listeners);
087: }
088:
089: protected void clearWatch() {
090: owner.getAspectInterface().clearMethodExitWatch(method);
091: }
092:
093: public boolean equals(Object other) {
094: MethodExitRequest otherReq;
095: if (other instanceof MethodExitRequest)
096: otherReq = (MethodExitRequest) other;
097: else
098: return false;
099: return method.equals(otherReq.method);
100: }
101:
102: public int hashCode() {
103: return getMethod().hashCode();
104: }
105:
106: public String toString() {
107: return "MethodExitReuest on " + methodClass.getName() + "."
108: + method.getName();
109: }
110:
111: }
112:
113: //======================================================================
114: //
115: // $Log: MethodExitRequest.java,v $
116: // Revision 1.1.1.1 2003/07/02 15:30:51 apopovic
117: // Imported from ETH Zurich
118: //
119: // Revision 1.3 2003/05/20 16:05:05 popovici
120: //
121: // New QueryManager replaces functionality in AspectManager (better Soc)
122: // New 'Surrogate' classes for usage in the QueryManager
123: // The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
124: //
125: // Revision 1.2 2003/05/05 17:46:54 popovici
126: // Refactorization step (runes->prose) cleanup
127: //
128: // Revision 1.1 2003/05/05 13:58:25 popovici
129: // renaming from runes to prose
130: //
131: // Revision 1.8 2003/04/26 18:51:39 popovici
132: // 1 Bug fix which lead to a refactoring step:
133: // 1. the bug: 'JoinPointRequests' used to write to a static list, which survived a startup/teardown;
134: // now this list belongs to the JoinPointManager;
135: // 2. the refactoring: the JoinPointManager now creates (and shares state) with join-points.
136: //
137: // Revision 1.7 2003/04/17 12:49:28 popovici
138: // Refactoring of the crosscut package
139: // ExceptionCut renamed to ThrowCut
140: // McutSignature is now SignaturePattern
141: //
142: // Revision 1.6 2003/04/17 08:47:59 popovici
143: // Important functionality additions
144: // - Cflow specializers
145: // - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
146: // - Transactional capabilities
147: // - Total refactoring of Specializer evaluation, which permits fine-grained distinction
148: // between static and dynamic specializers.
149: // - Functionality pulled up in abstract classes
150: // - Uniformization of advice methods patterns and names
151: //
152: // Revision 1.5 2003/03/04 18:36:05 popovici
153: // Organization of imprts
154: //
155: // Revision 1.4 2003/03/04 11:27:33 popovici
156: // Important refactorization step (march):
157: // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
158: // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
159: // structures
160: //
161: // Revision 1.3 2002/03/28 13:48:52 popovici
162: // Mozilla-ified
163: //
164: // Revision 1.2 2002/02/21 12:44:30 popovici
165: // Dispatching efficiency issues:
166: // - Hook methods in the join point manager are now inlined (they
167: // do not use any more 'notifyListeners'
168: // - Aop tags are now of type 'ListenerList' which allows efficient
169: // array iteration
170: // - 'setWatch' methods modifiy to accomodate ListenerLists on EventRequests
171: //
172: // Revision 1.1 2002/02/05 10:03:59 smarkwal
173: // BreakpointEvent and BreakpointRequest replaced by MethodEntry/MethodExit -Request and Event
174: //
175: // Revision 1.1.1.1 2001/11/29 18:13:12 popovici
176: // Sources from runes
177: //
178: // Revision 1.1.2.6 2001/11/21 11:56:19 popovici
179: //
180: // -The sun.tools.agent and ch.ethz.inf.util.JVMDIUtil functionality
181: // replaced with the iks.jvmdi package. References to this old
182: // functionality replaced throughout the code.
183: // -Partial reimplementation of the ch.ethz.inf.iks.runes classes,
184: // part of their functionality moved to the ch.ethz.prose.reflect
185: // abstract classes. New classes and functionality added to the
186: // ch.ethz.prose.reflect package, partially to reflect the
187: // more stable features taken from the iks.runes packages, partially
188: // to reflect the structure of the VM (constant pool, etc). Functionality in
189: // ch.ethz.prose.crosscut and the junit classes adapted to use the
190: // new form of the ch.ethz.prose.reflect package
191: //
192: // Revision 1.1.2.5 2001/03/19 12:10:49 popovici
193: // Constructor made public to allow Simulation tests.
194: //
195: // Revision 1.1.2.4 2001/02/21 13:20:33 popovici
196: // method 'toString' change to be both more verbose and more executive
197: //
198: // Revision 1.1.2.3 2000/11/28 16:27:27 groos
199: // Locatable interface has been removed. Instead, BreakpointRequest extends the interface LocationSpecific. The methods provided by LocationSpecific have been added and implemented.
200: //
201: // Revision 1.1.2.2 2000/10/23 19:05:52 popovici
202: // import declaration changed according to refactorization DEVEL_WS0001;
203: //
204: // Revision 1.1.2.1 2000/10/16 13:04:36 popovici
205: // Initial revision
206: //
|