🍪组件切面
LiteFlow从2.5.0版本开始,开始支持组件的切面功能,你可以通过2种方式进行
# 全局切面
全局切面是针对于所有的组件,进行切面。你只需要做如下实现即可:
@Component
public class CmpAspect implements ICmpAroundAspect {
@Override
public void beforeProcess(NodeComponent cmp) {
YourContextBean context = cmp.getContextBean(YourContextBean.class);
//before business
}
@Override
public void afterProcess(NodeComponent cmp) {
YourContextBean context = cmp.getContextBean(YourContextBean.class);
//after business
}
}
# Aspect的切面
LiteFlow同时也支持了Spring Aspect的切面,你可以用@Aspect标注对任意包,任意规则内的组件进行切面
@Aspect
public class CustomAspect {
@Pointcut("execution(* com.yomahub.liteflow.test.aop.cmp1.*.process())")
public void cut() {
}
@Around("cut()")
public Object around(ProceedingJoinPoint jp) throws Throwable {
//do before business
Object returnObj = jp.proceed();
//do after business
return returnObj;
}
}
帮助我们改善此文档 (opens new window)
上次更新: 2023/08/04, 17:02:03