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: // (histrory at the end)
24: //
25:
26: package ch.ethz.prose.crosscut;
27:
28: import java.lang.IllegalAccessException;
29: import ch.ethz.jvmai.JoinPoint;
30: import java.lang.Object;
31: import java.lang.reflect.InvocationTargetException;
32:
33: /**
34: * An advice execution for an advice action of the form
35: * <code>XXX(ANY thisObj,String a, int b, <em>other non-wildcards..</em>)</code>
36: * <p>
37: * This method redefines the <code>allocStackArgs</code> because it
38: * knows that the number of arguments on the stack is exactly
39: * equal to the number of arguments of the advice method.
40: *
41: * @version $Revision$
42: * @author Angela Nicoara
43: * @author Gerald Linhofer
44: */
45: class WildcardConcreteCcutAdvice extends CcutAdvice {
46: private static final long serialVersionUID = 3256438088669803317L;
47: private final ConstructorCut methodCut;
48:
49: protected void allocStackArgs(int expectedLength) {
50: stackArgsLength = advice.getLength();
51: stackArgs = new Object[stackArgsLength];
52: }
53:
54: WildcardConcreteCcutAdvice(ConstructorCut methodCut, JoinPoint m,
55: ConstructorCutSignaturePattern a) {
56: super (methodCut, m, a);
57: this .methodCut = methodCut;
58: }
59:
60: /** Invoke (reflection) the method of the advice object.
61: * Because of the special signature of the advice, one can
62: * pass the stack arguments to
63: * <code>Method.invoke</code>. the only modification of
64: * the actual stack arguments is to wrap the target into
65: * an <code>ANY</code> object.
66: *
67: */
68: protected void execute() throws IllegalAccessException,
69: InvocationTargetException {
70: ANY adviceThis = new ANY();
71: adviceThis.setObject(stackArgs[0]);
72: stackArgs[0] = adviceThis;
73: advice.methodObj.invoke(methodCut, stackArgs);
74: }
75: }
76:
77: //======================================================================
78: //
79: // $Log$
80: //
|