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: FieldAccessRequest.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.Field;
031: import ch.ethz.jvmai.JoinPointKinds;
032: import ch.ethz.jvmai.ClassSpecific;
033:
034: /**
035: * Class FieldAccessRequest 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 to stop when it encounters an access on the field
039: * denoted by this request. A corresponding
040: * <code>FieldAccessEvent</code> will be posted to the listeners
041: * registered in the join point manager.
042: *
043: * @version $Revision: 1.1.1.1 $
044: * @author Andrei Popovici
045: * @author Gerard Roos
046: */
047: public class FieldAccessRequest extends JoinPointRequest implements
048: JoinPointKinds, ClassSpecific {
049:
050: private final Field field;
051: private final Class fieldClass;
052:
053: /**
054: * Constructor.
055: * @param f Field to set the watch at.
056: * @param o Reference to the JoinPointManager to set and clear jvmai-watches.
057: */
058: public FieldAccessRequest(Field f, JoinPointManager o) {
059: super (o);
060: field = f;
061: fieldClass = field.getDeclaringClass();
062: }
063:
064: public String getKind() {
065: return KIND_FIELD_ACCESS_JP;
066: }
067:
068: public int getMask() {
069: return MASK_FIELD_ACCESS_JP;
070: }
071:
072: /**
073: * Implements method of interface ClassSpecific.
074: */
075: public Class getTargetClass() {
076: return fieldClass;
077: }
078:
079: /**
080: * Implements method of interface FieldSpecific.
081: */
082: public Field getField() {
083: return field;
084: }
085:
086: protected void setWatch(Object listeners) {
087: owner.getAspectInterface()
088: .setFieldAccessWatch(field, listeners);
089: }
090:
091: protected void clearWatch() {
092: owner.getAspectInterface().clearFieldAccessWatch(field);
093: }
094:
095: public boolean equals(Object other) {
096: FieldAccessRequest otherReq;
097: if (other instanceof FieldAccessRequest)
098: otherReq = (FieldAccessRequest) other;
099: else
100: return false;
101: return field.equals(otherReq.field);
102: }
103:
104: public int hashCode() {
105: return (field.hashCode() + 1);
106: }
107:
108: public String toString() {
109: return "FieldAccessRequest on " + fieldClass.getName() + "."
110: + field.getName();
111: }
112:
113: }
114:
115: //======================================================================
116: //
117: // $Log: FieldAccessRequest.java,v $
118: // Revision 1.1.1.1 2003/07/02 15:30:51 apopovic
119: // Imported from ETH Zurich
120: //
121: // Revision 1.2 2003/05/20 16:05:03 popovici
122: //
123: // New QueryManager replaces functionality in AspectManager (better Soc)
124: // New 'Surrogate' classes for usage in the QueryManager
125: // The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
126: //
127: // Revision 1.1 2003/05/05 13:58:26 popovici
128: // renaming from runes to prose
129: //
130: // Revision 1.10 2003/04/26 18:51:36 popovici
131: // 1 Bug fix which lead to a refactoring step:
132: // 1. the bug: 'JoinPointRequests' used to write to a static list, which survived a startup/teardown;
133: // now this list belongs to the JoinPointManager;
134: // 2. the refactoring: the JoinPointManager now creates (and shares state) with join-points.
135: //
136: // Revision 1.9 2003/04/17 12:49:27 popovici
137: // Refactoring of the crosscut package
138: // ExceptionCut renamed to ThrowCut
139: // McutSignature is now SignaturePattern
140: //
141: // Revision 1.8 2003/04/17 08:47:57 popovici
142: // Important functionality additions
143: // - Cflow specializers
144: // - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
145: // - Transactional capabilities
146: // - Total refactoring of Specializer evaluation, which permits fine-grained distinction
147: // between static and dynamic specializers.
148: // - Functionality pulled up in abstract classes
149: // - Uniformization of advice methods patterns and names
150: //
151: // Revision 1.7 2003/03/04 18:36:03 popovici
152: // Organization of imprts
153: //
154: // Revision 1.6 2003/03/04 11:27:28 popovici
155: // Important refactorization step (march):
156: // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
157: // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
158: // structures
159: //
160: // Revision 1.5 2003/01/27 12:46:42 pschoch
161: // HashCode incremented by 1 so it differs from other JoinPointReqest types
162: //
163: // Revision 1.4 2002/03/28 13:48:47 popovici
164: // Mozilla-ified
165: //
166: // Revision 1.3 2002/02/21 12:44:30 popovici
167: // Dispatching efficiency issues:
168: // - Hook methods in the join point manager are now inlined (they
169: // do not use any more 'notifyListeners'
170: // - Aop tags are now of type 'ListenerList' which allows efficient
171: // array iteration
172: // - 'setWatch' methods modifiy to accomodate ListenerLists on EventRequests
173: //
174: // Revision 1.2 2002/02/05 10:00:30 smarkwal
175: // JVMDI-specific code replaced by JVMAI. Prose-implementation classes and reflection package removed.
176: //
177: // Revision 1.1.1.1 2001/11/29 18:13:12 popovici
178: // Sources from runes
179: //
180: // Revision 1.1.2.4 2001/02/21 13:21:20 popovici
181: // method 'toString' change to be more executive
182: //
183: // Revision 1.1.2.3 2000/11/28 16:33:51 groos
184: // Interface FieldAccessRequest is now FieldSpecific. The methods provided in FieldSpecific are added and implemented.
185: //
186: // Revision 1.1.2.2 2000/11/22 16:51:51 groos
187: // 'FieldSignature' interface is obsolete and has been removed. Uses 'FieldSignatureImpl' directly.
188: //
189: // Revision 1.1.2.1 2000/11/21 14:29:21 groos
190: // initial revision.
191: //
|