Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【设计文档】模块加载的勾子 #2

Open
gaohanghbut opened this issue Jul 15, 2017 · 0 comments
Open

【设计文档】模块加载的勾子 #2

gaohanghbut opened this issue Jul 15, 2017 · 0 comments

Comments

@gaohanghbut
Copy link
Owner

gaohanghbut commented Jul 15, 2017

为什么需要勾子

框架本身不可能满足所有场景,想要做到不修改框架本身的代码也能满足很多特征需求,可以提供
勾子在框架的核心流程中做拦截操作。例如mybatis的拦截器,spring的PostBeanProcessor。

modular-spring中的勾子接口

modular-spring提供了以下两个勾子接口:

public interface ModuleLoadListener {

  /**
   * 在调用{@link ModuleApplicationContext#refresh()}前调用
   */
  void beforeModuleLoad(ModuleConfig moduleConfig, ModuleApplicationContext applicationContext);

  /**
   * 在调用{@link ModuleApplicationContext#refresh()}后调用
   */
  void afterModuleLoad(ModuleConfig moduleConfig, ModuleApplicationContext applicationContext);
}
public interface ApplicationStartupCallback {
  void action();
}

ModuleLoadListener提供了在一个模块初始化前和初始化后的处理逻辑的调用能力,而ApplicationStartupCallback提供了应用启动后的回调能力。

@gaohanghbut gaohanghbut changed the title 模块加载的勾子 【设计文档】模块加载的勾子 Jul 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant