阅读 springdm in action 笔记--Spring DM extenders
来源:互联网 发布:php团购代码逻辑 编辑:程序博客网 时间:2024/05/23 18:47
本文适合对OSGI有一定了解和基础的研发人员,最初的想法是记录在学习过程中的知识点,以备将来查询。由于我e文水平实在有限,很多地方是直译或者凭着自己的理解来翻译,如果大家发现有不对的地方请指正。另外提供spingdm in action 英文版的下载地址:http://download.csdn.net/source/3002996
META-INF/MANIFEST.MF
通过Spring-Context可以改变spring配置文件的默认路径,多个文件以逗号分隔
通过osgi:service可以发布一个osgi服务,注册到osgi registry中
通过osgi:reference可以引用一个osgi服务到本地bundle中
Spring DM中OSGi 资源定位策略
OSGi search strategyPrefixesDescriptionClass spaceclasspath: classpath*:Search is delegated to the bundle classloader. The bundle itself, imported packages, and required bundles are then scanned usingthe same semantics as the Bundle.getResource method. JAR fileosgibundlejar:Only the bundle itself is scanned, using the same semantics as the Bundle.getEntry method.Bundle spaceosgibundle:The bundle and its fragments (if any) are scanned. Delegates internally to the Bundle.findEntries method. This is Spring DM’s default resource-loading strategy.例子:
wait-for-dependencies:=false 延迟创建application context 知道他依赖的服务都是有效状态
TIMEOUT
如果一个dependency(暂时翻译为依赖)丢失,可能严重危机application context创建,可以通过设置timeout指令来避免application context创建过程被长期挂起,通过下面的设置,application context在尝试创建失败之前,等待他的强制依赖( mandatory dependencies)120秒。timeout仅仅对 mandatory dependencies有效,当设置wait-for-dependencies:false时该指令将被忽略
SPRING DM 事件机制
Application context events inSpring DM
一个简单的办法是实现一个implements OsgiBundleApplicationContextListener 的bean并且发布成OSGI service,Spring
DM 将自动发现它并增加到被管理的监听列表中.见如下代码
在spring配置文件声明该监听
在spring bean中使用OSGI BUNDLE CONTEXT
方法一:实现一个 implementing BundleContextAware的bean并实现setBundleContext方法
方法二:
必须明确的注入bundleContext
简单的web程序结构:
web bundle中类加载机制:
■ Its bundle space (classes in the JAR or WAR and classes from all the associated bundle fragments)
■ Classes from the packages imported with the Import-Package header
■ All the exported classes from bundles appearing in the Require-Bundle header
■ Bundle-Classpath: .,WEB-INF/classes,WEB-INF/lib/libA.jar, WEB-INF/lib/libB.jar
web.xml配置spring环境:
- 阅读 springdm in action 笔记--Spring DM extenders
- spring in action阅读笔记
- 阅读spring in action中文版
- Solr in Action阅读笔记
- 《Unity in Action》阅读笔记
- Spring in action笔记
- Spring in action 笔记
- Spring in action 笔记
- spring In Action 笔记
- spring in action 笔记
- spring-dm-reference.pdf阅读笔记(一)
- spring-dm-reference.pdf阅读笔记(二)
- 《Spring in Action 4》阅读札记
- 《spring in action》笔记(一)
- oculus rift in action 第一章 阅读笔记
- spring ioc 笔记(Spring in action)
- Spring AOP 学习笔记 【Spring in action】
- 【Spring】【笔记】《Spring In Action》第一章 读书笔记
- 使用apt-mirror建立本地ubuntu仓库源
- 使用apt-mirror建立本地ubuntu仓库源
- 狗狗服从性训练之小游戏大学问
- Android不是所有的手机号码,都可以获取。
- Report下拉框的设计
- 阅读 springdm in action 笔记--Spring DM extenders
- mysql rename命令
- 使用apt-mirror构建本地Debian镜像
- 多线程学习系列:(一)前言
- [转]见与不见
- 多线程学习系列:(二)线程基本知识
- 基于反相代理的Web缓存加速——可缓存的CMS系统设计
- 数据库技巧——MySQL十大优化技巧
- 多线程学习系列:(三)线程同步基础上