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