火龙果软件-OSGi开发之OSGi概念汇编资料_第1页
火龙果软件-OSGi开发之OSGi概念汇编资料_第2页
火龙果软件-OSGi开发之OSGi概念汇编资料_第3页
火龙果软件-OSGi开发之OSGi概念汇编资料_第4页
火龙果软件-OSGi开发之OSGi概念汇编资料_第5页
已阅读5页,还剩21页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、OSGi Development共二十六页目录(ml)OSGi概念(ginin)The History of OSGiProgram design key pointModularityCohesionCouplingEncapsulationGranularityServiceOSGi featuresOSGi LayerOSGi Basic ConceptModularityDynamicExtensionOSGi implementaionOSGi开发共二十六页OSGi的发展(fzhn)轨迹UPnPInitial ProvisioningName SpaceJiniStart Level

2、IO ConnectorWire AdminXML ParserMeasurement & StatePositionExecution Env.Application ManagerMIDP ContainerSigned BundlesDeclarative ServicesPower ManagementDevice ManagementSecurity PoliciesUPnP ExporterDiagnostics/MonitoringFramework LayeringInitial ProvisioningUPnP2000200120032005R1R2R3R4Home Auto

3、mation VehicleMobileFrameworkHttpLogDevice AccessPackage AdminConfiguration AdminPermission AdminUser AdminPreferencesMetaTypeService Tracker1999年3月,OSGi(Open Services Gateway initiative)联盟(非盈利性质)成立目标 :建立家庭网关,并通过互联网向家庭网络提供(tgng)各种服务。以支持嵌入式装置为主的家庭网关软件。(例如通过web页面控制咖啡机等);2000年发布OSGi Service Platform V

4、1.02001年发布V 2.02003年发布V 3.0 加入支持Java手机功能2004年 Eclipse 3.x核心改用OSGi, 开始有大量的开源团体投入研究2005年发布V 4.02007年发布V 4.1共二十六页Who use OSGiEclipse V3.0采用OSGi,使得(sh de)OSGi成功进入Java企业应用领域,并成为其中重要一员;推出了OSGi R4 RI:Equinox IBM Websphere RSABEA microServices, All BEA product will be based on microServicesApache Struts 2Sp

5、ring Spring-OSGiSimens,Nokia,BMW,Cisco etc.SAP, Oracle, IONA etc. are interested in OSGi and be OSGi EEG memberOSGi R4 Implemention Equinox Realized by Eclipse team; As the OSGi R4 RI; /equinox. Used by Eclipse RCP & Eclipse other products. Felix Realized by Apache Team; .Equinox共二十六页Java limited Ja

6、va class versionClass loader base on classpath to load java class, cant use different version. Authority control by package levelWhen the class declare as public, all clients can access Manage DependenciesYes, there is still a software crisis!Many applications are fragile monoliths with poorly defin

7、ed dependencies, collaboration points and behavioral responsibilities.Modularity is remarkably hard without OSGi.OSGi enforces good software modularity.Modularity, it turns out, is the lubricant of collaboration.The Software Crisis共二十六页分工(Division of Labour)抽象化(Abstraction)重复使用(Reuse)容易(rngy)维护(Ease

8、 of Maintenance and Repair)模块化MODULARITYSelf-Contained 完整的逻辑(lu j)单元Highly Cohesive 功能紧密Loosely Coupled 松耦合MODULEWrong!Right!Modular模块化的优势共二十六页Cohesion?Cohesion is an inward view of the relevance of the elements of a bundle to one other.In a highly cohesive bundle all parts are directly related to,

9、and focused on, addressing a defined, narrowly focused topic.Sadly, low cohesive bundles are rife.Highly cohesive bundles require careful design to keep them small.High cohesionLow cohesion 共二十六页Coupling?Coupling is an outward view of the number of relationships between a bundle and other bundles in

10、 the system.Bundles should be loosely coupled.A loosely coupled bundle is more likely to be used, reused and tested.“Dont make me inflate an entire universe!”Loosely coupled bundles are simpler to understand, test, debug change, etc.Loose Coupling is Good共二十六页EncapsulationBundles should be encapsula

11、ted from each other.Encapsulation enables loose coupling.Encapsulation enables the hiding of implementation details.A bundles API should be split into internal and external.Encapsulation at the module level is challenging in Java due to weak visibility rules.Good Fences Make Good Neighbors共二十六页Granu

12、larityBundle size matters.The size of a bundle affects its coupling and cohesion.Big bundles often have low cohesion and high coupling.Big bundles are harder to:UsereuseTestDebugSize Does Matter共二十六页OSGi ServicesBundles can collaborate via the OSGi service registry.A service is just an instance of a

13、 POJO class.Services are often stateless.Services must be thread-safe.Multiple implementations and instances of a service are common.Services are dynamically bound and unbound at runtime by either OSGi-specific wiring code, or the Declarative Services runtime.Not Everything Should be a Service共二十六页O

14、SGi Features Modularity with rule; Dynamic configuration, ”Plug and Play” ExtensionBest practice guide and support for building modularity/dynamic/extension systemModularity with rule;Dynamic support for module,OSGi service,Extension support with OSGi service.These features are supported by OSGi, th

15、is meaning is that you dont need realize those features by yourself. What you need do is just use itUniversal Middleware - 是OSGi近年来新取的名词,目标是让OSGi脱离语言限制,成为(chngwi)所有语言的统一模型。共二十六页OSGI LAYERSecurityBundleLife cycleModuleExecution environment JVMHardware/OSService共二十六页OSGi LayerBundles Logical modules t

16、hat make up an applicationService layer Provides communication among modules and their contained components. This layer is tightly integrated with the lifecycle layer. Lifecycle layer Provides access to the underlying OSGi framework. This layer handles the lifecycle of individual bundles so you can

17、manage your application dynamically, including starting and stopping bundles.Module layer Provides an API to manage bundle packaging, dependency resolution, and class loading.Execution environment A configuration of a JVM. This environment uses profiles that define the environment in which bundles c

18、an work. Security layer Optional layer based on Java 2 security, with additional constraints and enhancements. 共二十六页OSGI核心(hxn)组件FrameworkBundleServiceJava VMFrameworkBundleServiceExport | ImportBundleBundleBundleBundle ContainerBundleContext模块化及动态服务功能共二十六页OSGi BundlesOSGi中,我们将应用程序模块化成bundle,每个bundl

19、e是由一些紧耦合的,动态加载的,类的集合以及明确声明依赖关系(gun x)的配置文件组成的jar。Bundle可以在OSGi容器中installed, started, stopped, updated, and removed。Bundle允许模块之间共享类,这是一种静态重用的形式。当bundle在容器中启动后,它share出来的类即可被其他类引用。Bundle是jar文件,他的清单文件显式地声明了jar中哪些包对外是可见的(exported packages) ,哪些外部包是本包需要的(imported packages). 简述OSGi Service 是一个java class或者服务

20、接口的实例,它具有名值对OSGi Service通过接口来定义语义,通过一个java对象实现(shxin)接口。OSGi服务注册服务提供者注册服务到服务注册库中,让别的bundle来使用服务消费者查找服务并与服务提供者绑定OSGi Service共二十六页OSGi Basic Concepts - Modularity ModularityDefine module in OSGi;Publish functions for other modules;Use functions provided by other modules.BundleBundleJAVAOperating Syste

21、mHardwareOSGi FrameworkServiceregistrypackagespackages共二十六页OSGi Basic Concepts - ModularityDefine module in OSGiIn OSGi module compose of one or more bundles;Bundle is a normal jar file, the difference is its Manifest.mf file, OSGi add some specical header info property to declarative bundle, such a

22、s: bundle-versionexport-packageimport-packagePublish functions for other bundlesadd export-package header info to provide package for other bundles to usesuch as .osgi.ppt.service;add Fragment-Host header info to provide all resources for host bundle to use;publish OSGi service for other bundles;Use

23、 BundleContext.registerService to register normal java interface as OSGi service;Write xml with rule to declarative normal java class as OSGi component, and provide service interface for other bundles, such as:共二十六页Use functions provided by other modulesadd import-package header info to import packa

24、ges provided by other bundles, then you can use the java class in those packages;add require-bundle header info to use all export packages and resources provider by bundle;use OSGi service provided by other bundles;Use BundleContext.getService to get OSGi service provided by other bundles;Write xml

25、with rule to declarative normal java class as OSGi component,and inject OSGi service provided by other bundles,such as: OSGi Basic Concepts - Modularity共二十六页2022/7/28OSGi Basic Concepts - Dynamic Dynamic Bundle lifecycle OSGi component lifecycle Handle the dynamic when bundle lifecycle changed; when

26、 OSGi component lifecycle changed; when configuration changed; when framework changed; when custom event published;OSGi provide an API for manageing bundles lifecycle (Install/Resolve/Start/Stop/Refresh/Update/Uninstall),so OSGi framework RI will control bundle lifecycle self;狀態descriptionINSTALLEDb

27、undle成功安裝後進入的狀態RESOLVED所有Java classes或native code 可使用所進入的狀態。STARTING被啟用狀態STOPPING被停止狀態ACTIVE啟用後成功執行的狀態UNINSTALLED卸載狀態共二十六页 Component that provide no service;when all need OSGi services(exclued optional service) are usable,the component will be actived; Component that provide services;when all need O

28、SGi services(exclued optional service) are usable; other component call this OSGi service implemention.OSGi Basic Concepts - Dynamic共二十六页2022/7/2822Handle the dynamic when bundle lifecycle changed; OSGi component lifecycle will change automatically; OSGi will handle bundle lifecycle dynamic self; wh

29、en OSGi component lifecycle changed;OSGi service tracker can be used to monitor OSGi service;Declarative Services use bind-method,unbind-method to notify the dynamic of OSGi service. when configuration changed;Configuration Admin Service automatically notify the configuration change. when framework changed;FrameworkEventListener can be implemented to monitor framework. when custom event p

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论