KickJava   Java API By Example, From Geeks To Geeks.

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


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: ExceptionThrowRequest.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 ch.ethz.jvmai.JVMAspectInterface;
31 import ch.ethz.jvmai.JoinPointKinds;
32
33
34 /**
35  * Class ExceptionThrowRequest is a special kind of
36  * <code>JoinPointRequest</code> which, when inserted into a
37  * <code>JoinPointManager</code> will make the local virtual
38  * machine to stop when it encounters an exception object beeing thrown
39  * denoted by this request. A corresponding
40  * <code>ExceptionThrowEvent</code> will be posted to the listeners
41  * registered in the join point manager.
42  * @version $Revision: 1.1.1.1 $
43  * @author Philippe Schoch
44  */

45 public
46 class ExceptionThrowRequest extends JoinPointRequest implements JoinPointKinds {
47
48   private final Class JavaDoc exceptionClass;
49
50   /**
51    * Constructor.
52    * @param exceptionClass Class of the thrown Exception.
53    * @param ai Reference to the aspect-interface to set and clear jvmai-watches.
54    * @param ii Reference to the info-interface to query additional information from
55    * the jvmai-system.
56    */

57   public ExceptionThrowRequest(Class JavaDoc cls, JoinPointManager o)
58     throws ClassCastException JavaDoc
59   {
60     super(o);
61
62     try {
63             if (!(Class.forName("java.lang.Throwable").isAssignableFrom(cls)))
64                 throw new ClassCastException JavaDoc("ClassCastException: Class must be of subtype 'Throwable'");
65     }
66     catch (ClassNotFoundException JavaDoc e)
67         {
68         System.err.println(e);
69         e.printStackTrace();
70     }
71
72     exceptionClass = cls;
73   }
74
75   public int getMask()
76     {
77       return MASK_EXCEPTION_THROW_ARGS_JP;
78     }
79
80     public String JavaDoc getKind()
81     {
82     return KIND_EXCEPTION_THROW_ARGS_JP;
83     }
84
85
86   public Class JavaDoc getExceptionClass()
87   {
88       return exceptionClass;
89   }
90
91   protected void setWatch(Object JavaDoc listeners)
92   {
93       owner.getAspectInterface().setExceptionThrowWatch(exceptionClass, listeners);
94   }
95
96   protected void clearWatch()
97   {
98       owner.getAspectInterface().clearExceptionThrowWatch(exceptionClass);
99   }
100
101   public boolean equals(Object JavaDoc other)
102   {
103       ExceptionThrowRequest otherReq;
104       if (other instanceof ExceptionThrowRequest)
105     otherReq = (ExceptionThrowRequest)other;
106       else
107     return false;
108       return exceptionClass.equals(otherReq.getExceptionClass());
109   }
110
111   public int hashCode()
112   {
113       return exceptionClass.hashCode();
114   }
115
116   public String JavaDoc toString()
117   {
118       return "ExceptionThrowRequest on Class " + exceptionClass.getName();
119   }
120
121 }
122
123
124 //======================================================================
125
//
126
// $Log: ExceptionThrowRequest.java,v $
127
// Revision 1.1.1.1 2003/07/02 15:30:51 apopovic
128
// Imported from ETH Zurich
129
//
130
// Revision 1.3 2003/05/20 16:05:03 popovici
131
//
132
// New QueryManager replaces functionality in AspectManager (better Soc)
133
// New 'Surrogate' classes for usage in the QueryManager
134
// The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
135
//
136
// Revision 1.2 2003/05/06 15:51:33 popovici
137
// Mozilla-ification
138
//
139
// Revision 1.1 2003/05/05 13:58:25 popovici
140
// renaming from runes to prose
141
//
142
// Revision 1.7 2003/04/26 18:51:36 popovici
143
// 1 Bug fix which lead to a refactoring step:
144
// 1. the bug: 'JoinPointRequests' used to write to a static list, which survived a startup/teardown;
145
// now this list belongs to the JoinPointManager;
146
// 2. the refactoring: the JoinPointManager now creates (and shares state) with join-points.
147
//
148
// Revision 1.6 2003/04/17 12:49:28 popovici
149
// Refactoring of the crosscut package
150
// ExceptionCut renamed to ThrowCut
151
// McutSignature is now SignaturePattern
152
//
153
// Revision 1.5 2003/04/17 08:47:57 popovici
154
// Important functionality additions
155
// - Cflow specializers
156
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
157
// - Transactional capabilities
158
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
159
// between static and dynamic specializers.
160
// - Functionality pulled up in abstract classes
161
// - Uniformization of advice methods patterns and names
162
//
163
// Revision 1.4 2003/03/04 18:36:04 popovici
164
// Organization of imprts
165
//
166
// Revision 1.3 2003/03/04 11:27:27 popovici
167
// Important refactorization step (march):
168
// - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
169
// - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
170
// structures
171
//
172
// Revision 1.2 2003/01/17 12:16:57 pschoch
173
// Bugfix in the 'equals' method
174
//
175
// Revision 1.1 2002/10/31 18:26:55 pschoch
176
// Capability of crosscutting Exceptions added to prose.
177
//
178
Popular Tags