- 浏览: 1123514 次
- 性别:
- 来自: 火星郊区
博客专栏
-
OSGi
浏览量:0
文章分类
- 全部博客 (695)
- 项目管理 (48)
- OSGi (122)
- java (79)
- Vaadin (5)
- RAP (47)
- mysql (40)
- Maven (22)
- SVN (8)
- 孔雀鱼 (10)
- hibernate (9)
- spring (10)
- css (3)
- 年审 (6)
- ant (1)
- jdbc (3)
- FusionCharts (2)
- struts (4)
- 决策分析 (2)
- 生活 (10)
- 架构设计 (5)
- 破解 (2)
- 狼文化 (4)
- JVM (14)
- J2EE (1)
- 应用服务器 (1)
- 我的链接 (5)
- 数学 (2)
- 报表 (1)
- 百科 (6)
- Flex (7)
- log4j (2)
- PHP (1)
- 系统 (2)
- Web前端 (7)
- linux (6)
- Office (1)
- 安全管理 (5)
- python (2)
- dom4j (1)
- 工作流 (3)
- 养生保健 (4)
- Eclipse (8)
- 监控开发 (1)
- 设计 (3)
- CAS (1)
- ZK (41)
- BluePrint (3)
- 工具 (1)
- SWT (7)
- google (2)
- NIO (1)
- 企业文化 (2)
- Windoes (0)
- RCP (7)
- JavaScript (10)
- UML (1)
- 产品经理 (2)
- Velocity (10)
- C (1)
- 单元测试 (1)
- 设计模式 (2)
- 系统分析师 (2)
- 架构 (4)
- 面试 (2)
- 代码走查 (1)
- MongoDB (1)
- 企业流程优化 (1)
- 模式 (1)
- EJB (1)
- Jetty (1)
- Git (13)
- IPV6 (1)
- JQuery (8)
- SSH (1)
- mybatis (10)
- SiteMesh (2)
- JSTL (1)
- veloctiy (1)
- Spring MVC (1)
- struts2 (3)
- Servlet (1)
- 权限管理 (1)
- Java Mina (1)
- java 系统信息 (6)
- OSGi 基础 (3)
- html (1)
- spring--security (6)
- HTML5 (1)
- java爬虫搜索 (1)
- mvc (3)
最新评论
-
Tom.X:
http://osgia.com/
将web容器置于OSGi框架下进行web应用的开发 -
chenyuguxing:
你好, 为什么我的bundle export到felix工程中 ...
在Apache Felix中运行bundle -
string2020:
<niceManifest>true</ni ...
Bundle Plugin for Maven -
jsonmong:
OSGI,是未来的主流,目前已相当成熟。应用OSGI比较好的, ...
基于OSGi的声明式服务 -
zyhui98:
貌似是翻译过来的,有很少人在linux上做开发吧
如何成为“10倍效率”开发者
OSGi Core定义了一个服务层,提供了一个Bundle之间交互的简单机制,通过注册Java Object 至OSGi service registry。 Blueprint Container
(1) Blueprint Configuration
默认配置文件位于:ProjectDir/src/main/resources/OSGI-INF/blueprint
默认XML文件命名空间:
- <? xml version = "1.0" encoding = "UTF-8" ?>
- < blueprint xmlns = "http://www.osgi.org/xmlns/blueprint/v1.0.0" >
- ...
- </ blueprint >
自定义配置文件地址:
Bundle-Blueprint: lib/account.xml, security.bp, cnf/*.xml
Mandatory dependencies:
OSGi Service 中Dependencies默认是必须的,但可通过设置reference和reference-list元素的availability为optional
来改变这中现象。正常情况下,当Bluepring Container初始化时,通过一定范围的时间来允许Dependencies
Resolve, 该时间么哦人为:5秒,可通过下面的方式自定义:
- Bundle-SymbolicName: org.fusesource.example.osgi-client;
- blueprint.graceperiod: = true ;
- blueprint.timeout: = 10000
(2) Defining a Service Bean
(3) Exporting a Service
1. Exporting with a single interface
- < blueprint xmlns = "http://www.osgi.org/xmlns/blueprint/v1.0.0" >
- < bean id = "savings" class = "org.fusesource.example.SavingsAccountImpl" />
- < service ref = "savings" interface = "org.fusesource.example.Account" />
- </ blueprint >
2. Exporting with multiple interfaces
- < blueprint xmlns = "http://www.osgi.org/xmlns/blueprint/v1.0.0" >
- < bean id = "savings" class = "org.fusesource.example.SavingsAccountImpl" />
- < service ref = "savings" >
- < interfaces >
- < value > org.fusesource.example.Account </ value >
- < value > org.fusesource.example.SavingsAccount </ value >
- </ interfaces >
- </ service >
- </ blueprint >
注意:interface和interfaces不能同时在service元素中使用。
3. Exporting with auto-export
例如:下面的代码中Blueprint将自动注册所有SavingsAccountImpl实现的public接口:
- < blueprint xmlns = "http://www.osgi.org/xmlns/blueprint/v1.0.0" >
- < bean id = "savings" class = "org.fusesource.example.SavingsAccountImpl" />
- < service ref = "savings" auto-export = "interfaces" />
- </ blueprint >
其中auto-export默认值为:disabled,其他可选值为:
interfaces:注册该类实现的所有public的接口;
class-hierarchy:注册该类自己以及他的父类,但不包含Object类;
all-classes:注册该类自己以及他的父类,同时包括该类实现的接口。
4. Setting service properties
- < blueprint xmlns = "http://www.osgi.org/xmlns/blueprint/v1.0.0" >
- < bean id = "savings" class = "org.fusesource.example.SavingsAccountImpl" />
- < service ref = "savings" auto-export = "interfaces" ranking = "10" >
- < service-properties >
- < beans:entry key = "bank.name" value = "HighStreetBank" />
- </ service-properties >
- </ service >
- </ blueprint >
说明:A. 注册的service默认的Properties有:osgi.service.blueprint.compname值为service bean 的id
B. service.ranking 是系统自动设置。
C. 当系统查找服务时返回对个匹配的服务时,默认选择ranking值最高的服务,因此可配置该属性用以服务
之间的区分。
5. Specifying a registration listener
- < blueprint xmlns = "http://www.osgi.org/xmlns/blueprint/v1.0.0" . >
- < bean id = "listenerBean" class = "org.fusesource.example.Listener" />
- < service ref = "savings" auto-export = "interfaces" >
- < registration-listener ref = "listenerBean"
- registration-method = "register" unregistration-method = "unregister" />
- </ service >
- </ blueprint >
- //Java
- package org.fusesource.example;
- public class Listener {
- public void register(Account service, java.util.Map serviceProperties) {
- }
- public void unregister(Account service, java.util.Map serviceProperties) {
- }
- }
说明:register和unregister方法的参数,第一个参数可以是service class或service class 实现的接口,因为该
参数包含service instance, 如果该service bean 被声明为property, 在注册的时候是没有service instance可用
的,因此此时该参数的值为null.
第二个参数可以是java.util.Map或java.util.Dictionary,这个Map包含service 注册时的Properties.
(4) Importing a Service
使用reference和reference-list元素Import Service, 两者之间的区别是:reference用于访问stateless service,
而reference-list用于访问stateful service.
1. Matching by interface (stateless)
- < blueprint xmlns = "http://www.osgi.org/xmlns/blueprint/v1.0.0" >
- < reference id = "savingsRef" interface = "org.fusesource.example.SavingsAccount" />
- < bean id = "client" class = "org.fusesource.example.client.Client" >
- < property name = "savingsAccount" ref = "savingsRef" />
- </ bean >
- </ blueprint >
- package org.fusesource.example.client;
- import org.fusesource.example.SavingsAccount;
- public class Client {
- SavingsAccount savingsAccount;
- // Bean properties
- public SavingsAccount getSavingsAccount() {
- return savingsAccount;
- }
- public void setSavingsAccount(SavingsAccount savingsAccount) {
- this .savingsAccount = savingsAccount;
- }
- }
2. Matching by interface (stateful)
- < blueprint xmlns = "http://www.osgi.org/xmlns/blueprint/v1.0.0" >
- < reference-list id = "savingsListRef"
- interface = "org.fusesource.example.SavingsAccount" />
- < bean id = "client" class = "org.fusesource.example.client.Client" >
- < property name = "savingsAccountList" ref = "savingsListRef" />
- </ bean >
- </ blueprint >
- package org.fusesource.example.client;
- import org.fusesource.example.SavingsAccount;
- public class Client {
- java.util.List<SavingsAccount> accountList;
- // Bean properties
- public java.util.List<SavingsAccount> getSavingsAccountList() {
- return accountList;
- }
- public void setSavingsAccountList(java.util.List<SavingsAccount> accountList) {
- this .accountList = accountList;
- }
- }
3. Matching service properties with a filter
- < reference id = "savingsRef" interface = "org.fusesource.example.SavingsAccount" filter = "(bank.name=HighStreetBank)" />
- < reference-list id = "savingsRef" interface = "org.fusesource.example.SavingsAccount" filter = "(bank.name=HighStreetBank)" />
4. Specifying whether mandatory or optional
默认值:mandatory
- < reference id = "savingsRef" interface = "org.fusesource.example.SavingsAccount" availability = "mandatory" />
5. Specifying a reference listener
- < blueprint xmlns = "http://www.osgi.org/xmlns/blueprint/v1.0.0" >
- < reference id = "savingsRef" interface = "org.fusesource.example.SavingsAccount" >
- < reference-listener bind-method = "onBind"
- unbind-meth od = "onUnbind" >
- < bean class = "org.fusesource.example.client.Listener" />
- </ reference-listener >
- </ reference >
- < bean id = "client" class = "org.fusesource.example.client.Client" >
- < property name = "savingsAcc" ref = "savingsRef" />
- </ bean >
- </ blueprint >
- package org.fusesource.example.client;
- import org.osgi.framework.ServiceReference;
- public class Listener {
- public void onBind(ServiceReference ref) {
- System.out.println("Bound service: " + ref);
- }
- public void onUnbind(ServiceReference ref) {
- System.out.println("Unbound service: " + ref);
- }
-
}
发表评论
-
关于Felix Log Service
2012-12-07 16:44 1515OSGi服务纲要规范中定义了服务于OSGi平台的通用日志服 ... -
Maven 3 Felix 4 Eclipse 的搭建与部署(部分转载自别人文章)
2012-10-18 10:24 19924.1.开发环境搭建 4.2开发工具 Maven 3 F ... -
【绝对路径】OSGi环境中获取Plugin/Bundle中文件资源的绝对路径
2012-10-08 10:53 2374摘要:在进行Eclipse RCP开发的过程中,需要使用一 ... -
OpenCore:基于OSGi开发纯插件体系结构的WEB应用程序
2012-09-21 17:46 1376随着OSGi/Equinox逐渐成为Java EE服务端的基础 ... -
OSGi技术在Java Web开发中的应用
2012-09-20 11:26 1367随着 Java SE 对模块化功能原生支持的一再推迟(据最 ... -
OSGI典型的应用案例
2012-09-20 11:26 1570OSGI典型的应用案例主要有两个:分别是Eclipse和BMW ... -
OSGi特点
2012-09-20 11:26 12091、JRE版本无关性。虽然Java一直被人们认为是“Write ... -
OSGI与JMX 的关系
2012-09-19 17:09 1018不过重点是: JMX 本来设计的用途就只为了管理,我们不 ... -
在equinox环境开发web应用的"利器" -- registerResources()方法 详解
2012-09-19 17:07 1192registerResources()方法详解 1、简介 ... -
在equinox环境开发web应用的"利器" -- 序
2012-09-19 17:05 1325在equinox环境中开发web应用必须要借助一些工具包提供的 ... -
equinox环境下web应用资源的部署
2012-09-19 17:04 1268osgi的equinox实现环境下,web服务器和web应用都 ... -
OSGi产生的背景--在繁荣的混乱之中走出困惑
2012-09-19 16:58 1118软件的复杂性正在以惊 ... -
将web容器置于OSGi框架下进行web应用的开发
2012-09-16 14:26 3487将web容器置于OSGi框架下,其实就是将web容器做成OSG ... -
在Eclipse中开发OSGi Bundle
2012-09-16 14:26 1291Eclipse为开发OSGI Bundle提供了良好的支持,它 ... -
【第一代服务注册形式】 - 将一个Bundle注册为服务
2012-09-14 10:09 11081、创建业务接口类及其实现类 Java代码 ... -
Declarative Services规范简介及应用
2012-09-14 10:08 1372Declarative Services 是一 ... -
用FileInstall管理Bundle的动态安装、启动、卸载
2012-09-14 10:07 12971、文件目录如下: F:\study_osgi ... -
服务工厂 - Bundle消费者返回不同的服务对象
2012-09-14 10:03 1180一般情况下,服务对象在注册后,任何其它的Bundle在请求 ... -
服务跟踪(ServiceTracker)
2012-09-14 09:58 1127当多个Bundle使用同一 ... -
OSGI 中嵌入 Http 服务器的运行环境
2012-07-31 13:44 3016Eclipse 4.2 OSGI 依赖的Bundle: or ...
相关推荐
osgi多个bundle之间读取同一配置文件,需要单独添加一个用来读取配置文件的bundle
OSGI bundle 在线用户管理 邮件发送
新版的tomcat融合OSGI容器程序,老版的不好使,自己改了下
osgi发布http服务的各种bundle,各种jar包,全全全~非常好用的技术包 包括:org.eclipse.equinox.http_1.0.0.v20060601a.jar org.eclipse.equinox.ds_1.0.0.v20060601a.jar org.eclipse.equinox.servlet.api_1.0.0...
OSGi with CAR-Bundle.ppt
给出了可用插件bridge和一个可用osgi例子,可以帮助学习osgi的同学学习部署osgi程序到tomcat中。
NULL 博文链接:https://salever.iteye.com/blog/1474694
示例源码工程 博文链接:https://longstudio.iteye.com/blog/1955587
基于 equinox 的 OSGI 运行BUNDLE例子,已包含 ECLIPSE 下的OSGI平台包,按步骤运行即可。 当然,设置JAVA_HOME,及BIN环境变量运行JAVAC 就不用说了 ^-^
OSGi捆绑包状态Maven插件 总览 OSGi容器的远程捆绑软件状态检查器。 请参阅以获取完整文档。 版本控制 遵循准则。
osgiBundleUtilityApplication 实用程序应用程序,用于查看OSGi容器中导出的软件包及其关联的分发包。
OSGi与Web容器的整合
blueprint-osgi-bundle
基于osgi整合ssm框架开发web项目,使用ssm注解的方式开发,缺少两个jsp文件,能运行
OSGi排行榜显示如何将OSGi用作Web服务平台。 使用蓝图,声明式服务,元类型服务,Redis和Apache CXF演示OSGi的各个方面。 Apache Karaf用作OSGi运行时(提供了Jedis的Shell扩展和Karaf的功能)。入门安装并创建要...
osgi在web容器中部署的例子,可以部署在tomcat中。
编译 mvn软件包将在目标中生成捆绑罐 跑步 将捆绑罐复制到OSGI容器,例如Felix或Faraf ...
osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍
OSGi 中文版 中文 OSGi中文OSGi 中文版 中文 OSGi中文OSGi 中文版 中文 OSGi中文OSGi 中文版 中文 OSGi中文OSGi 中文版 中文 OSGi中文OSGi 中文版 中文 OSGi中文OSGi 中文版 中文 OSGi中文OSGi 中文版 中文 OSGi中文
想多前沿技术了解的朋友,一定要看哦.