- 浏览: 545218 次
- 性别:
- 来自: 西安
文章分类
- 全部博客 (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安装配置学习笔记
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); } }
发表评论
-
使用Maven构建JBI组件
2012-08-29 18:06 12091. 配置POM文件 <pluginR ... -
JBI及相关组件理论
2012-08-28 12:42 11011. Java Business Integration(JB ... -
部署JBI组件至Fuse ESB Enterprise Runtime
2012-08-28 10:20 1347JBI Endpoint Cluster ... -
OSGi容器中Bundle之间Asynchronous Communication
2012-07-20 09:41 1637Fuse ESB Enterprise Contai ... -
Fuse ESB Enterprise之OSGi Bunbdle部署模型
2012-07-12 09:49 17141. Building an OSGi Bundle ... -
Fuse ESB Enterprise之WAR部署模型
2012-07-12 09:48 13051. Build a WAR Modifying ... -
Fuse ESB Enterprise之FAB部署模型
2012-07-11 08:13 1593FAB Project是以pom.xml配置文件为主进行该JA ... -
FuseESB Enterprise 系统配置
2012-05-22 15:42 1729Fuse ESB Enterprise 使用Felix 实现的 ... -
FuseESB Enterprise Runtime 配置
2012-05-19 16:46 13920. FuseESB作为系统服务 (1) Ge ... -
FuseESB Enterprise Routing and Integration理论
2012-05-19 12:49 1055Fuse ESB Enterprise的内嵌的routing ... -
FuseESB Enterprise Messaging理论
2012-05-18 15:11 10191. The Embedded Messaging Servi ... -
ServiceMix中部署:WebService和OSGi Service
2012-02-04 22:47 1365部署Web Service 1. 2. 部署OSGi ... -
ServiceMix中部署:JAR和WAR
2012-02-04 14:34 1725部署JAR: 1. Transform a non-OSGi ... -
ServiceMix中部署:OSGi Bundle和Feature
2012-02-04 11:49 4208部署单个Bundle: 1. Hot Deployment ... -
Maven管理ServiceMix工程
2012-02-03 20:50 15041. 添加fusersource respository至se ... -
FuseESB Enterprise理论及架构思想
2012-01-31 12:01 1194官方对FuseESB的定义: Fuse ESB is an ... -
FuseESB Enterprise/ServiceMix安装配置
2012-01-31 10:45 2603ServiceMix安装配置: 1. 安装准备 a ...
相关推荐
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中文
想多前沿技术了解的朋友,一定要看哦.