编译器扩展

编译器扩展

扩展说明

Java 代码编译器,用于动态生成字节码,加速调用。

扩展接口

org.apache.dubbo.common.compiler.Compiler

扩展配置

自动加载

已知扩展

  • org.apache.dubbo.common.compiler.support.JdkCompiler
  • org.apache.dubbo.common.compiler.support.JavassistCompiler

扩展示例

Maven 项目结构:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxCompiler.java (实现Compiler接口)
  7. |-resources
  8. |-META-INF
  9. |-dubbo
  10. |-org.apache.dubbo.common.compiler.Compiler (纯文本文件,内容为:xxx=com.xxx.XxxCompiler)

XxxCompiler.java:

  1. package com.xxx;
  2. import org.apache.dubbo.common.compiler.Compiler;
  3. public class XxxCompiler implements Compiler {
  4. public Object getExtension(Class<?> type, String name) {
  5. // ...
  6. }
  7. }

META-INF/dubbo/org.apache.dubbo.common.compiler.Compiler:

  1. xxx=com.xxx.XxxCompiler

最后修改 March 2, 2023: Fix alias forward in docs3-v2 (#2342) (f16c1535592)