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
  • 相关阅读:
    Tomcat
    mybatis xml参数传递详解
    windows zookeeper集群
    @RequestParam和@RequestBody区别
    nginx学习
    先冒泡,再使用vector
    有a,b,c,d 4个球,分别出现的概率是10%,20%,30%,40%,要求编写RunDemo,每调用一次函数RunDemo,就按上面的概率出现球。
    字符串右移
    编写程序输入实现123->321
    计算机网络(一)
  • 原文地址:https://www.cnblogs.com/xianz666/p/13274829.html
Copyright © 2011-2022 走看看