0
At the moment, we are building a module in Spring Boot that uses a legacy settings, built on top of Spring MVC and has many configurations (XML and classes).
After a few weeks, we were able to make Spring Boot compatible with the legacy settings, but we couldn’t validate if, in fact, Aspectj is working as expected.
And why do I say that?
We observe that during configuration, within the TransactionManagementConfigurationSelector
(in the code below), we are receiving the adviceModes
of PROXY
and ASPECTJ
:
/**
* Returns {@link ProxyTransactionManagementConfiguration} or
* {@code AspectJ(Jta)TransactionManagementConfiguration} for {@code PROXY}
* and {@code ASPECTJ} values of {@link EnableTransactionManagement#mode()},
* respectively.
*/
@Override
protected String[] selectImports(AdviceMode adviceMode) {
switch (adviceMode) {
case PROXY:
return new String[] {AutoProxyRegistrar.class.getName(),
ProxyTransactionManagementConfiguration.class.getName()};
case ASPECTJ:
return new String[] {determineTransactionAspectClass()};
default:
return null;
}
}
This particular case is even more curious, since during debugging we receive twice ASPECTJ and once proxy at the end of the settings. It seems that the Aspectj settings of the legacy are being applied, but something is also configuring the advice mode
Proxy.
After further investigation, we found the originator of the Proxy warning mode, which is the TransactionAutoConfiguration
, more specifically theTransactionAutoConfiguration.EnableTransactionManagementConfiguration.CglibAutoProxyConfiguration.class
.
The application of the following exclusion prevented the advice mode
PROXY was configured in TransactionManagementConfigurationSelector
, but we are not 100% sure that this will not affect the application at some point:
@SpringBootApplication (exclude = TransactionAutoConfiguration.class)
Given the fact that we have only Aspectj configured in our application, and this setting is also applying Proxy, there is a way to validate which mode is being used during a transaction, and if possible, which classes are using Proxy and which are using Aspectj?