KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > prose > filter > Cflow


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: Cflow.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.filter;
28
29 // used packages
30
import java.util.*;
31 import java.io.*;
32 import ch.ethz.jvmai.JoinPointKinds;
33 import ch.ethz.jvmai.JoinPoint;
34 import ch.ethz.jvmai.CodeJoinPoint;
35 import ch.ethz.prose.engine.JoinPointRequest;
36 import ch.ethz.prose.crosscut.MethodCut;
37
38 /**
39  * Class Cflow XXX
40  *
41  * @version $Revision: 1.1.1.1 $
42  * @author Andrei Popovici
43  */

44 public
45 class Cflow {
46
47  static class BelowPointCutter extends PointCutter implements JoinPointKinds
48     {
49     PointCutter pcut;
50     protected BelowPointCutter(PointCutter pcut)
51     {
52       if (pcut == null)
53         throw new IllegalArgumentException JavaDoc("the argument to Cflow.below cannot be null");
54
55         acceptMask = MASK_ALL_JP;
56         canFilterStaticallyMask = 0;
57         mayFilterStaticallyMask = 0;
58         this.pcut = pcut;
59     }
60
61     protected boolean doIsSpecialRequest(JoinPointRequest jpr)
62     {
63         throw new Error JavaDoc("if we cannot filter statically, we should not be here");
64     }
65
66     protected boolean doIsSpecialEvent(CodeJoinPoint jpe)
67     {
68         try
69         {
70             CodeJoinPoint upper = jpe.getEnclosingJoinPoint();
71             while (upper != null)
72             {
73               if (pcut.isSpecialEvent(upper))
74                 return true;
75
76               upper=upper.getEnclosingJoinPoint();
77             }
78             return false;
79         }
80         catch (ch.ethz.jvmai.JVMAIRuntimeException e)
81           {
82             // System.err.println("hitting the ceiling");
83
return false;
84           }
85     }
86  };
87
88   static class BelowMethodCut extends PointCutter implements JoinPointKinds
89   {
90     MethodCut mcut;
91     protected BelowMethodCut(MethodCut methCut)
92       {
93     if (methCut == null)
94       throw new IllegalArgumentException JavaDoc("the argument to Cflow.below cannot be null");
95     acceptMask = MASK_ALL_JP;
96     canFilterStaticallyMask = 0;
97     mayFilterStaticallyMask = 0;
98     mcut = methCut;
99       }
100
101     protected boolean doIsSpecialRequest(JoinPointRequest jpr)
102       {
103     throw new Error JavaDoc("if we cannot filter statically, we should not be here");
104       }
105
106     protected boolean doIsSpecialEvent(CodeJoinPoint jpe)
107       {
108     try
109       {
110         CodeJoinPoint upper = jpe.getEnclosingJoinPoint();
111         while (upper != null)
112           {
113         if (mcut.equivalentSpecializer().isSpecialEvent(upper))
114           return true;
115
116         upper=upper.getEnclosingJoinPoint();
117           }
118         return false;
119       }
120     catch (ch.ethz.jvmai.JVMAIRuntimeException e)
121         {
122           // System.err.println("hitting the ceiling");
123
return false;
124         }
125       }
126   };
127
128   public static PointCutter below(MethodCut mcut)
129     {
130       return new BelowMethodCut(mcut);
131     }
132
133   public static PointCutter below(PointCutter pcut)
134     {
135       return new BelowPointCutter(pcut);
136     }
137
138     }
139
140
141 //======================================================================
142
//
143
// $Log: Cflow.java,v $
144
// Revision 1.1.1.1 2003/07/02 15:30:51 apopovic
145
// Imported from ETH Zurich
146
//
147
// Revision 1.3 2003/05/06 15:51:35 popovici
148
// Mozilla-ification
149
//
150
// Revision 1.2 2003/05/05 17:57:46 popovici
151
// New cflow below pointcuter added; MethodCut fixed for usage in Cflow below (used not to be initialized once transported over the network)
152
//
153
// Revision 1.1 2003/05/05 13:58:01 popovici
154
// renaming from runes to prose
155
//
156
// Revision 1.2 2003/04/27 13:08:43 popovici
157
// Specializers renamed to PointCutter
158
//
159
// Revision 1.1 2003/04/17 14:52:28 popovici
160
// CflowS renamed to Cflow
161
//
162
// Revision 1.2 2003/04/17 12:49:31 popovici
163
// Refactoring of the crosscut package
164
// ExceptionCut renamed to ThrowCut
165
// McutSignature is now SignaturePattern
166
//
167
// Revision 1.1 2003/04/17 08:47:25 popovici
168
// Important functionality additions
169
// - Cflow specializers
170
// - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
171
// - Transactional capabilities
172
// - Total refactoring of Specializer evaluation, which permits fine-grained distinction
173
// between static and dynamic specializers.
174
// - Functionality pulled up in abstract classes
175
// - Uniformization of advice methods patterns and names
176
//
177
Popular Tags