FlowInitializingBean.java 944 B

1234567891011121314151617181920212223242526272829
  1. package com.fjhx.flow.config;
  2. import com.fjhx.flow.core.FlowBean;
  3. import com.fjhx.flow.core.FlowDelegate;
  4. import lombok.extern.slf4j.Slf4j;
  5. import org.springframework.beans.BeansException;
  6. import org.springframework.beans.factory.config.BeanPostProcessor;
  7. import org.springframework.context.annotation.Configuration;
  8. /**
  9. * 利用spring后置处理器注册流程代理对象
  10. */
  11. @Slf4j
  12. @Configuration
  13. public class FlowInitializingBean implements BeanPostProcessor {
  14. @Override
  15. public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
  16. if (bean instanceof FlowDelegate) {
  17. FlowDelegate flowDelegate = (FlowDelegate) bean;
  18. FlowBean.addBean(flowDelegate.getFlowKey(), beanName);
  19. log.info("流程:{} 注册成功", flowDelegate.getFlowKey());
  20. }
  21. return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
  22. }
  23. }