KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > aop > aspectj > annotation > AspectJAdvisorFactory


1 /*
2  * Copyright 2002-2007 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.aop.aspectj.annotation;
18
19 import java.lang.reflect.Method JavaDoc;
20 import java.util.List JavaDoc;
21
22 import org.aopalliance.aop.Advice;
23
24 import org.springframework.aop.Advisor;
25 import org.springframework.aop.aspectj.AspectJExpressionPointcut;
26 import org.springframework.aop.framework.AopConfigException;
27
28 /**
29  * Interface for factories that can create Spring AOP Advisors from classes
30  * annotated with AspectJ annotation syntax.
31  *
32  * @author Rod Johnson
33  * @author Juergen Hoeller
34  * @since 2.0
35  * @see AspectMetadata
36  * @see org.aspectj.lang.reflect.AjTypeSystem
37  */

38 public interface AspectJAdvisorFactory {
39
40     /**
41      * Determine whether or not the given class is an aspect, as reported
42      * by AspectJ's {@link org.aspectj.lang.reflect.AjTypeSystem}.
43      * <p>Will simply return <code>false</code> if the supposed aspect is
44      * invalid (such as an extension of a concrete aspect class).
45      * Will return true for some aspects that Spring AOP cannot process,
46      * such as those with unsupported instantiation models.
47      * Use the {@link #validate} method to handle these cases if necessary.
48      * @param clazz the supposed annotation-style AspectJ class
49      * @return whether or not this class is recognized by AspectJ as an aspect class
50      */

51     boolean isAspect(Class JavaDoc<?> clazz);
52
53     /**
54      * Is the given class a valid AspectJ aspect class?
55      * @param aspectClass the supposed AspectJ annotation-style class to validate
56      * @throws AopConfigException if the class is an invalid aspect
57      * (which can never be legal)
58      * @throws NotAnAtAspectException if the class is not an aspect at all
59      * (which may or may not be legal, depending on the context)
60      */

61     void validate(Class JavaDoc<?> aspectClass) throws AopConfigException;
62
63     /**
64      * Build Spring AOP Advisors for all annotated At-AspectJ methods
65      * on the specified aspect instance.
66      * @param aif the aspect instance factory (not the aspect instance itself
67      * in order to avoid eager instantiation)
68      * @return a list of advisors for this class
69      */

70     List JavaDoc<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory aif);
71
72     /**
73      * Build a Spring AOP Advisor for the given AspectJ advice method.
74      * @param candidateAdviceMethod the candidate advice method
75      * @param aif the aspect instance factory
76      * @param declarationOrderInAspect the declaration order within the aspect
77      * @param aspectName the name of the aspect
78      * @return <code>null</code> if the method is not an AspectJ advice method
79      * or if it is a pointcut that will be used by other advice but will not
80      * create a Spring advice in its own right
81      */

82     Advisor getAdvisor(Method JavaDoc candidateAdviceMethod,
83             MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String JavaDoc aspectName);
84
85     /**
86      * Build a Spring AOP Advice for the given AspectJ advice method.
87      * @param candidateAdviceMethod the candidate advice method
88      * @param pointcut the corresponding AspectJ expression pointcut
89      * @param aif the aspect instance factory
90      * @param declarationOrderInAspect the declaration order within the aspect
91      * @param aspectName the name of the aspect
92      * @return <code>null</code> if the method is not an AspectJ advice method
93      * or if it is a pointcut that will be used by other advice but will not
94      * create a Spring advice in its own right
95      * @see org.springframework.aop.aspectj.AspectJAroundAdvice
96      * @see org.springframework.aop.aspectj.AspectJMethodBeforeAdvice
97      * @see org.springframework.aop.aspectj.AspectJAfterAdvice
98      * @see org.springframework.aop.aspectj.AspectJAfterReturningAdvice
99      * @see org.springframework.aop.aspectj.AspectJAfterThrowingAdvice
100      */

101     Advice getAdvice(Method JavaDoc candidateAdviceMethod, AspectJExpressionPointcut pointcut,
102             MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String JavaDoc aspectName);
103
104 }
105
Popular Tags