- 浏览: 546330 次
- 性别:
- 来自: 西安
文章分类
- 全部博客 (251)
- UML/RUP/软件工程 (0)
- DDD:领域驱动设计 (1)
- IaaS/Paas/SaaS (1)
- Hadoop/YARN (10)
- PBDP项目 (2)
- OSGi-基础 (7)
- OSGi-Aries (2)
- OSGi-SpringDM (32)
- Oracle/MySQL/SS (8)
- Felix/Equinox/Bnd (14)
- Virgo Server/Gemini (7)
- Weblogic/JBoss/Tomcat (10)
- ActiveMQ (14)
- Camel (1)
- Spring Roo/Eclipse (7)
- Java/JSP/JSF (10)
- Maven (19)
- ESB-Mule (1)
- ESB-ServiceMix (18)
- SOA/SCA/SDO (12)
- WebService/RESTful (17)
- JS/jQuery/ExtJS (4)
- Spring/JPA/MVC (15)
- SpringSecurity (5)
- BPM/jBPM (3)
- Hudson/SVN/CI (0)
- LinuxOS/虚拟化 (25)
- Office/OpenOffice (1)
- 项目管理 (5)
- POI/jFreeChart (1)
最新评论
-
panamera:
请问JMS Transport 发布的webservice 是 ...
CXF 提供的Service Transport-JMS Transpor -
jianyi296:
where is attachment.
CXF WebService Dynamic Client -
hj01kkk:
您好,我用jdbc-user-service为什么每次验证时都 ...
SpringSecurity笔记3-Authenticating Users:Authenticaton Strategy -
wufenglin1231:
你好,我在实现Mapping exceptions to re ...
RESTful 异常处理 -
xchd:
[echo] Project: common
[echo ...
Hive安装配置学习笔记
1. THE SPRING DM EVENT MECHANISM
The available events are Java classes in the org.springframework.osgi.context.event package and
they’re listed below:
(1)OsgiBundleContextRefreshedEvent : Published when an application context is successfully started
or refreshed.
(2)OsgiBundleContextFailedEvent : Published when the creation of an application context fails.
(3)OsgiBundleContextClosedEvent : Published when an application context is closed, usually when
a Spring-powered bundle is stopped.
2. Spring Container Event与SpringDM Event的区别
(1)相同点:Spring DM’s OsgiBundleContextRefreshedEvent is raised when the refresh method of the
ConfigurableApplicationContext interface is called, which is the same point in the lifecycle that the
Spring ContextRefreshedEvent is raised.
(2)不同点:Spring’s standard event system propagates container events to interested beans in the
same application context , whereas Spring DM propagates events outside the containing
application context,possibly betwwen bundles .
(3)Spring’s standard event mechanism:
The Spring lightweight container comes with a built-in event mechanism that allows beans to be
notified of lifecycle steps in their parent application context. Beans interested in receiving events
need to implement the ApplicationListener interface, and the application context will register
them as listeners when it creates them. They will be notified of events such as the application
context starting, stopping, or closing. Spring also allows beans to raise their own events, which
will be propagated the same way as built-in ones. This makes it easy to use an event-driven
approach in Spring applications, which would normally be enough for simple use cases.
3. 注册SpringDM Event监听器
By declaring a bean that implements the OsgiBundleApplicationContextListener interface and then
publishing it as an OSGi service. Spring DM will automatically detect it and add it to the list of
managed listeners. The listener interface declares only one method, onOsgiApplicationEvent, with
the event as the only parameter.
An OSGi bundle application listener:
package com.manning.sdmia.ch04;
import org.springframework.osgi.context.event.OsgiBundleApplicationContextEvent;
import org.springframework.osgi.context.event.OsgiBundleApplicationContextListener;
import org.springframework.osgi.context.event.OsgiBundleContextClosedEvent;
import org.springframework.osgi.context.event.OsgiBundleContextRefreshedEvent;
public class ApplicationContextObserver implements
OsgiBundleApplicationContextListener<OsgiBundleApplicationContextEvent> {
private transient int countRefreshed = 0;
private transient int countClosed = 0;
public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent evt) {
if(evt instanceof OsgiBundleContextRefreshedEvent) {
countRefreshed++;
} else if(evt instanceof OsgiBundleContextClosedEvent) {
countClosed++;
}
}
public int getCountRefreshed() {
return countRefreshed;
}
public int getCountClosed() {
return countClosed;
}
}
Declaring and exporting a listener:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd">
<bean id="observer" class="com.manning.sdmia.ch04.ApplicationContextObserver" />
<osgi:service ref="observer" interface="org.springframework.osgi.context.event.
OsgiBundleApplicationContextListener"/>
</beans>
4. THE WHITEBOARD PATTERN
The whiteboard pattern is more about “event-based” communication, so that’s why we don’t use
the exact same vocabulary as with the observer pattern: observables become event producers,
and observers become listeners or consumers.
In an OSGi environment, event-based communication between components can be implemented
by following the observer pattern , but the dynamic nature of OSGi becomes a real hindrance to
its use. The difficulty mainly consists in maintaining consistent linkages between producers and
consumers, because to provide modular interbundle connections, they should be OSGi services,
and as such, they can disappear or reappear at any moment. A producer would have to maintain
its own collection of listeners, usually with the use of a ServiceTracker . Even if this solution could
work well, it would be cumbersome and error prone.
Another solution might consist of using some kind of middle tier to decouple producers and
listeners. Listeners would register with this middle tier, and producers could retrieve listeners from
it in a totally safe manner. The intricacies we described previously would now be handled by this
middle tier. Luckily for us, this middleware already exists in OSGi, in the shape of the service
registry!
In the whiteboard pattern, each time a producer wants to send an event to its listeners, it
retrieves it from the whiteboard and proceeds with the event dispatch. The collection of listeners
it receives from the registry can be seen as a snapshot of the listeners that are registered at the
moment the event is dispatched. The producer relies on the service registry to correctly maintain
the collection of listeners. The usual way to retrieve listeners is to track them through their
interface with a ServiceTracker and use the getServices method.
发表评论
-
SpringDM笔记31-Testing with OSGi and SpringDM
2011-11-22 10:27 12491. 创建一个SpringDM测试类 SpringD ... -
SpringDM笔记30-OSGi中使用SSL/STL
2011-11-21 11:55 1321SSL:Secure Sockets Layer ... -
SpringDM笔记29-Require-Bundle与Import-Package的区别
2011-11-21 10:31 2245具体可参考:http://www.osgi.org/bl ... -
SpringDM笔记28-OSGi Bundle Activities with Spring-DM
2011-11-17 10:19 1165OSGi框架中也支持搞层次的模块交互:bundles.例如 ... -
SpringDM笔记28-Spring And OSGi:Layers of Integration
2011-11-15 11:00 11801. Application Design:Service和B ... -
SpringDM笔记27-Extending The Stand Extender and Configure
2011-09-02 09:38 8721. -
SpringDM笔记25-Using AJAX frameworks with Spring DM:GWT
2011-09-01 08:53 12041. Using Spring DM with AJAX fr ... -
SpringDM笔记24-Using action-based web frameworks with Spring DM:SpringMVC
2011-08-30 09:33 1481■ Action-based web frameworks ... -
SpringDM笔记23-Using the open EntityManager in view pattern实现延迟加载
2011-08-30 09:27 15711. The open EntityManager in vi ... -
SpringDM笔记22-Transactions Support With SpringDM
2011-08-29 21:24 12151. Spring’s transactional suppo ... -
SpringDM笔记21-Using ORM within OSGi with Spring DM
2011-08-25 10:31 2098Version 1.Object/relational ma ... -
SpringDM笔记20-Using JDBC within OSGi with Spring DM
2011-08-25 09:08 1779The public API for interact ... -
SpringDM笔记19-SpringDM如何处理OSGi应用的动态行为
2011-08-24 08:51 1147ServiceTracker 1. Dealing ... -
SpringDM笔记18-Designing OSGi Enterprise Applications
2011-08-22 11:08 11241. Organizing OSGi components ... -
SpringDM笔记17-Handling Collections of OSGi Services
2011-08-20 09:12 15431.Configuring collections:the l ... -
SpringDM笔记16-处理OSGi服务的动态性:事件
2011-08-19 09:51 17861. Service registration and unr ... -
SpringDM笔记15-通过声明特定的属性注册和引用服务
2011-08-18 11:01 14091. Configuration for registerin ... -
SpringDM笔记14-The thread context classloader 及在OSGi中的运用
2011-08-18 10:40 22531. Using the thread context cla ... -
SpringDM笔记13-OSGi服务注册与引用
2011-08-18 09:28 34531. Combining OSGi services and ... -
SpringDM笔记12-Spring DM’s web Extender运行机制
2011-08-17 11:04 2090SpringDM把一个WAR作为一个Bundle, 其实 ...
相关推荐
spring-osgi-extender-1.2.1.jar spring-osgi-extender-1.2.1-sources.jar spring-osgi-io-1.2.1.jar spring-osgi-io-1.2.1-sources.jar spring-osgi-mock-1.2.1.jar spring-osgi-mock-1.2.1-sources.jar spring-...
开源项目-gomatic-extender.zip,Go toolchain subcommand extender - allows for easily adding to or overriding go subcommands by just adding a go-* executable to the path.
Composer安装程序扩展器composer-installers-extender是的插件,它允许逐个软件包将任何软件包安装到项目中默认vendor目录以外的目录。 该插件扩展了插件,以允许其自定义安装程序处理任何任意软件包类型。 插件具有...
grunt-responsive-images-extender, 使用srcset和尺寸属性扩展HTML图像标签的Grunt插件 grunt-responsive-images-extender使用srcset扩展HTML图像标记,并使用大小属性来利用本机响应图像。正在启动这个插件需要 ...
单片机串入并出源程序,已经调试成功,可以直接使用
A reference on the utility programs included with the TNT DOS-Extender SDK, including: the 386|LINK linker; the 386|LIB librarian; the REBIND binder utility program; the PLSTRIP symbol table strip ...
实测可用
实测可用
安装npm install knockout-promise-extender添加到淘汰赛var ko = require ( 'knockout' ) ;var promiseExtenderFactory = require ( 'knockout-promise-extender' ) ;ko . extenders . promise = ...
提供POP3服务
Extender-Lib is for supporing multiple Pcf8574 boards together in chain with less complexcity of the programmingmex we can connect 8 Pcf8574 together in chain which will give extra 64 pins for ...
A reference on the utility programs included with the TNT DOS-Extender SDK, including: the 386|LINK linker; the 386|LIB librarian; the REBIND binder utility program; the PLSTRIP symbol table strip ...
A reference on the utility programs included with the TNT DOS-Extender SDK, including: the 386|LINK linker; the 386|LIB librarian; the REBIND binder utility program; the PLSTRIP symbol table strip ...
This repository contains example projects that supports different Bluetechnix Blackfin extender boards.
Net Search Extender提供给用户一种使用SQL查询来搜索文档的快速、通用和迅捷的方法。
内含57.4PIN_MAP,包括应用的例程,值得参考。需要57.4引脚定义的速速下载
Minter Explorer Extender服务的官方存储库。 Extender是一项服务,负责从区块链网络播种数据库。 Minter Explorer服务的一部分。 注意:该项目处于积极的开发阶段,请随时向我们发送问题,问题和希望 相关服务: ...
VisendoSMTPExtender,一款免费的POP服务器搭建软件。。。。。。。。。。。。。。。。。。
VisendoSMTPExtender_Plus_x64.msi
org.springframework.osgi.extender-1.2.1.jar