KickJava   Java API By Example, From Geeks To Geeks.

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


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: FieldAccessRequest.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 FieldAccessRequest 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 an access on the field
42  * denoted by this request. A corresponding
43  * <code>FieldAccessEvent</code> will be posted to the listeners
44  * registered in the join point manager.
45  *
46  * @version $Revision: 1.1.1.1 $
47  * @author Andrei Popovici
48  * @author Gerard Roos
49  */

50 public class FieldAccessRequest extends JoinPointRequest implements JoinPointKinds,ClassSpecific {
51
52   private final Field JavaDoc field;
53   private final Class JavaDoc fieldClass;
54
55   /**
56    * Constructor.
57    * @param f Field to set the watch at.
58    * @param ai Reference to the aspect-interface to set and clear jvmai-watches.
59    * @param ii Reference to the info-interface to query additional information from
60    * the jvmai-system.
61    */

62   public FieldAccessRequest(Field JavaDoc f,JoinPointManager o)
63     {
64       super(o);
65       field = f;
66       fieldClass = field.getDeclaringClass();
67     }
68
69     public String JavaDoc getKind()
70     {
71     return KIND_FIELD_ACCESS_JP;
72     }
73
74
75   public int getMask()
76     {
77       return MASK_FIELD_ACCESS_JP;
78     }
79
80   /**
81    * Implements method of interface ClassSpecific.
82    */

83   public Class JavaDoc getTargetClass()
84     {
85       return fieldClass;
86     }
87
88   /**
89    * Implements method of interface FieldSpecific.
90    */

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