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 Developers of the Original Code are Angela Nicoara and Gerald Linhofer.
17: // All Rights Reserved.
18: //
19: // Contributor(s):
20: // $Id$
21: // ===============================================================
22: //
23: // (history at the end)
24: //
25:
26: package ch.ethz.prose.crosscut;
27:
28: import java.lang.IllegalAccessException;
29: import java.io.Serializable;
30: import ch.ethz.jvmai.JoinPoint;
31: import java.lang.Object;
32: import java.lang.reflect.InvocationTargetException;
33:
34: ////////////////////////
35: /// ADVICE EXECUTION
36: ////////////////////////
37:
38: /** The <code>CcutAdvice</code> class encapsulates the transformation of the join-point
39: * data (e.g., target, stack parameters) to the types required to execute
40: * the <code>UserDefinedMCSignature</code> of this crosscut. The <code>execute</code>
41: * method does this job.
42: * <p>
43: * An <code>CcutAdvice</code> object contains all the data needed
44: * for the advice constructor <em>invocation</em>.
45: *
46: * @version $Revision$
47: * @author Angela Nicoara
48: * @author Gerald Linhofer
49: */
50: abstract class CcutAdvice implements Serializable {
51: private final ConstructorCut constructorCut;
52: private static final int UNKNOWN = -1;
53:
54: transient protected Object[] stackArgs = null;
55: transient protected int stackArgsLength = UNKNOWN;
56: transient protected ConstructorCutSignaturePattern advice;
57:
58: protected CcutAdvice(ConstructorCut constructorCut,
59: JoinPoint joinPoint, ConstructorCutSignaturePattern advice) {
60: this .advice = advice;
61: Object[] args = joinPoint.getArgs();
62:
63: allocStackArgs(args.length + 1);
64:
65: stackArgs[0] = joinPoint.getThis();
66: for (int i = 0; i < args.length; i++)
67: stackArgs[i + 1] = args[i];
68: this .constructorCut = constructorCut;
69:
70: }
71:
72: // 2. Alllocate local params array
73: protected void allocStackArgs(int expectedLength) {
74: stackArgsLength = expectedLength;
75: stackArgs = new Object[stackArgsLength];
76: }
77:
78: abstract protected void execute() throws IllegalAccessException,
79: InvocationTargetException;
80: }
81:
82: //======================================================================
83: //
84: // $Log$
85: //
|