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

工具类输出当前ApplicationContext所有被装配的类的更多相关文章

  1. 写文件的工具类,输出有格式的文件(txt、json/csv)

    import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io. ...

  2. 创建如下三个类:(People类中的三个方法分别输出一些信息,ChinaPeople 和AmericanPeople类重写父类的三个方法)。

    创建如下三个类:(People类中的三个方法分别输出一些信息,ChinaPeople 和AmericanPeople类重写父类的三个方法). ackage com.chuoji.text01; pub ...

  3. 创建在类路径资源[applicationcontext]中定义名为“工厂”的bean时出错。:在设置bean属性“dataSource”时,无法解析对bean“dataSource”的引用;嵌套异常是org.springframe .beans.factory。BeanCreationException:创建名为“数据源”的bean时出错,该名称是在类路径资源[applicationcontext

    控制台报错: 创建在类路径资源[applicationcontext]中定义名为“工厂”的bean时出错.:在设置bean属性“dataSource”时,无法解析对bean“dataSource”的引 ...

  4. 适用于app.config与web.config的ConfigUtil读写工具类 基于MongoDb官方C#驱动封装MongoDbCsharpHelper类(CRUD类) 基于ASP.NET WEB API实现分布式数据访问中间层(提供对数据库的CRUD) C# 实现AOP 的几种常见方式

    适用于app.config与web.config的ConfigUtil读写工具类   之前文章:<两种读写配置文件的方案(app.config与web.config通用)>,现在重新整理一 ...

  5. arcgis python脚本工具实例教程—栅格范围提取至多边形要素类

    arcgis python脚本工具实例教程-栅格范围提取至多边形要素类 商务合作,科技咨询,版权转让:向日葵,135-4855_4328,xiexiaokui#qq.com 功能:提取栅格数据的范围, ...

  6. 阶段3 2.Spring_03.Spring的 IOC 和 DI_4 ApplicationContext的三个实现类

    如何找到接口的实现类 BeanFactory是核心容器的顶层接口 查看接口的实现类 接下来介绍这三个实现类 把bean.xml复制到桌面上面 运行测试程序 实际更常用ClassPathXmlAppli ...

  7. 基类中定义的虚函数在派生类中重新定义时,其函数原型,包括返回类型、函数名、参数个数、参数类型及参数的先后顺序,都必须与基类中的原型完全相同 but------> 可以返回派生类对象的引用或指针

      您查询的关键词是:c++primer习题15.25 以下是该网页在北京时间 2016年07月15日 02:57:08 的快照: 如果打开速度慢,可以尝试快速版:如果想更新或删除快照,可以投诉快照. ...

  8. 类和对象的创建过程(元类,__new__,__init__,__call__)

    一. type() 1.创建类的两种方式 方式一 class MyClass(object): def func(self,name): print(name) myc = MyClass() pri ...

  9. 【代码笔记】Java常识性基础补充(三)——Java的API及Object类、正则表达式、getTime()方法、DateFormat类、Calendar类

    1.0 Java 的API(API: Application(应用) Programming(程序) Interface(接口)) 2.0 Java API就是JDK中提供给我们使用的类,这些类将底层 ...

随机推荐

  1. Tiops评测

    一.前言 前几天参加了一个新钛云服公有课,才了解到这家公司有发布自己产品Tiops云运维堡垒机. 在此之前有了解过JumpServer,可以完美支持windows和linux server运维管理,以 ...

  2. How tomcat works(深入剖析tomcat)(7) Logger

    How tomcat works (7)日志记录器 总体概述 顾名思义,这一章将的是tomcat的日志记录器组件,比较简单,tomcat提供了几种类型不同的日志记录器,但是所有的日志记录器都需要实现L ...

  3. C#中的WinForm问题——如何设置窗体的大小为超过屏幕显示的最大尺寸?

    今天在学习C#时遇到了一个问题,在此记录下来,留作日后总结复习之用,也分享给有同样问题和困扰的园友. 我手上的电脑是笔记本电脑,屏幕的尺寸大小为1366*768,然而项目所使用的屏幕大小为1920*1 ...

  4. Nginx配置https以及配置说明

    示例 worker_processes 1; events { worker_connections 1024; } http { #均衡负载 upstream demo{ server localh ...

  5. 死磕以太坊源码分析之Fetcher同步

    死磕以太坊源码分析之Fetcher同步 Fetcher 功能概述 区块数据同步分为被动同步和主动同步: 被动同步是指本地节点收到其他节点的一些广播的消息,然后请求区块信息. 主动同步是指节点主动向其他 ...

  6. IdentityServer4系列 | 资源密码凭证模式

    一.前言 从上一篇关于客户端凭证模式中,我们通过创建一个认证授权访问服务,定义一个API和要访问它的客户端,客户端通过IdentityServer上请求访问令牌,并使用它来控制访问API.其中,我们也 ...

  7. PyQt(Python+Qt)学习随笔:QTreeWidgetItem项获取项的父项或子项

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 树型部件QTreeWidget中的QTreeWidgetItem项,可以通过child(int in ...

  8. PyQt(Python+Qt)学习随笔:QAbstractItemView的defaultDropAction属性

    老猿Python博文目录 老猿Python博客地址# 一.概述 defaultDropAction属性用于控制QAbstractItemView及其子类的实例视图中拖放时放下的默认操作.该属性的类型为 ...

  9. 一台电脑上同时安装python2和python3

    被python2的编码问题整的快晕了,python3对编码问题解决的不错 所以想安装下python3,但由于目前企业大多还是用python2,所以不想卸载2,让python2和python3共存. 本 ...

  10. Acwing 734. 能量石

    贪心(微扰) + dp 这道题还是比较难的,前置知识: 贪心的微扰(邻项交换)证法,例题:国王游戏,耍杂技的牛 01背包 算法1:暴力\(O(T * n! * n)\) 可以\(dfs\)全排列枚举所 ...