Spring DM所提供的Bundle监听接口OsgiBundleApplicationContextListener
通过使用Spring DM提供的监听接口,我们可以更好的对服务进行管控,其实该接口也非常简单就能使用上,只要自定义一个类实现OsgiBundleApplicationContextListener接口,实现onOsgiApplicationEvent方法,并将自定义类注册成OSGI服务,通过判断event的事件类型来执行相应逻辑处理,同时也可以获取到当前监听的Bundle,从而达到更深层次的监控,
public class ListenerDemo implements OsgiBundleApplicationContextListener{ @Override
public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent event) { String bundleName = event.getBundle().getSymbolicName(); if (event instanceof OsgiBundleContextRefreshedEvent) {//Spring上下文创建成功事件
System.out.println("服务启动");
}else if (event instanceof OsgiBundleContextClosedEvent) {//Spring上下文销毁事件
System.out.println("服务关闭"); }
}
}<bean id="ListenerDemo" class="com.sample.service.listener.ListenerDemo"></bean> <osgi:service ref="ListenerDemo" interface="org.springframework.osgi.context.event.OsgiBundleApplicationContextListener"/>
Spring DM所提供的Bundle监听接口OsgiBundleApplicationContextListener的更多相关文章
- JavaEE开发之Spring中的事件发送与监听以及使用@Profile进行环境切换
本篇博客我们就来聊一下Spring框架中的观察者模式的应用,即事件的发送与监听机制.之前我们已经剖析过观察者模式的具体实现,以及使用Swift3.0自定义过通知机制.所以本篇博客对于事件发送与监听的底 ...
- Spring ApplicationContext(八)事件监听机制
Spring ApplicationContext(八)事件监听机制 本节则重点关注的是 Spring 的事件监听机制,主要是第 8 步:多播器注册:第 10 步:事件注册. public void ...
- 深入理解Spring的容器内事件发布监听机制
目录 1. 什么是事件监听机制 2. JDK中对事件监听机制的支持 2.1 基于JDK实现对任务执行结果的监听 3.Spring容器对事件监听机制的支持 3.1 基于Spring实现对任务执行结果的监 ...
- spring boot实战(第二篇)事件监听
http://blog.csdn.net/liaokailin/article/details/48186331 前言 spring boot在启动过程中增加事件监听机制,为用户功能拓展提供极大的便利 ...
- spring中的事件发布与监听
点赞再看,养成习惯,微信搜索「小大白日志」关注这个搬砖人. 文章不定期同步公众号,还有各种一线大厂面试原题.我的学习系列笔记. spring事件发布与监听的应用场景 当处理完一段代码逻辑,接下来需要同 ...
- Android绘图监听接口OnPreDrawListener详解
public static interface ViewTreeObserver.OnPreDrawListener 我们先看下API中的定义: 类概述: 为即将绘制视图树时执行的回调函数定义的接口. ...
- Android画图监听接口OnPreDrawListener具体解释
public static interface ViewTreeObserver.OnPreDrawListener 我们先看下API中的定义: 类概述: 为即将绘制视图树时运行的回调函数定义的接口. ...
- node 监听接口
var http = require('http'); var mysql = require('mysql'); var connection = mysql.createConnection({ ...
- Android中Preference的使用以及监听事件分析
在Android系统源码中,绝大多数应用程序的UI布局采用了Preference的布局结构,而不是我们平时在模拟器中构建应用程序时使用的View布局结构,例如,Setting模块中布局.当然,凡事都有 ...
随机推荐
- PS基础学习
1.文件新建 (1).菜单栏新建,快捷键(Ctrl+N) (2).预设的使用--->一般用于网页制作,就选择Web,宽度,高度的单位,网页是像素 (3).分辨率的设置--->电脑网页屏幕分 ...
- Learning How to Learn, Part 1
Jan 8, 2015 • vancexu Learning How to Learn: Powerful mental tools to help you master tough subjects ...
- sql语句:if exists语句使用
') begin print('exists ') end else begin print('no exists ') end go
- asp.net实现断点续传
C# 断点续传原理与实现 在了解HTTP断点续传的原理之前,让我们先来了解一下HTTP协议,HTTP协议是 一种基于tcp的简单协议,分为请求和回复两种.请求协议是由 客户机(浏览器)向服务器(WEB ...
- UVa 10986 - Sending email
题目大意:网络中有n个SMTP服务器,有m条电缆将它们相连,每条电缆传输信息需要一定的时间.现在给出信息的起点和终点,计算所需的最小时间. 有权图上的单源最短路问题(Single-Source Sho ...
- 背景图片等比缩放的写法background-size简写法
1.背景图片或图标也可像img一样给其宽高就能指定其缩放大小了. 比如一个实际宽高36*28的图标,要缩小一半引用进来的写法就是: background:rgba(0, 0, 0, 0) url(&q ...
- python 自动化之路 day 13
本节内容参考博客: http://www.cnblogs.com/wupeiqi/articles/5132791.html http://www.cnblogs.com/wupeiqi/articl ...
- 05 Linux字符驱动---静态注册
1. mycdev.c #include <linux/init.h> #include <linux/module.h> #include <linux/cdev.h& ...
- 怎样看paper 最有效率
thinking more after reading. Don't just read the papers.in addition, at begining, you'd better focus ...
- 1.4.2.5. 测试(Core Data 应用程序实践指南)
测试的方法也很简单: 首先,在AppDelegate.h里面引用CoreDataHelper @property (strong, nonatomic, readonly)CoreDateHelper ...