Add support for @Transactional in native images
This commit introduces a TransactionBeanRegistrationAotProcessor in charge of creating the required proxy and reflection hints when @Transactional is detected on beans. It also refines DefaultAopProxyFactory to throw an exception when a subclass-based proxy is created in native images since that's unsupported for now (see gh-28115 related issue). Closes gh-28717
This commit is contained in:
@@ -54,8 +54,7 @@ public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
|
||||
|
||||
@Override
|
||||
public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException {
|
||||
if (!NativeDetector.inNativeImage() &&
|
||||
(config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config))) {
|
||||
if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) {
|
||||
Class<?> targetClass = config.getTargetClass();
|
||||
if (targetClass == null) {
|
||||
throw new AopConfigException("TargetSource cannot determine target class: " +
|
||||
@@ -64,6 +63,9 @@ public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
|
||||
if (targetClass.isInterface() || Proxy.isProxyClass(targetClass) || ClassUtils.isLambdaClass(targetClass)) {
|
||||
return new JdkDynamicAopProxy(config);
|
||||
}
|
||||
if (NativeDetector.inNativeImage()) {
|
||||
throw new AopConfigException("Subclass-based proxies are not support yet in native images");
|
||||
}
|
||||
return new ObjenesisCglibAopProxy(config);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user