关于OSGi

>>>OSGi适合什么场景:
(1).有多个不同版本的库包,都需要被加载到同一JVM中,==>根据类全路径和版本号(组合关键字)创建类==>
(2).不适合用于bundle整个应用,适合用于接入很多包时,做到自动、纠错处理;==>在接入很多包时,有自动、纠错处理的优点
>>>使用OSGi的优势:热部署、动态配置,也就是Karaf所具备的特征中的前两个;
>>>Comparing Java EE with OSGi is like comparing apples and oranges with the additional bonus of not knowing what is what. ==>不能单纯的比较J2EE和OSGi
  ==>类似苹果和橘子的比较,要知道在什么时候用什么东西。谁更适合用于哪种场景
  ==>J2EE聚焦于异构环境和企业级范围的信息系统集成的可扩展、多层业务应用
  ==>OSGi只是一个小范围,通过集成多个独立的代码库到同一个JVM中;
  ==>OSGi是一个容器技术,类似于J2EE技术中的Servlet、JDBC、EJBs、JMS等,不对J2EE有什么影响;
  ==>OSGi目前还不会变为J2EE的规范,至少在JDK8之前。
>>>OSGi框架:Eclipse Equinox, Apache Felix,  Knoplerfish.
>>>Eclipse就是用OSGi框架写的,还有其他的中间件产品和开源产品,包括应用服务器、企业服务总线、IDE也是用OSGi框架的。
>>>Apache Aries ==> 实现了部分OSGi规范的元部件或者组件
>>>Apache Aries ==>提供了企业级OSGi元部件,Aries是对OSGi一些企业级规范的实现,目前包含如下实现:
  (1)Blueprint规范 ==>Blueprint Specification
  (2)JTA事务服务规范 ==>JTA Transaction Service Specification
  (3)JMX管理模型规范==>JMX Management Model Specification
  (4)JNDI服务规范==>JNDI Service Specification
  (5)JPA服务规范==>JPA Service Specification
  (6)服务加载器仲裁规范==>Service Loader Mediator Specification
  (7)子系统服务规范==>Subsystem Service Specification
>>>Blueprint服务是从Spring框架组件模型映射来的,Blueprint Container 规范为OSGi定义了一个依赖性注入(dependency injection)框架
   ,目的是处理OSGi的动态特性,即服务可以在任何时间变得可用和不可用,但blueprint container需要OSGi框架来运行。
>>>OSGi R5或者R4有三大部分规范:Core、Compendium<纲要>、Enterprise
>>>Manifest Headers==>重要属性项如下==>属性值间是逗号隔开,每个属性值中的区分间隔是分号
/////////////////begin////////////
Bundle-Activator: org.apache.felix.cm.impl.ConfigurationManager
Bundle-ManifestVersion: 2
Bundle-Name: Apache Felix Configuration Admin Service
Bundle-SymbolicName: org.apache.felix.configadmin
Bundle-Version: 1.6.0
DynamicImport-Package: org.osgi.service.log; version="1.3"
Embed-Dependency:
Export-Package:
Export-Service:
Import-Package:
Import-Service: org.osgi.service.log.LogService; availability:=optional; multiple:=false
/////////////////end//////////////
>>>一个bundle是一个规则的jar文件,附加的元数据放在MANIFEST文件中。bundle就是jar文件,但必须有MANIFEST文件。

>>>基于OSGi开发,你需要做什么?
(0)选择OSGi框架
(1)编写OSGi bundle ==>最关键的是Manifest文件
  ==>开发环境可以通过Eclipse结合Ant或者Maven
  ==>需要继承OSGi框架中的类或者实现其接口
(2)准备OSGi运行时环境==>karaf
(3)部署这些OSGi bundle

***、What is OSGi ==>OSGi是什么?
>>The dynamic modular system for Java ==>Java领域的动态模块系统
>>Defines a way to create true modules and a way for those==>定义了创建真正模块的方式,定义了通过在运行时进行的模块交互来构建模块化系统的方式
modules to interact at runtime to create a modular system
>>A module: a bundle ==>模块就是bundle,jar+manifest(bundle元数据)
A jar + manifest (bundle metadata)
>>Can be installed, updated, and uninstalled without restarting the JVM==>在不重启JVM的前提下可以安装、升级、卸载模块(bundle)
***、How does OSGi help?==>OSGi是如何起作用?
OSGi helps to break down a complex systems into a collection of
interacting modules ==>OSGi有助于将一个复杂系统切割成一组交互的模块。
>>Modularity ==>模块性
  >>>A bundle can share/hide information at package level ==>一个bundle可以在包级别共享或者隐藏信息;
>>Lifecycle Management ==>生命周期管理
  >>>Separate class loader for each bundle ==>每个bundle的类加载是隔离的;
  >>>A bundle-lifecycle can be managed dynamically==>一个bundle的生命周期可以被动态管理
>>Services ==>服务
  >>>Each bundle provides it's functionality as OSGi services to other bundles==>每个bundle可以作为OSGi服务,将其功能提供给其他bundle。
  >>>Services are simply Java objects that implement a given interface==>服务是实现了指定接口的简单Java对象。
  >>>Implementation is loosely coupled==>实现是松耦合的。
  >>>Bundles reuse a single Java object registered==>Bundle可以重用被注册的单个Java对象
  >>>In VM collaborative SOA model==>在同一个JVM中,可协作的SOA模型
***、A Middleware platform provides;==>中间件平台提供以下能力
>>Integration ==>集成
>>Governance ==>监管
>>Data Services ==>数据服务
>>Business Processes ==>业务流程
>>Connectivity Services ==>连接性服务
>>Identity and Security ==>身份和安全
>>Application Management ==>应用管理
>>API Management ==>API管理
***、OSGi in Middleware==>OSGi在中间件(用处)
>>Each SOA component can be represented by an OSGi bundle==>每一个SOA组件可以通过一个OSGi bundle来表示。
  >>>Application Management ==>应用管理
  >>>Mediation ==>仲裁
  >>>Service Hosting etc. ==>服务属主等等
>>Separation of concern ==> 关注点分离
  >>>Each OSGi bundle to provide a set of well-defined services==>每一个OSGi bundle提供了一组定义好的服务
  >>>Loosely coupled components==>松耦合组件
>>Dynamic loading of modules ==>动态模块加载
  >>>Can extend the system dynamically by installing new bundles==>通过安装新的bundle,能够做到动态扩展系统
  >>>Is supported by an underlying provisioning platform==>通过下层的预配置平台来支撑
***、Carbon: An open-source fully componentized enterprise
middleware platform based on OSGi ==>Carbon是一个基于OSGi的开源的、完全组件化的企业级中间件平台。

***、模块化和版本化是中间件项目的两个核心问题

猜你喜欢

转载自can-do.iteye.com/blog/2245304
今日推荐