将ProxyCompiler类标为废弃,并替换为AsgcCompiler实现

This commit is contained in:
aoshiguchen
2022-09-10 12:40:46 +08:00
parent 1aabca969e
commit b5bcaeddc0
2 changed files with 4 additions and 11 deletions
@@ -21,6 +21,7 @@
*/ */
package fun.asgc.neutrino.core.aop.proxy; package fun.asgc.neutrino.core.aop.proxy;
import fun.asgc.neutrino.core.aop.compiler.AsgcCompiler;
import fun.asgc.neutrino.core.base.GlobalConfig; import fun.asgc.neutrino.core.base.GlobalConfig;
import fun.asgc.neutrino.core.util.*; import fun.asgc.neutrino.core.util.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -38,7 +39,7 @@ public class AsgcProxyFactory implements ProxyFactory {
private static final String SYMBOLIC = "AsgcProxy$$"; private static final String SYMBOLIC = "AsgcProxy$$";
private static final String classNameTemplate = "%s" + SYMBOLIC + "%s"; private static final String classNameTemplate = "%s" + SYMBOLIC + "%s";
private static AtomicLong proxyClassCounter = new AtomicLong(); private static AtomicLong proxyClassCounter = new AtomicLong();
private ProxyCompiler compiler = new ProxyCompiler(); private AsgcCompiler compiler = new AsgcCompiler();
private ProxyClassLoader classLoader = new ProxyClassLoader(); private ProxyClassLoader classLoader = new ProxyClassLoader();
@Override @Override
@@ -85,20 +86,11 @@ public class AsgcProxyFactory implements ProxyFactory {
if (GlobalConfig.isPrintGeneratorCode()) { if (GlobalConfig.isPrintGeneratorCode()) {
log.debug("类:{} 的代理类源码:\n{}", targetType.getName(), sourceCode); log.debug("类:{} 的代理类源码:\n{}", targetType.getName(), sourceCode);
} }
Class<P> retClass = compile(proxyClass); Class<P> retClass = (Class<P>)compiler.compile(proxyClass.getPkg(), proxyClass.getName(), proxyClass.getSourceCode());
P obj = retClass.newInstance(); P obj = retClass.newInstance();
return obj; return obj;
} }
private <T> Class<T> compile(ProxyClass proxyClass) throws ClassNotFoundException {
// if (SystemUtil.isStartupFromJar() || GlobalConfig.isSaveGeneratorCode()) {
// compiler.compileToFile(proxyClass);
// return (Class<T>)classLoader.loadProxyClass(proxyClass);
// }
compiler.compile(proxyClass);
return (Class<T>)classLoader.loadProxyClass(proxyClass);
}
private String generateClassName(Class<?> clazz) { private String generateClassName(Class<?> clazz) {
return String.format(classNameTemplate, clazz.getSimpleName(), proxyClassCounter.incrementAndGet()); return String.format(classNameTemplate, clazz.getSimpleName(), proxyClassCounter.incrementAndGet());
} }
@@ -40,6 +40,7 @@ import java.util.stream.Collectors;
* @date: 2022/6/24 * @date: 2022/6/24
*/ */
@Slf4j @Slf4j
@Deprecated
public class ProxyCompiler { public class ProxyCompiler {
/** /**
* 收集编译过程信息 * 收集编译过程信息