KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > runtime > internal > AroundClosure


1 /* *******************************************************************
2  * Copyright (c) 1999-2001 Xerox Corporation,
3  * 2002 Palo Alto Research Center, Incorporated (PARC).
4  * All rights reserved.
5  * This program and the accompanying materials are made available
6  * under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * Xerox/PARC initial implementation
12  * Alex Vasseur wired up for @AJ proceeding
13  * Andy Clement 23-06-06 added extras for @AJ
14  * ******************************************************************/

15
16
17 package org.aspectj.runtime.internal;
18
19 import org.aspectj.lang.ProceedingJoinPoint;
20
21 public abstract class AroundClosure {
22     protected Object JavaDoc[] state;
23
24     // Records with the related joinpoint has a this or a target and whether
25
// either of them are bound in the pointcut. Set in the 'link' call made
26
// at each matching join point... (see pr126167)
27
// bit6 being 1 means the flags haven't been initialized
28
protected int bitflags = 0x100000;
29     protected Object JavaDoc[] preInitializationState;
30
31     public AroundClosure() {
32     }
33     
34     public AroundClosure(Object JavaDoc[] state) {
35         this.state = state;
36     }
37     
38     public int getFlags() {return bitflags;}
39
40     public Object JavaDoc[] getState() {
41       return state;
42     }
43     
44     public Object JavaDoc[] getPreInitializationState() {
45         return preInitializationState;
46     }
47
48     /**
49      * This takes in the same arguments as are passed to the proceed
50      * call in the around advice (with primitives coerced to Object types)
51      */

52     public abstract Object JavaDoc run(Object JavaDoc[] args) throws Throwable JavaDoc;
53
54     /**
55      * This method is called to implicitly associate the closure with the joinpoint
56      * as required for @AJ aspect proceed()
57      */

58     public ProceedingJoinPoint linkClosureAndJoinPoint() {
59         //TODO is this cast safe ?
60
ProceedingJoinPoint jp = (ProceedingJoinPoint)state[state.length-1];
61         jp.set$AroundClosure(this);
62         return jp;
63     }
64
65     /**
66      * This method is called to implicitly associate the closure with the joinpoint
67      * as required for @AJ aspect proceed()
68      */

69     public ProceedingJoinPoint linkClosureAndJoinPoint(int flags) {
70         //TODO is this cast safe ?
71
ProceedingJoinPoint jp = (ProceedingJoinPoint)state[state.length-1];
72         jp.set$AroundClosure(this);
73         this.bitflags = flags;
74         return jp;
75     }
76 }
77
Popular Tags