01: //
02: // This file is part of the prose package.
03: //
04: // The contents of this file are subject to the Mozilla Public License
05: // Version 1.1 (the "License"); you may not use this file except in
06: // compliance with the License. You may obtain a copy of the License at
07: // http://www.mozilla.org/MPL/
08: //
09: // 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 are Angela Nicoara and Gerald Linhofer.
17: // All Rights Reserved.
18: //
19: // Contributor(s):
20: // $Id: ConstructorCutSpecializer.java,v 1.1.2.1 2004/08/02 13:08:03 lgerald Exp $
21: // =====================================================================
22: //
23: // (history at end)
24: //
25:
26: package ch.ethz.prose.crosscut;
27:
28: // used packages
29: import java.lang.reflect.Modifier; //import java.lang.reflect.Method;
30: import java.lang.reflect.Constructor;
31: import ch.ethz.prose.engine.JoinPointRequest; //import ch.ethz.prose.engine.MethodExitRequest;
32: import ch.ethz.prose.engine.ConstructorRequest;
33: import ch.ethz.prose.filter.PointCutter;
34: import ch.ethz.jvmai.JoinPointKinds;
35: import ch.ethz.jvmai.CodeJoinPoint;
36: import ch.ethz.jvmai.ConstructorJoinPoint;
37:
38: /**
39: * Class ConstructorCutSpecializer
40: *
41: * @version $Revision$
42: * @author Angela Nicoara
43: */
44: public class ConstructorCutSpecializer extends PointCutter implements
45: JoinPointKinds {
46:
47: private static final long serialVersionUID = 3977017349142229297L;
48:
49: ConstructorCutSignaturePattern adviceSignature;
50:
51: public ConstructorCutSpecializer(
52: ConstructorCutSignaturePattern adviceSignature) {
53: this .adviceSignature = adviceSignature;
54: acceptMask = MASK_ALL_JP;
55: mayFilterStaticallyMask = MASK_METHOD_ENTRY_JP
56: | MASK_METHOD_EXIT_JP;
57: canFilterStaticallyMask = MASK_METHOD_ENTRY_JP
58: | MASK_METHOD_EXIT_JP;
59: }
60:
61: protected boolean doIsSpecialRequest(JoinPointRequest jpr) {
62: Class targetClass = null;
63: Constructor constructorToExecute = null;
64: int methodModifiers = 0;
65: targetClass = ((ConstructorRequest) jpr).getTargetClass();
66: constructorToExecute = ((ConstructorRequest) jpr)
67: .getConstructor();
68:
69: methodModifiers = constructorToExecute.getModifiers();
70:
71: return ((methodModifiers & Modifier.ABSTRACT) != Modifier.ABSTRACT)
72: && ((methodModifiers & Modifier.NATIVE) != Modifier.NATIVE)
73: && adviceSignature.matchesTarget(targetClass)
74: && adviceSignature
75: .matchesParameters(constructorToExecute);
76: }
77:
78: protected boolean doIsSpecialEvent(CodeJoinPoint jpe) {
79: Object target = jpe.getTarget();
80: if (target != null)
81: return adviceSignature.matchesTarget(target.getClass())
82: && adviceSignature
83: .matchesParameters(((ConstructorJoinPoint) jpe)
84: .getConstructor());
85: else
86: return adviceSignature.matchesTarget(jpe.getMethod()
87: .getDeclaringClass())
88: && adviceSignature
89: .matchesParameters(((ConstructorJoinPoint) jpe)
90: .getConstructor());
91: }
92: }
93:
94: //======================================================================
95: //
96: // $Log$
97: //
|