File tree 1 file changed +23
-3
lines changed
spring-aop/src/main/java/org/springframework/aop/aspectj/annotation
1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change 28
28
import org .springframework .beans .factory .aot .BeanFactoryInitializationCode ;
29
29
import org .springframework .beans .factory .config .ConfigurableListableBeanFactory ;
30
30
import org .springframework .lang .Nullable ;
31
+ import org .springframework .util .ClassUtils ;
31
32
32
33
/**
33
34
* {@link BeanFactoryInitializationAotProcessor} implementation responsible for registering
34
35
* hints for AOP advices.
35
36
*
36
37
* @author Sebastien Deleuze
38
+ * @author Stephane Nicoll
37
39
* @since 6.0.11
38
40
*/
39
41
class AspectJBeanFactoryInitializationAotProcessor implements BeanFactoryInitializationAotProcessor {
40
42
43
+ private static final boolean aspectJPresent = ClassUtils .isPresent (
44
+ "org.aspectj.lang.annotation.Pointcut" , AspectJBeanFactoryInitializationAotProcessor .class .getClassLoader ());
45
+
41
46
@ Nullable
42
47
@ Override
43
48
public BeanFactoryInitializationAotContribution processAheadOfTime (ConfigurableListableBeanFactory beanFactory ) {
44
- BeanFactoryAspectJAdvisorsBuilder builder = new BeanFactoryAspectJAdvisorsBuilder (beanFactory );
45
- List <Advisor > advisors = builder .buildAspectJAdvisors ();
46
- return advisors .isEmpty () ? null : new AspectContribution (advisors );
49
+ if (aspectJPresent ) {
50
+ return AspectDelegate .processAheadOfTime (beanFactory );
51
+ }
52
+ return null ;
53
+ }
54
+
55
+ /**
56
+ * Inner class to avoid a hard dependency on AspectJ at runtime.
57
+ */
58
+ private static class AspectDelegate {
59
+
60
+ @ Nullable
61
+ private static AspectContribution processAheadOfTime (ConfigurableListableBeanFactory beanFactory ) {
62
+ BeanFactoryAspectJAdvisorsBuilder builder = new BeanFactoryAspectJAdvisorsBuilder (beanFactory );
63
+ List <Advisor > advisors = builder .buildAspectJAdvisors ();
64
+ return advisors .isEmpty () ? null : new AspectContribution (advisors );
65
+ }
66
+
47
67
}
48
68
49
69
You can’t perform that action at this time.
0 commit comments