zoukankan      html  css  js  c++  java
  • 工具类输出当前ApplicationContext所有被装配的类

    package org.springblade.desk.utils;
    import org.springframework.beans.BeansException;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.ApplicationContextAware;
    import org.springframework.stereotype.Component;
    @Component
    public class SpringUtil implements ApplicationContextAware {
    
        /**
         * 当前IOC
         *
         */
        private static ApplicationContext applicationContext;
        /**
         * 设置applicationContext
         */
        @Override
        public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
            this.applicationContext = applicationContext;
        }
    
        /**
         * 从当前IOC获取bean
         */
        public static <T> T getObject(Class<T> clazz){
            return applicationContext.getBean(clazz);
        }
    
        public static void showClass(){
            String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
            for(String beanDefinitionName : beanDefinitionNames){
                System.out.println(beanDefinitionName);
            }
        }
    }
    
    //业务类
    package org.springblade.desk.listener.task;
    import org.flowable.engine.delegate.TaskListener;
    import org.flowable.task.service.delegate.DelegateTask;
    import org.springblade.core.mp.support.Condition;
    import org.springblade.desk.entity.ProcessPurchaseOrder;
    import org.springblade.desk.entity.ProcessPurchaseOrderDetail;
    import org.springblade.desk.service.impl.PurchaseOrderDetailServiceImpl;
    import org.springblade.desk.service.impl.PurchaseOrderServiceImpl;
    import org.springblade.desk.utils.SpringUtil;
    import org.springframework.stereotype.Component;
    import java.util.List;
    
    /**
     * create by Dell on 2020/6/23
     */
    @Component
    public class PurchaseOrderTaskListener implements TaskListener {
        @Override
        public void notify(DelegateTask delegateTask) {
            PurchaseOrderServiceImpl purchaseOrderServiceImpl= SpringUtil.getObject(PurchaseOrderServiceImpl.class);
            PurchaseOrderDetailServiceImpl purchaseOrderDetailServiceImpl= SpringUtil.getObject(PurchaseOrderDetailServiceImpl.class);
            System.out.println("采购订单进入监听事件delegateTask=========================="+delegateTask);
            String processInstanceId = delegateTask.getProcessInstanceId() ;
            ProcessPurchaseOrder entity = new ProcessPurchaseOrder();
            entity.setProcessInstanceId(processInstanceId);
            List<ProcessPurchaseOrder> list = purchaseOrderServiceImpl.list(Condition.getQueryWrapper(entity));
            if(list!=null&&!list.isEmpty()){
                for(ProcessPurchaseOrder bean : list){
                    ProcessPurchaseOrderDetail line = new ProcessPurchaseOrderDetail();
                    line.setOrderNumber(bean.getOrderNumber());
                    List<ProcessPurchaseOrderDetail> lineList = purchaseOrderDetailServiceImpl.list(Condition.getQueryWrapper(line));
                }
            }
            System.out.println("taskListener"+ list.size()+"--------");
        }
    }

    //借鉴=============== https://www.jianshu.com/p/56d5be0dab91
  • 相关阅读:
    重磅!容器集群监控利器 阿里云Prometheus 正式免费公测
    阿里开源 KT Connnect,轻量级云原生测试环境治理平台来啦!
    使用Velero Restic快速完成云原生应用迁移至ACK集群
    Kubernetes 弹性伸缩全场景解析 (一):概念延伸与组件布局
    北京DAY1下午
    洛谷 P3041 [USACO12JAN] Video Game Combos
    Tyvj 1729 文艺平衡树
    bzoj 3238: [AHOI2013]差异
    bzoj 2957: 楼房重建
    bzoj 2660: [Beijing wc2012]最多的方案
  • 原文地址:https://www.cnblogs.com/xianz666/p/13274829.html
Copyright © 2011-2022 走看看