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: ExceptionThrowRequest.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 ch.ethz.jvmai.JoinPointKinds;
031:
032: /**
033: * Class ExceptionThrowRequest is a special kind of
034: * <code>JoinPointRequest</code> which, when inserted into a
035: * <code>JoinPointManager</code> will make the local virtual
036: * machine to stop when it encounters an exception object beeing thrown
037: * denoted by this request. A corresponding
038: * <code>ExceptionThrowEvent</code> will be posted to the listeners
039: * registered in the join point manager.
040: * @version $Revision: 1.1.1.1 $
041: * @author Philippe Schoch
042: */
043: public class ExceptionThrowRequest extends JoinPointRequest implements
044: JoinPointKinds {
045:
046: private final Class exceptionClass;
047:
048: /**
049: * Constructor.
050: * @param cls Class of the thrown Exception.
051: * @param o Reference to the JoinPointManager to set and clear jvmai-watches.
052: */
053: public ExceptionThrowRequest(Class cls, JoinPointManager o)
054: throws ClassCastException {
055: super (o);
056:
057: try {
058: if (!(Class.forName("java.lang.Throwable")
059: .isAssignableFrom(cls)))
060: throw new ClassCastException(
061: "ClassCastException: Class must be of subtype 'Throwable'");
062: } catch (ClassNotFoundException e) {
063: System.err.println(e);
064: e.printStackTrace();
065: }
066:
067: exceptionClass = cls;
068: }
069:
070: public int getMask() {
071: return MASK_EXCEPTION_THROW_ARGS_JP;
072: }
073:
074: public String getKind() {
075: return KIND_EXCEPTION_THROW_ARGS_JP;
076: }
077:
078: public Class getExceptionClass() {
079: return exceptionClass;
080: }
081:
082: protected void setWatch(Object listeners) {
083: owner.getAspectInterface().setExceptionThrowWatch(
084: exceptionClass, listeners);
085: }
086:
087: protected void clearWatch() {
088: owner.getAspectInterface().clearExceptionThrowWatch(
089: exceptionClass);
090: }
091:
092: public boolean equals(Object other) {
093: ExceptionThrowRequest otherReq;
094: if (other instanceof ExceptionThrowRequest)
095: otherReq = (ExceptionThrowRequest) other;
096: else
097: return false;
098: return exceptionClass.equals(otherReq.getExceptionClass());
099: }
100:
101: public int hashCode() {
102: return exceptionClass.hashCode();
103: }
104:
105: public String toString() {
106: return "ExceptionThrowRequest on Class "
107: + exceptionClass.getName();
108: }
109:
110: }
111:
112: //======================================================================
113: //
114: // $Log: ExceptionThrowRequest.java,v $
115: // Revision 1.1.1.1 2003/07/02 15:30:51 apopovic
116: // Imported from ETH Zurich
117: //
118: // Revision 1.3 2003/05/20 16:05:03 popovici
119: //
120: // New QueryManager replaces functionality in AspectManager (better Soc)
121: // New 'Surrogate' classes for usage in the QueryManager
122: // The 'RemoteAspectManager' and tools modified to use the Surrogates and the QueryManager
123: //
124: // Revision 1.2 2003/05/06 15:51:33 popovici
125: // Mozilla-ification
126: //
127: // Revision 1.1 2003/05/05 13:58:25 popovici
128: // renaming from runes to prose
129: //
130: // Revision 1.7 2003/04/26 18:51:36 popovici
131: // 1 Bug fix which lead to a refactoring step:
132: // 1. the bug: 'JoinPointRequests' used to write to a static list, which survived a startup/teardown;
133: // now this list belongs to the JoinPointManager;
134: // 2. the refactoring: the JoinPointManager now creates (and shares state) with join-points.
135: //
136: // Revision 1.6 2003/04/17 12:49:28 popovici
137: // Refactoring of the crosscut package
138: // ExceptionCut renamed to ThrowCut
139: // McutSignature is now SignaturePattern
140: //
141: // Revision 1.5 2003/04/17 08:47:57 popovici
142: // Important functionality additions
143: // - Cflow specializers
144: // - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
145: // - Transactional capabilities
146: // - Total refactoring of Specializer evaluation, which permits fine-grained distinction
147: // between static and dynamic specializers.
148: // - Functionality pulled up in abstract classes
149: // - Uniformization of advice methods patterns and names
150: //
151: // Revision 1.4 2003/03/04 18:36:04 popovici
152: // Organization of imprts
153: //
154: // Revision 1.3 2003/03/04 11:27:27 popovici
155: // Important refactorization step (march):
156: // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
157: // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
158: // structures
159: //
160: // Revision 1.2 2003/01/17 12:16:57 pschoch
161: // Bugfix in the 'equals' method
162: //
163: // Revision 1.1 2002/10/31 18:26:55 pschoch
164: // Capability of crosscutting Exceptions added to prose.
165: //
|