View Javadoc

1   /***************************************************************************************
2    * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved.                 *
3    * http://aspectwerkz.codehaus.org                                                    *
4    * ---------------------------------------------------------------------------------- *
5    * The software in this package is published under the terms of the LGPL license      *
6    * a copy of which has been included with this distribution in the license.txt file.  *
7    **************************************************************************************/
8   package org.codehaus.aspectwerkz.aspect;
9   
10  import org.codehaus.aspectwerkz.CrossCuttingInfo;
11  import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
12  
13  import java.lang.reflect.Method;
14  
15  /***
16   * Interface for that all aspect container implementations must implement.
17   * 
18   * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér </a>
19   */
20  public interface AspectContainer {
21      /***
22       * Invokes the advice method on a per JVM basis.
23       * 
24       * @param methodIndex the method index
25       * @param joinPoint the join point
26       * @return the result from the method invocation
27       */
28      Object invokeAdvice(int methodIndex, JoinPoint joinPoint) throws Throwable;
29  
30      /***
31       * Invokes the advice method on a per JVM basis.
32       *
33       * @param methodIndex the method index
34       * @param joinPoint the join point
35       * @param methodToArgsIndexes
36       *
37       * @return the result from the method invocation
38       */
39      Object invokeAdvice(int methodIndex, JoinPoint joinPoint, int[] methodToArgsIndexes) throws Throwable;
40  
41      /***
42       * Returns a specific advice by index.
43       * 
44       * @param index the index
45       * @return the advice
46       */
47      Method getAdvice(int index);
48  
49      /***
50       * Creates a new perJVM cross-cutting instance, if it already exists then return it.
51       * 
52       * @return the cross-cutting instance
53       */
54      Object createPerJvmAspect();
55  
56      /***
57       * Creates a new perClass cross-cutting instance, if it already exists then return it.
58       * 
59       * @param callingClass
60       * @return the cross-cutting instance
61       */
62      Object createPerClassAspect(Class callingClass);
63  
64      /***
65       * Creates a new perInstance cross-cutting instance, if it already exists then return it.
66       * 
67       * @param callingInstance
68       * @return the cross-cutting instance
69       */
70      Object createPerInstanceAspect(Object callingInstance);
71  
72      /***
73       * Creates a new perThread cross-cutting instance, if it already exists then return it.
74       * 
75       * @param thread the thread for the aspect
76       * @return the cross-cutting instance
77       */
78      Object createPerThreadAspect(Thread thread);
79  
80      /***
81       * Returns the cross-cutting info.
82       * 
83       * @return the cross-cutting info
84       */
85      CrossCuttingInfo getCrossCuttingInfo();
86  
87      /***
88       * Attach the introduction container to this aspect container to mirror the "aspect contains 0-n introduction"
89       * 
90       * @param name of the introduction
91       * @param introContainer introduction container
92       */
93      void addIntroductionContainer(String name, IntroductionContainer introContainer);
94  
95      /***
96       * Returns the introduction container of given name (introduction name) or null if not linked.
97       * 
98       * @param name of the introduction
99       * @return introduction container
100      */
101     IntroductionContainer getIntroductionContainer(String name);
102 }