`

OSGi

    博客分类:
  • J2EE
阅读更多
  

一个 web 项目,可以通过将各个 layer(prensentation - service - model - dao)的 classes,单独打成 jar, 实现 development time modularity. 但是,这些 module 最终还是需要作为 war 的依赖部署到web container 中,任何一个jar的变更,还是需要重新部署整个war。
OSGi带来的是,是 runtime module system.比如在不用重新部署整个web项目的情况单独升级某个dao jar。



An introduction to OSGi:
http://www.developerfusion.com/article/84923/an-introduction-to-osgi/


OSGi Modularity - Tutorial:
http://www.vogella.com/tutorials/OSGi/article.html
引用
使用 eclipse 的 export -> "deployable plugins and fragments" 导出 bundle jar 到 Felix 目录下,该 jar 会被放到一个叫 plugins 的目录下,而不是默认的 bundle 目录下。这两个目录,或者说在 osgi 环境下 bundle 与 plugin 有区别吗?答案是没有区别,只是 felix 将一个 osgi 服务叫做 bundle,而 eclipse 通常称其为 plugin 而已:
引用
1.2. Bundle vs. plug-in
In Eclipse the smallest unit of modularization is a plug-in. The terms plug-in and bundle are (almost) interchangeable. An Eclipse plug-in is also an OSGi bundle and vice versa.
所以在 osgi 的语境下我们认为:
bundle = Deployable service = plugin,一般就是个jar包。

All these restrictions are enforced via a specific OSGi classloader. Each bundle has its own classloader. Access to restricted classes is not possible.



Apache Felix Framework Usage Documentation:
http://felix.apache.org/documentation/subprojects/apache-felix-framework/apache-felix-framework-usage-documentation.html
引用

A bundle is the OSGi term for a component for the OSGi framework



OSGi and Class Loader:
https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.0/html/Managing_OSGi_Dependencies/files/BCL-ClassLoader.html
引用
In the context of OSGi, where a typical application depends on multiple class loaders (one for each bundle), it is important to understand that the fully-qualified class name—for example, org.foo.Hello—is not sufficient to identify a loaded class uniquely. In general, a loaded class is uniquely identified by combining the classloader identity with the fully-qualified class name.



Remote services(aka, Dosgi - distributed osgi):
http://blog.akquinet.de/2009/09/14/dynamokos-dealing-with-dynamism-in-osgi-distributed-web-applications/



eclipse 下 osgi 项目的创建与 deploy:
https://blogs.oracle.com/arungupta/entry/totd_126_creating_an_osgi


Introduction to the Apache Felix DependencyManager – part two
http://arnhem.luminis.eu/introduction-apache-felix-dependencymanager-part-2/


常见 OSGI MANIFEST.MF configs:
引用
Import-Package:the packages that it needs to run
Export-Package:the packages that it may export for other bundles to use
Bundle-RequiredExecutionEnvironment:the execution environment that it requires





引用
Chapter 5. Bundles and Application Contexts
The unit of deployment (and modularity) in OSGi is the bundle (see section 3.2 of the OSGi Service Platform Core Specification). A bundle known to the OSGi runtime is in one of three steady states: installed, resolved, or active. Bundles may export services (objects) to the OSGi service registry, and by so doing make these services available for other bundles to discover and to use. Bundles may also export Java packages, enabling other bundles to import the exported types.
In Spring the primary unit of modularity is an application context, which contains some number of beans (objects managed by the Spring application context). Application contexts can be configured in a hierarchy such that a child application context can see beans defined in a parent, but not vice-versa. The Spring concepts of exporters and factory beans are used to export references to beans to clients outside of the application context, and to inject references to services that are defined outside of the application context.
There is a natural affinity between an OSGi bundle and a Spring application context. Using Spring Dynamic Modules, an active bundle may contain a Spring application context, responsible for the instantiation, configuration, assembly, and decoration of the objects (beans) within the bundle. Some of these beans may optionally be exported as OSGi services and thus made available to other bundles, beans within the bundle may also be transparently injected with references to OSGi services.

After a refreshPackages operation, packages exported by older versions of updated bundles, or packages exported by uninstalled bundles, are no longer available.

When a Spring-powered bundle is stopped, the application context created for it is automatically destroyed.

If a Spring-powered bundle that has been stopped is subsequently re-started, a new application context will be created for it.

The Spring extender recognizes a bundle as "Spring-powered" and will create an associated application context when the bundle is started and one or both of the following conditions is true:
The bundle path contains a folder META-INF/spring with one or more files in that folder with a '.xml' extension.
META-INF/MANIFEST.MF contains a manifest header Spring-Context.



OSGi Specification, 6.0:
http://www.osgi.org/download/r6/osgi.core-6.0.0.pdf


The difference between a jar and a bundle:
http://konigsberg.blogspot.com/2009/04/difference-between-jar-and-bundle.html


Discovering the future of Java
http://javadepend.wordpress.com/2012/10/31/discovering-the-future-of-java/

SpringSource to move dmServer to Eclipse – OSGi not ready for mainstream?
http://www.theserverside.com/discussions/thread.tss?thread_id=59183
分享到:
评论

相关推荐

    osgi介绍osgi介绍

    osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍

    osgi-resource-locator-1.0.1-API文档-中文版.zip

    赠送jar包:osgi-resource-locator-1.0.1.jar; 赠送原API文档:osgi-resource-locator-1.0.1-javadoc.jar; 赠送源代码:osgi-resource-locator-1.0.1-sources.jar; 赠送Maven依赖信息文件:osgi-resource-locator...

    OSGi与Equinox 创建高度模块化的Java系统

    OSGi与Equinox:创建高度模块化的Java系统》分为四个部分。第一部分主要介绍了OSGi和Equinox,以及OSGi标准的Eclipse实现;第二部分采用非正式教程的方式教给读者如何从零开始构建真实的Toast应用,针对每一个步骤都...

    OSGI原理与最佳实践

    资源名称:OSGI原理与最佳实践内容简介:国内第一本OSGi图书OSGi国内推广者林昊多年经验的结晶涵盖OSGi从入门到深入的知识体系引领OSGi国内研究和普及本书基于作者多年使用OSGi的经验而编写,涵盖了OSGi从入门到深入...

    《OSGi实战》完整中文版

    《 OSGi实战》是学习OSGi的全面指导,利用与架构和开发人员相关的示例清楚地讲解OSGi概念,同时探讨了很多实践场景和技术,阐述了开发人员有多需要OSGi,怎么将OSGi嵌入其他容器中,将遗留系统移入OSGi的最佳实践,...

    OSGi.NET框架 Documentation

    本文档主要针对OSGi.NET模块化框架使用进行了描述 OSGi.NET框架是一个参照了OSGi规范的模块化管理框架。框架为应用程序(组件(bundle))提供了一个标准环境。整个框架可以划分为一些层次: 1.运行环境 2.模块...

    Equinox OSGI ServletBridge 原理与实践.rar

    OSGI 在 J2EE 环境下的应用越来越广泛,目前在 Servlet 应用中使用 OSGI 有两种方式:Servlet Container in OSGI 和 OSGI in Servlet Container. 前一种:和普通的 OSGI bundle 开发差不多,而后一种:Equinox 提供...

    osgi实战(pdf超请版)

    本篇 Opendoc 按照学习开源框架的基本流程进行编写,从体验 OSGI 到基于 OSGI 框架的实战,到深入 OSGI,完成对于 OSGI 从入门到深入学习的过程,最后对于 OSGI 的现状和发展发表些自己的看法和思考,限于笔者的水平以及...

    OSGi原理与最佳实践

    本书基于作者多年使用OSGi的经验而编写,涵盖了OSGi从入门到深入的知识体系,从OSGi的简介开题,介绍OSGi的作用及基本概念;其后进入OSGi实战,结合实例讲解如何基于OSGi框架编写模块化、动态化的各种Java应用;最后...

    osgi.enterprise-6.0.0

    The OSGi Enterprise Expert Group (EEG) is chartered to define the technical requirements and specifications to tailor and extend the OSGi framework to address information technology software ...

    OSGI原理最佳实践(包含源代码)

    是一本适合新接触OSGI开发学习的一本很好的书,本书介绍了Equinox, Spring-DM和Felix这三个常用的OSGi容器的使用、开发、以及WebApplication的开发部署;介绍了OSGi的规范和Core Framework和Layer。包含书中的用例源...

    OSGI 实例eclipse插件开发

    OSGI 实例 eclipse 插件开发

    OSGi原理与最佳实践pdf下载(完整版)

    OSGI原理与最佳实践的完整版,共12章 第1 章OSGi 简介 第2 章OSGi 框架简介 第3 章基于Spring-DM 实现Petstore 第4 章基于Apache CXF 实现分布式Petstore 第5 章构建OSGI Bundle Repositor'y 第6 章OSGi 规范解读 ...

    OSGi+SpringMVC+Spring+Hibernate企业应用框架

    辛苦研究了一个多月,终于搭建成了一个可用于实际应用开发的OSGI-WEB框架,采用OSGi+SpringMVC+Spring+Hibernate+Virgo技术,鉴于此类技术架构甚少,特提供出来供大家参考。 使用步骤: 一、下载STS搭建Osgi开发...

    (OSGi In Practice_20091217

    The Java™ programming language is one of the most popular languages today ...That module system is called OSGi. OSGi is nothing more nor less than the way to build modular applications in Java.

    osgi.residential-6.0.0

    When the OSGi Alliance started in 1998, the focus was in residential gateways the organization's name contained the word gateway before it was changed to the OSGi Alliance. Since that time, OSGi ...

    Felix_OSGi实作

    Felix_OSGi实作,介绍最流行的OSGI framwork-Felix的好文档

    OSGI原理与最佳实践(扫描版,带目录).pdf

    OSGi原理与最佳实践基于作者多年使用0SGi的经验而编写,涵盖了0SGi从/kfqN深入的知识体系,从OSGi的简介开始,介绍OSGi的作用及基本概念;其后进入OSGi实战,结合实例讲解如何基于OSGi框架编写模块化、动态化的各种...

    利用R-OSGi实现分布式OSGi应用

    利用R-OSGi实现分布式OSGi应用 本文通过介绍传统 OSGi 应用程序及 R-OSGi 的实现方式入手,阐述了 R-OSGi 对于 OSGi 规范的实现方式。然后通过一个简单的功能实现由浅入深地讲述传统 OSGi 和 R-OSGi 上的两种不同...

Global site tag (gtag.js) - Google Analytics