01: package ch.ethz.prose.crosscut;
02:
03: import java.lang.reflect.Method;
04:
05: import ch.ethz.jvmai.MethodRedefineJoinPoint;
06: import ch.ethz.prose.engine.JoinPointRequest;
07: import ch.ethz.prose.filter.PointCutter;
08:
09: /**
10: * A crosscut that represents method redefinitions.
11: *
12: * @version $Revision$
13: * @author Angela Nicoara
14: * @author Gerald Linhofer
15: */
16: public abstract class MethodRedefineCut extends MethodCut {
17:
18: private static final long serialVersionUID = 3760844579762419253L;
19:
20: protected MethodRedefineCut() throws MissingInformationException {
21: super ();
22: mcutSpecializer = new MethodRedefineCutSpecializer(
23: adviceSignature);
24: }
25:
26: /**
27: * Generate method redefine requests for each declared method in <code>theClass</code>
28: * that matches this crosscut.
29: *
30: * @param theClass class whose methods are checked
31: * @return matching collection of join point requests
32: */
33: protected CrosscutRequest doCreateRequest(Class theClass) {
34: CrosscutRequest result = new CrosscutRequest();
35: Method[] methArray = null;
36:
37: try {
38: methArray = theClass.getDeclaredMethods();
39: } catch (NoClassDefFoundError e) {
40: return result;
41: }
42:
43: for (int i = 0; i < methArray.length; i++) {
44: Class[] params = methArray[i].getParameterTypes();
45: JoinPointRequest crtRequest;
46:
47: crtRequest = requestFactory.createJoinPointRequest(
48: MethodRedefineJoinPoint.KIND, methArray[i]);
49: if (mcutSpecializer.isSpecialRequest(crtRequest))
50: result.add(crtRequest);
51: }
52:
53: return result;
54: }
55:
56: protected PointCutter pointCutter() {
57: throw new RuntimeException("there's no PointCutter for "
58: + this .getClass().getName());
59: }
60:
61: public String toString() {
62: return " Crosscut: 'MethodRedefineCut' \n" + " Advice:"
63: + toStringSignature + "\n" + " PointCutter: "
64: + getSpecializer() + "\n";
65: }
66:
67: }
|