package com.fjhx.flow.config; import com.fjhx.flow.core.FlowBean; import com.fjhx.flow.core.FlowDelegate; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.annotation.Configuration; /** * 利用spring后置处理器注册流程代理对象 */ @Slf4j @Configuration public class FlowInitializingBean implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof FlowDelegate) { FlowDelegate flowDelegate = (FlowDelegate) bean; FlowBean.addBean(flowDelegate.getFlowKey(), beanName); log.info("流程:{} 注册成功", flowDelegate.getFlowKey()); } return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName); } }