KickJava   Java API By Example, From Geeks To Geeks.

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


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: JoinPointRequest.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 import java.util.HashSet JavaDoc;
30
31 import ch.ethz.jvmai.JVMAspectInterface;
32
33 /**
34  * Abstract class JoinPointRequest represents a request for some execution
35  * event (reaching a joinpoint) inside a virtual machine. The request will serve
36  * as key to a hashtable managed by <code>JoinPointManager</code>.
37  * This hashtable maps joinpoints (<code>JoinPointRequest</code>) to
38  * lists of listeners (<code>JoinPointListeners</code>).
39  *
40  * @version $Revision: 1.1.1.1 $
41  * @author Andrei Popovici
42  */

43 public abstract class JoinPointRequest {
44
45   public abstract int getMask();
46
47     public abstract String JavaDoc getKind();
48
49   transient protected final JoinPointManager owner;
50
51     /**
52      * Constructor.
53      *
54      * @param o Reference to the owner (join point manager)
55      * of this request
56      */

57   protected JoinPointRequest(JoinPointManager o)
58     {
59       this.owner = o;
60     }
61
62   protected JoinPointRequest()
63     {
64       owner = null;
65     }
66
67   /**
68      * Enables notification of joinpoint-events which have a
69      * signature equal to this request. This method will instruct the
70      * jvmai-system to set a watch on the joinpoin denoted by this request.
71      * Successive calls to this method without disabling the joinpoint will
72      * be recognized and dropped.
73      *
74      * @param listeners List of <code>JoinPointListener</code>s. This list will
75      * be registered as the aop-tag of the watch set here. When a joinpoint-event
76      * has occured, <code>JoinPointManager</code> will receive this aop-tag as part
77      * of the <code>JoinPoint</code>-object. The content of this tag will be casted
78      * to a list and all <code>JoinPointListener</code> included will be notified.
79      * <p>
80      * <b>Important:</b> Allways use the same list of <code>JoinPointListener<code> for
81      * the same joinpoint! Remember that the instance has been registered as the aop-tag.
82      * If you create a new list and try to enable the same joinpoint with the new list,
83      * the call to this method will be dropped and the new list won't be registered.
84      * To insert a new list, first disable the joinpoint (this will delete the associated
85      * aop-tag) and reenable it then with the new list.
86      */

87   public void enableJoinPoint(Object JavaDoc listeners)
88     {
89       synchronized (owner.enabledJoinPoints)
90     {
91       if (owner.enabledJoinPoints.contains(this))
92           return;
93
94           setWatch(listeners);
95       owner.enabledJoinPoints.add(this);
96     }
97     }
98
99     /**
100      * Disable the notification of joinpoint-events which have
101      * the a signature equal to this request. This method will delete
102      * the watch and the associated aop-tag in the underlying jvmai-system.
103      */

104   public void disableJoinPoint()
105     {
106       synchronized(owner.enabledJoinPoints)
107     {
108       if (!owner.enabledJoinPoints.contains(this))
109         return;
110           clearWatch();
111       owner.enabledJoinPoints.remove(this);
112     }
113     }
114
115     /**
116      * Sets the watch in the underlzing jvmai-system. This method has to
117      * be implemented by subclasses of <code>JoinPointRequest</code>.
118      * It will be called only by <code>enableJoinPoint(List listeners)</code>.
119      */

120   protected abstract void setWatch(Object JavaDoc listeners);
121
122     /**
123      * Clears the watch in the underlzing jvmai-system. This method has to
124      * be implemented by subclasses of <code>JoinPointRequest</code>.
125      * It will be called only by <code>disableJoinPoint()</code>.
126      */

127   protected abstract void clearWatch();
128
129     /**
130      * Every subclass of <code>JoinPointRequest</code> must provide an
131      * implementation for this method in order to be used as key to the
132      * hashtable administrated by the <code>JoinPointManager</code>.
133      */

134   public abstract boolean equals(Object JavaDoc other);
135
136     /**
137      * Every subclass of <code>JoinPointRequest</code> must provide an
138      * implementation for this method in order to be used as key to the
139      * hashtable administrated by the <code>JoinPointManager</code>.
140      */

141   public abstract int hashCode();
142
143  }
144
145
146 //======================================================================
147
//
148
// $Log: JoinPointRequest.java,v $
149
// Revision 1.1.1.1 2003/07/02 15:30:51 apopovic
150
// Imported from ETH Zurich
151
//
152
// Revision 1.2 2003/05/20 16:05:04 popovici
153
//
154
// New QueryManager replaces functionality in AspectManager (better Soc)
155
// New 'Surrogate' classes for usage in the QueryManager
156
// The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
157
//
158
// Revision 1.1 2003/05/05 13:58:27 popovici
159
// renaming from runes to prose
160
//
161
// Revision 1.10 2003/04/26 18:51:38 popovici
162
// 1 Bug fix which lead to a refactoring step:
163
// 1. the bug: 'JoinPointRequests' used to write to a static list, which survived a startup/teardown;
164
// now this list belongs to the JoinPointManager;
165
// 2. the refactoring: the JoinPointManager now creates (and shares state) with join-points.
166
//
167
// Revision 1.9 2003/04/17 12:49:27 popovici
168
// Refactoring of the crosscut package
169
// ExceptionCut renamed to ThrowCut
170
// McutSignature is now SignaturePattern
171
//
172
// Revision 1.8 2003/04/17 08:47:58 popovici
173
// Important functionality additions
174
// - Cflow specializers
175
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
176
// - Transactional capabilities
177
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
178
// between static and dynamic specializers.
179
// - Functionality pulled up in abstract classes
180
// - Uniformization of advice methods patterns and names
181
//
182
// Revision 1.7 2003/03/04 18:36:04 popovici
183
// Organization of imprts
184
//
185
// Revision 1.6 2003/03/04 11:27:31 popovici
186
// Important refactorization step (march):
187
// - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
188
// - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
189
// structures
190
//
191
// Revision 1.5 2003/02/11 14:28:47 popovici
192
// Serialization Problems solved; for MethodCut; Used to deserialize
193
// with null values for 'AdviceMethod'. Insertion caused problems
194
//
195
// Revision 1.4 2002/03/28 13:48:50 popovici
196
// Mozilla-ified
197
//
198
// Revision 1.3 2002/02/21 12:44:30 popovici
199
// Dispatching efficiency issues:
200
// - Hook methods in the join point manager are now inlined (they
201
// do not use any more 'notifyListeners'
202
// - Aop tags are now of type 'ListenerList' which allows efficient
203
// array iteration
204
// - 'setWatch' methods modifiy to accomodate ListenerLists on EventRequests
205
//
206
// Revision 1.2 2002/02/05 10:01:09 smarkwal
207
// JVMDI-specific code replaced by JVMAI. Prose-implementation classes and reflection package removed.
208
//
209
// Revision 1.1.1.1 2001/11/29 18:13:19 popovici
210
// Sources from runes
211
//
212
// Revision 1.1.2.1 2000/10/16 20:01:09 popovici
213
// Documentation added.
214
//
215
// Revision 1.1 2000/10/16 11:55:40 popovici
216
// Initial Revision
217
//
218
Popular Tags