 鲜花( 0)  鸡蛋( 0)
|
OSGi是Open Service Gateway Initiative的简称,该组织建立于1999年,是一个非赢利机构,旨在建立一个开放的服务规范,为通过网络向设备提供服务建立开放的标准。
) i" V9 D/ f9 r' H$ s: p* gOSGI 规范包括了构建开放的可交付网络服务的各方面,OSGI规范又包括了以下子规范。
, X/ g8 ~; f( E( g8 f7 T- fFramework规范(OSGI核心,提供一个安全的可管理的Java Framework来部署可扩展的Java服务。)
/ t1 r+ U- }/ B) FPackage Admin Service规范(来管理不同的Bundle之间的引用关系。当Bundle更新或者反安装时判断是否有其他的服务正在使用当前的Bundle)& ~' k0 I1 b i2 S2 |' a' F
Start Level规范(定义了启动和停止一个OSGi Service Platform时,不同的Bundles的启动或者停止的先后顺序)3 t. A5 ]$ R: Y4 A/ `/ N
Permission Admin Service规范(Bundle是否许可执行另外的Bundle的代码)' W: q5 h8 A& Q& P5 @2 T, `% t% N
URL Handlers Service规范(怎样注册URL Schema,如何将java.io.InputStream对象转换为特定的Java对象)
* B; A* W, O" C) q4 g- U, l$ q( e! z; ?Log Service规范 (以下略。。。)/ `/ ?- B; Z, u5 r" S
Configuration Admin Service规范
6 w2 a5 n* i. b* e) V2 v3 I2 G! kDevice Access Specification6 M i" v. V* r) o
User Admin Service Specification
; j% Q2 Y L! a& {& n$ i: hIO Connector Service Specification+ u/ B5 ^( V: T, S1 G, F, L$ a) l
Http Service Specification
G* `% y5 z$ hPreference Service Specification
0 k0 S( c6 m2 l; UWire Admin Service Specification8 f1 H2 b, l: t8 [6 x% w: [7 z
XML Parser Service Specification" D1 {9 T: {6 T! v2 \8 H/ W5 S
Metatype Specification& r4 C8 _# w1 p' b
Service Tracker Specification
; v8 G7 u* J a$ z5 YMeasurment and State Specification
' Q- F3 e( _1 S, ]8 APosition Specification0 }! L+ z9 ]8 t- s, m
Execution Environment Specfication% R d1 a `- Z
OSGI Framework* C( c' d2 D" H, }7 k4 Y
Framework是OSGI Service Platform规范的核心组成部分。它提供了一个通用的、安全可管理的Java framework。通过这个Framework可以支持一种叫做bundles的Service application的部署和扩展。
^7 d( I; f& c X$ G4 }( QOSGI兼容设备可以下载并且安装OSGI bundles,也可一当他们不再需要的时候删除。bundles安装后会注册一定数量的Services,并被由同一个Framework下的其他bundles使用。1 F* R8 C$ t6 S) V$ B
在一个动态扩展的的 OSGI环境中,Framework管理bundles的安装和更新。同时也管理bundles和Services之间的依赖关系。
" a4 O9 G- |3 p; ]. \Framework提供给bundle开发者必须的资源来在Java平台上开发,为开发的bundles提供了代码动态加载的功能, 也使得开发者开发、部署一个大规模的Services变的很容易。. p u4 o! P/ b/ I
其 次,Framework为Java bundle开发者提供了简明一致的编程模型。简化了开发部署的复杂性。这个编程模型允许开发者将自己的接口规范绑定到OSGI环境中的Service。 The selection of a specific implementation, optimized for a specific need or from a specific vendor, can thus be deferred to run-time.
7 j l3 l: K6 K一个一致的编程模型帮助开发者可以应付一些可估计的危急错误。Framework将会运行在不同的硬件环境上,但一致的接口确保软件组建可以运行在一致的服务接口上。/ i' S# ~; o$ ^. d! ~- I: G, D
The Bundle Object
: N% { z+ ^; r; G1 r对于每一个安装在OSGI Service Platform的bundle都有一个与之关联的bundle object。一个bundle对象用来管理bundle的生命周期。这项工作通常由Management Agent来做。
: F% u$ R, X2 k: A- @ ?Bundle State8 T7 V; F- V) d" \' ]2 v$ g
bundle有以下状态;
; d0 A$ b$ }5 UINSTALLED – The bundle has been successfully installed. Native code clauses must have been validated.
0 v5 S8 q- |4 e4 DRESOLVED – All Java classes that the bundle needs are available. This state indicates that the bundle is either ready to be started or has stopped.
/ c& c* t6 d$ V3 `5 JSTARTING – The bundle is being started, and the BundleActivato r. start method has been called and has not yet returned.% S7 ]! v+ O! B; ]/ P- o/ c
STOPPING – The bundle is being stopped, and the BundleActivato r. stop method has been called and has not yet returned.8 F) I: q2 c. ~, k4 }, V1 H
ACTIVE – The bundle has successfully started and is running.
4 L {* n C5 nUNINSTALLED – The bundle has been uninstalled. It cannot move into another state.7 D, @3 x- k" s: Y
eclipse 3.0并没有用OSGI替换掉原来的PlugIn机制。它只是做了与标准兼容的工作:给用户提供了一系列的API来访问,在这个过程中,就必须要做一些改 变(比如plugin registry和loading机制)来同OSGI标准完全兼容。最初的Plugin核心只支持静态的扩展,就是说,如果要改变一个已经存在的Plug 就必须重启core,也就是要退出Eclipse并重启。
* V- U0 A1 }* H. P8 Y有很多人问Eclipse为什么要兼容OSGI规范而不是其他的规范呢?+ y4 Y$ p3 O* o- Q4 J
在 Eclipse被捐赠出来以前,Eclipse由OTI来开发,其目标是开发一个嵌入式Java软件的开发平台。互联网上现在仍然由很多的连接指向 Visual Age Micro Edition (VAME). 这也是SWT被构思的一个原因,他们想将SWT使用在嵌入式设备中的用户界面。这种渊源关系解释了当时为什么选择OSGI规范。8 _9 O2 {- E8 K9 }* f7 e: A( O2 P: G
另外一个原因是除了OSGI没有其他的规范。OSGI规范在轻量级服务架构应用方面被广泛的支持。而且OSGI被好多电信业的知名公司和一些其他行业的知名公司所支持。他们需要使用OSGI来同Sun的J2ME来抗衡。 |
|