KickJava   Java API By Example, From Geeks To Geeks.

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


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: FieldModificationRequest.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.Field JavaDoc;
31
32
33 import ch.ethz.jvmai.JVMAspectInterface;
34 import ch.ethz.jvmai.JoinPointKinds;
35 import ch.ethz.jvmai.ClassSpecific;
36
37 /**
38  * Class FieldModificationRequest is a special kind of
39  * <code>JoinPointRequest</code> which, when inserted into a
40  * <code>JoinPointManager</code> will make the local virtual
41  * machine to stop when it encounters a modification on the field
42  * denoted by this request. A corresponding
43  * <code>FieldModificationEvent</code> will be posted to the listeners
44  * registered in the join point manager.
45  *
46  * @version $Revision: 1.1.1.1 $
47  * @author Gerard Roos
48  */

49 public class FieldModificationRequest extends JoinPointRequest implements JoinPointKinds,ClassSpecific {
50
51   private final Field JavaDoc field;
52   private final Class JavaDoc fieldClass;
53
54   /** Constructor.
55    * creates an empty field modification request. This constructor must
56    * be used by subclasses, if the initialization shall not
57    * go over the info interface.
58    */

59   protected FieldModificationRequest()
60     {
61       super(null);
62       field = null;
63       fieldClass = null;
64     }
65
66     public String JavaDoc getKind()
67     {
68     return KIND_FIELD_MODIFICATION_JP;
69     }
70
71   public int getMask()
72     {
73       return MASK_FIELD_MODIFICATION_JP;
74     }
75
76   /**
77    * Constructor.
78    * @param f Field to set the watch at.
79    * @param ai Reference to the aspect-interface to set and clear jvmai-watches.
80    * @param ii Reference to the info-interface to query additional information from
81    * the jvmai-system.
82    */

83   public FieldModificationRequest(Field JavaDoc f,JoinPointManager o)
84     {
85       super(o);
86       field = f;
87       fieldClass = field.getDeclaringClass();
88     }
89
90   /**
91    * Implements method of interface ClassSpecific.
92    */

93   public Class JavaDoc getTargetClass()
94     {
95       return fieldClass;
96     }
97
98   /**
99    * Implements method of interface FieldSpecific.
100    */

101   public Field JavaDoc getField()
102     {
103       return field;
104     }
105
106   protected void setWatch(Object JavaDoc listeners)
107     {
108       owner.getAspectInterface().setFieldModificationWatch(field,listeners);
109     }
110
111   protected void clearWatch()
112     {
113       owner.getAspectInterface().clearFieldModificationWatch(field);
114     }
115
116   public boolean equals(Object JavaDoc other)
117     {
118       FieldModificationRequest otherReq;
119       if (other instanceof FieldModificationRequest)
120     otherReq = (FieldModificationRequest)other;
121       else
122     return false;
123       return field.equals(otherReq.field);
124     }
125
126   public int hashCode()
127     {
128       return field.hashCode();
129     }
130
131   public String JavaDoc toString()
132     {
133       return "FieldModificationRequest on " + fieldClass.getName() + "." + field.getName();
134     }
135
136 }
137
138
139 //======================================================================
140
//
141
// $Log: FieldModificationRequest.java,v $
142
// Revision 1.1.1.1 2003/07/02 15:30:51 apopovic
143
// Imported from ETH Zurich
144
//
145
// Revision 1.2 2003/05/20 16:05:03 popovici
146
//
147
// New QueryManager replaces functionality in AspectManager (better Soc)
148
// New 'Surrogate' classes for usage in the QueryManager
149
// The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
150
//
151
// Revision 1.1 2003/05/05 13:58:27 popovici
152
// renaming from runes to prose
153
//
154
// Revision 1.10 2003/04/26 18:51:37 popovici
155
// 1 Bug fix which lead to a refactoring step:
156
// 1. the bug: 'JoinPointRequests' used to write to a static list, which survived a startup/teardown;
157
// now this list belongs to the JoinPointManager;
158
// 2. the refactoring: the JoinPointManager now creates (and shares state) with join-points.
159
//
160
// Revision 1.9 2003/04/17 12:49:27 popovici
161
// Refactoring of the crosscut package
162
// ExceptionCut renamed to ThrowCut
163
// McutSignature is now SignaturePattern
164
//
165
// Revision 1.8 2003/04/17 08:47:57 popovici
166
// Important functionality additions
167
// - Cflow specializers
168
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
169
// - Transactional capabilities
170
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
171
// between static and dynamic specializers.
172
// - Functionality pulled up in abstract classes
173
// - Uniformization of advice methods patterns and names
174
//
175
// Revision 1.7 2003/03/04 18:36:03 popovici
176
// Organization of imprts
177
//
178
// Revision 1.6 2003/03/04 11:27:29 popovici
179
// Important refactorization step (march):
180
// - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
181
// - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
182
// structures
183
//
184
// Revision 1.5 2002/05/28 15:51:36 popovici
185
// parameterless contstructor created in FieldModificationRequest.
186
// Subclasses can now create Dummy field modification requests
187
//
188
// Revision 1.4 2002/03/28 13:48:48 popovici
189
// Mozilla-ified
190
//
191
// Revision 1.3 2002/02/21 12:44:30 popovici
192
// Dispatching efficiency issues:
193
// - Hook methods in the join point manager are now inlined (they
194
// do not use any more 'notifyListeners'
195
// - Aop tags are now of type 'ListenerList' which allows efficient
196
// array iteration
197
// - 'setWatch' methods modifiy to accomodate ListenerLists on EventRequests
198
//
199
// Revision 1.2 2002/02/05 10:00:21 smarkwal
200
// JVMDI-specific code replaced by JVMAI. Prose-implementation classes and reflection package removed.
201
//
202
// Revision 1.1.1.1 2001/11/29 18:13:13 popovici
203
// Sources from runes
204
//
205
// Revision 1.1.2.4 2001/02/21 13:21:40 popovici
206
// method 'toString' change to be more executive
207
//
208
// Revision 1.1.2.3 2000/11/28 16:34:16 groos
209
// Interface FieldModificationRequest is now FieldSpecific. The methods provided in FieldSpecific are added and implemented.
210
//
211
// Revision 1.1.2.2 2000/11/22 16:49:01 groos
212
// Constructor not public anymore (now package scope).
213
// 'FieldSignature' interface is obsolete and has been removed. Uses 'FieldSignatureImpl' directly.
214
//
215
// Revision 1.1.2.1 2000/11/21 14:29:27 groos
216
// initial revision.
217
//
218
Popular Tags