My question is about Spring AspectJ mode and especially its inclusion for:
- Transaction management
- Caching
1) I noticed that to enable AspectJ mode for transaction management I needed to do the following:
@Configuration @EnableTransactionManagement(mode = AdviceMode.ASPECTJ)
2) While to use AspectJ mode for caching, it seems you need:
-Put the following phrase into the Tomcat lib java directory: org.springframework:spring-instrument-tomcat -Add the following line to Tomcat server.xml:
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
- add the following configuration:
@Configuration @EnableLoadTimeWeaving(aspectjWeaving = AspectJWeaving.ENABLED) public class LoadTimeWeavingConfiguration implements LoadTimeWeavingConfigurer { @Override public LoadTimeWeaver getLoadTimeWeaver() { return new ReflectiveLoadTimeWeaver(); } }
- finally, you can use AspectJ mode as follows:
@Configuration @EnableCaching(mode = AdviceMode.ASPECTJ)
Is it correct? If so, why is AspectJ-mode caching different from AspectJ transaction support?
source share