埃德蒙顿华人社区-Edmonton China

 找回密码
 注册
查看: 1729|回复: 0

OSGI(简介)

[复制链接]
鲜花(0) 鸡蛋(0)
发表于 2008-8-21 22:15 | 显示全部楼层 |阅读模式
老杨团队,追求完美;客户至上,服务到位!
OSGi是Open Service Gateway Initiative的简称,该组织建立于1999年,是一个非赢利机构,旨在建立一个开放的服务规范,为通过网络向设备提供服务建立开放的标准。
# [, u5 @8 M; [5 V$ [OSGI 规范包括了构建开放的可交付网络服务的各方面,OSGI规范又包括了以下子规范。
( g& C4 }/ W& L) g1 l( ]4 c# lFramework规范(OSGI核心,提供一个安全的可管理的Java Framework来部署可扩展的Java服务。)
6 ]( F9 b  b5 a( i  D0 @# ~* M7 s) EPackage Admin Service规范(来管理不同的Bundle之间的引用关系。当Bundle更新或者反安装时判断是否有其他的服务正在使用当前的Bundle)# c: f. ?5 L2 D- S
Start Level规范(定义了启动和停止一个OSGi Service Platform时,不同的Bundles的启动或者停止的先后顺序), V' @) q* a* z& }- f
Permission Admin Service规范(Bundle是否许可执行另外的Bundle的代码): v! B* X( U0 S7 I& e
URL Handlers Service规范(怎样注册URL Schema,如何将java.io.InputStream对象转换为特定的Java对象)% P' S" t/ c. D: P
Log Service规范 (以下略。。。)
$ A" E" z& u8 p6 c# J  a/ K  MConfiguration Admin Service规范1 F: h3 ~, ?0 K6 r
Device Access Specification/ {1 }* i# Y- F0 O! U$ @
User Admin Service Specification* O/ L8 E, }' z4 J
IO Connector Service Specification; ]4 Y* H) R+ g9 ?& L+ ]
Http Service Specification( F( l( Q( |( F( k
Preference Service Specification
# Z+ p  ~4 p2 u4 U# V: oWire Admin Service Specification7 L2 |& M. C. ?& W- m# V, C
XML Parser Service Specification* {/ ]( |( \8 c6 |: Y2 }
Metatype Specification5 Z1 i, }6 a. ^& u" |& q
Service Tracker Specification. V4 t; v3 n1 F3 V5 b( Z/ d+ p; i6 h
Measurment and State Specification
2 f& T% d! k7 \  D% L6 f- P) YPosition Specification
, I8 s, q% c8 P: Q4 VExecution Environment Specfication4 i" Z; A2 Y1 m- v
OSGI Framework
$ L6 ]: w0 ~( {. C+ X. K5 BFramework是OSGI Service Platform规范的核心组成部分。它提供了一个通用的、安全可管理的Java framework。通过这个Framework可以支持一种叫做bundles的Service application的部署和扩展。
0 N) Q1 Z5 a; [6 i2 MOSGI兼容设备可以下载并且安装OSGI bundles,也可一当他们不再需要的时候删除。bundles安装后会注册一定数量的Services,并被由同一个Framework下的其他bundles使用。
' i. R/ k2 ?* _在一个动态扩展的的 OSGI环境中,Framework管理bundles的安装和更新。同时也管理bundles和Services之间的依赖关系。
. z. }: j9 B: [" RFramework提供给bundle开发者必须的资源来在Java平台上开发,为开发的bundles提供了代码动态加载的功能, 也使得开发者开发、部署一个大规模的Services变的很容易。
$ f% h) L* M$ `; G3 A其 次,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.
* ]; h$ x% M8 h9 s( l一个一致的编程模型帮助开发者可以应付一些可估计的危急错误。Framework将会运行在不同的硬件环境上,但一致的接口确保软件组建可以运行在一致的服务接口上。$ h" I0 {1 T+ d, E. t' Y3 M' e
The Bundle Object
' [  ]& |/ t3 N* I' y6 R对于每一个安装在OSGI Service Platform的bundle都有一个与之关联的bundle object。一个bundle对象用来管理bundle的生命周期。这项工作通常由Management Agent来做。
8 z, C' g: n) |# eBundle State
! I% l8 r2 \9 x/ J7 ?& s8 Z) [bundle有以下状态;
* o2 n6 x! L5 s0 Q* c. l! x0 U; sINSTALLED – The bundle has been successfully installed. Native code clauses must have been validated.
$ o, t' C" s9 u6 q" vRESOLVED – All Java classes that the bundle needs are available. This state indicates that the bundle is either ready to be started or has stopped.
: e$ p* ?& R& ?& S5 q, A5 CSTARTING – The bundle is being started, and the BundleActivato r. start method has been called and has not yet returned.. O0 T8 [1 L7 Q& Y7 @# \. }
STOPPING – The bundle is being stopped, and the BundleActivato r. stop method has been called and has not yet returned.
9 l" ?& J2 m% j( G$ f- D: yACTIVE – The bundle has successfully started and is running.% x4 A; c1 t8 P6 e: h! H5 y. d8 k' Q
UNINSTALLED – The bundle has been uninstalled. It cannot move into another state.5 d' H: Y) t" v; i3 T
eclipse 3.0并没有用OSGI替换掉原来的PlugIn机制。它只是做了与标准兼容的工作:给用户提供了一系列的API来访问,在这个过程中,就必须要做一些改 变(比如plugin registry和loading机制)来同OSGI标准完全兼容。最初的Plugin核心只支持静态的扩展,就是说,如果要改变一个已经存在的Plug 就必须重启core,也就是要退出Eclipse并重启。
2 R0 W1 n" J2 Q# y4 f3 ]有很多人问Eclipse为什么要兼容OSGI规范而不是其他的规范呢?: ^0 L$ q, t# s6 }, M; e
在 Eclipse被捐赠出来以前,Eclipse由OTI来开发,其目标是开发一个嵌入式Java软件的开发平台。互联网上现在仍然由很多的连接指向 Visual Age Micro Edition (VAME). 这也是SWT被构思的一个原因,他们想将SWT使用在嵌入式设备中的用户界面。这种渊源关系解释了当时为什么选择OSGI规范。9 Z* ~# l( Z) k$ R3 o
另外一个原因是除了OSGI没有其他的规范。OSGI规范在轻量级服务架构应用方面被广泛的支持。而且OSGI被好多电信业的知名公司和一些其他行业的知名公司所支持。他们需要使用OSGI来同Sun的J2ME来抗衡。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系我们|小黑屋|手机版|Archiver|埃德蒙顿中文网

GMT-7, 2026-4-10 00:53 , Processed in 0.118357 second(s), 9 queries , Gzip On, APC On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表