1.新建个模块,实现Plugin接口(以增加@Service注解支持为例)
public class XPluginImp implements Plugin { @Override public void start(SolonApp app) { Aop.context().beanBuilderAdd(Service.class, (clz, bw, anno) -> { bw.proxySet(BeanProxyImp.global()); Aop.context().beanRegister(bw, "", true); }); } }2.增加配置文件
src/main/resources/META-INF/solon/solon.extend.aspect.properties3.增加配置内容,打包发布即可
solon.plugin=org.noear.solon.extend.aspect.XPluginImp 12、Solon内部的事件总线EventBus的妙用通过事件总线收集异常
//[收集异常] EventBus.push(err); //[订阅异常] EventBus.subscribe(Throwable.class,(event)->{ event.printStackTrace(); }); //或通过SolonApp订阅 app.onEvent(Throwable.class, (err)->{ err.printStackTrace(); }); //或通过组件订阅 @Component public class ErrorListener implements EventListener<Throwable> { @Override public void onEvent(Throwable err) { err.printStackTrace(); } }通过事件总线扩展配置对象
// // 插件开发时,较常见 // SqlManagerBuilder builder = new SqlManagerBuilder(ds); EventBus.push(builder); 附:Solon项目地址gitee: https://gitee.com/noear/solon
github: https://github.com/noear/solon