- 浏览: 254204 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
aquarion:
非常感谢,解决了我的问题
Perspective 自定义设置扩展点 -
zheng_zhen:
好文章,进一步问您一下,请问自己实现的run/debug如何能 ...
【原创】Eclipse Launcher (Run/Debug As 菜单扩展)实现 -
salever:
mwdnjupt 写道http://www.xeclipse. ...
浅析OSGI的bundle依赖 -
mwdnjupt:
http://www.xeclipse.com/?p=1165 ...
浅析OSGI的bundle依赖 -
Tom.X:
插件化、模块化应遵循高内聚、低耦合的原则,尽量不要在各bund ...
浅析OSGI的bundle依赖
1 MANIFEST 文件
Bundle Manifest Headers, META-INF/MANIFEST.MF
1.1 Java JAR format:
http://download.oracle.com/javase/1.4.2/docs/guide/jar/jar.html#JAR%20Manifest
Manifest Specification :
1. manifest-file: main-section newline *individual-section
2. main-section: version-info newline *main-attribute
3. version-info: Manifest-Version : version-number
4. version-number : digit+{.digit+}*
5. main-attribute: (any legitimate main attribute) newline
6. individual-section: Name : value newline *perentry-attribute
7. perentry-attribute: (any legitimate perentry attribute) newline
1.2 Bundle-ActivationPolicy: lazy
The Bundle-ActivationPolicy specifies how the framework should activate the bundle once started.
If the activation fails because the Bundle Activator start method has thrown an exception, the bundle must be stopped without calling the Bundle Activator stop method.
1.2.1 Lazy Activation Policy
A lazy activation policy indicates that the bundle, once started, must not be activated until it receives the first request to load a class.
Step to activate:
• A Bundle Context is created for the bundle.
• The bundle state is moved to the STARTING state.
• The LAZY_ACTIVATION event is fired.
• The system waits for a class load from the bundle to occur.
• The normal STARTING event is fired.
• The bundle is activated.
• The bundle state is moved to ACTIVE .
• The STARTED event is fired.
Starting with eager activation versus lazy activation
1.2.2 Activate Rule:
By default, any class loaded from the bundle can trigger the lazy activation, however, resource loads must not trigger the activation. The lazy activation policy can define which classes cause the activation with the following directives:
• include – A list of package names that must trigger the activation when a class is loaded from any of these packages. The default is all package names present in the bundle.
• exclude – A list of package names that must not trigger the activation of the bundle when a class is loaded from any of these packages. The default is no package names.
For example:
Bundle-ActivationPolicy: lazy; «
include:="com.acme.service.base,com.acme.service.help"
1.3 Bundle-Activator
The Bundle-Activator header specifies the name of the class used to start and stop the bundle.
A bundle is activated by calling its Bundle Activator object, if one exists. The BundleActivator interface defines methods that the Framework invokes when it starts and stops the bundle.
To inform the OSGi environment of the fully qualified class name serving as its Bundle Activator, a bundle developer must declare a Bundle-Activator manifest header in the bundle’s manifest file. The Framework must instantiate a new object of this class and cast it to a BundleActivator instance. It must then call the BundleActivator.start method to start the bundle
Activator 可有可无,在一些 Library bundle 里面可以没有 activator 。
1.4 Bundle-Category:
The Bundle-Category header holds a comma-separated list of category names.
1.5 Bundle-ClassPath
The Bundle-ClassPath header defines a comma-separated list of JAR file path names or directories (inside the bundle) containing classes and resources. The period (’.’) specifies the root directory of the bundle’s JAR. The period is also the default.
Container , entries , search order , entry path , bundle class path
Example :
Bundle-ClassPath : lib/ant-antlr.jar,
lib/ant-apache-log4j.jar,
lib/ant.jar,
.
1.6 Fragment-Host
The Fragment-Host header defines the host bundles for this fragment
Fragment-Host ::= bundle-description
bundle-description ::= symbolic-name
(';' parameter ) *
When a fragment bundle is attached to a host bundle, it logically becomes part of it. All classes and resources within the fragment bundle must be loaded using the class loader (or Bunde object) of its host bundle. The fragment bundles of a host bundle must be attached to a host bundle in the order that the fragment bundles are installed, which is in ascending bundle ID order.
About Fragment
All class or resource loading of a fragment is handled through the host’s class loader or Bundle object, a fragment must never have its own class loader, it therefore fails the class and resource loading methods of the Bundle object. Fragment bundles are treated as if they are an intrinsic part of their hosts.
Though a fragment bundle does not have its own class loader, it still must have a separate Protection Domain when it is not an extension fragment. Each fragment can have its own permissions linked to the fragment bundle’s location and signer.
A host bundle’s class path is searched before a fragment’s class path. This implies that packages can be split over the host and any of its fragments. Searching the fragments must be done in ascending bundle ID order. This is the order that the fragment bundles were installed.
1.7 Bundle-Name
1.8 Bundle-SymbolicName
引用名
The Bundle-SymbolicName manifest header is a mandatory header. The bundle symbolic name and bundle version identify a unique bundle.
1. singleton – Indicates that the bundle can only have a single version resolved. A value of true indicates that the bundle is a singleton bundle . The default value is false . The Framework must resolve at most one bundle when multiple versions of a singleton bundle with the same symbolic name are installed. Singleton bundles do not affect the resolution of non-singleton bundles with the same symbolic name.
2. fragment-attachment – Defines how fragments are allowed to be attached, see the fragments in Fragment Bundles on page 69. The following values are valid for this directive:
Ø always – (Default) Fragments can attach at any time while the host is resolved or during the process of resolving.
Ø never – No fragments are allowed.
Ø resolve-time – Fragments must only be attached during resolving.
1.9 Bundle-RequiredExecutionEnvironment
1.10 Require-Bundle
The Require-Bundle header specifies that all exported packages from another bundle must be imported, effectively requiring the public interface of another bundle.
1.11 Bundle-Version
1.12 Provided-Capability
1.13 Require-Capability
1.14 Bundle-Localization
国际化相关
1.15 Export-Package
The Export-Package header contains a declaration of exported packages.
The header allows many packages to be exported. An export definition is the description of a single package export for a bundle.
Export directives are:
• uses – A comma-separated list of package names that are used by the exported package. Note that the use of a comma in the value requires it to be enclosed in double quotes. If this exported package is chosen as an export, then the resolver must ensure that importers of this package wire to the same versions of the package in this list. See Package Constraints on page 46.
• mandatory - A comma-separated list of attribute names. Note that the use of a comma in the value requires it to be enclosed in double quotes. A bundle importing the package must specify the mandatory attributes, with a value that matches, to resolve to the exported package.
• include – A comma-separated list of class names that must be visible to an importer. Note that the use of a comma in the value requires it to be enclosed in double quotes.
• exclude -A comma-separated list of class names that must be invisible to an importer. Note that the use of a comma in the value
1.16 Import-Package
The Import-Package header declares the imported packages for this bundle.
The header allows many packages to be imported. An import definition is the description of a single package for a bundle. The syntax permits multiple package names, separated by semi-colons, to be described in a short form.
An error aborts an installation or update when:
• A directive or attribute appears multiple times, or
• There are multiple import definitions for the same package, or
• The version and specification-version attributes do not match.
1.17 Bundle-ContactAddress
1.18 Bundle-Copyright
1.19 Bundle-Description
1.20 Bundle-DocURL:
1.21 Bundle-Icon
1.22 Bundle-License
1.23 Bundle-ManifestVersion: 2
1.24 Bundle-NativeCode
1.25 Bundle-UpdateLocation
1.26 Bundle-Vendor
1.27 DynamicImport-Package
1.28 Export-Service
1.29 Import-Service
1.30 其他
1.30.1 Custom Headers
The manifest an excellent place to provide metadata belonging to a bundle. This is true for the OSGi Alliance but it is also valid for other organizations. For historic reasons, the OSGi Alliance claims the default name space, specifically headers that indicate OSGi related matters like names that contain Bundle, Import, Export, etc. Organizations that want to use headers that do not clash with OSGi Alliance defined names or bundle header names from other organizations should prefix custom headerswith x- , for example x-LazyStart .
Example :
Eclipse-SourceBundle: org.eclipse.ui.ide;version="3.6.2.M20101201-0800
";roots:="."
1.30.2 Common Header Syntax
Many Manifest header values share a common syntax. This syntax consists of:
header ::= clause ( ’,’ clause ) *
clause ::= path ( ’;’ path ) *( ’;’ parameter ) *
A parameter can be either a directive or an attribute . A directive is an instruction that has some implied
1.30.3 Version
version ::=
major( '.' minor ( '.' micro ( '.' qualifier )? )? )?
major ::= number // See 1.3.2
minor ::= number
micro ::= number
qualifier ::= ( alphanum | ’_’ | '-' )+
A version must not contain any white space. The default value for a version is 0.0.0.
1.30.4 Version Ranges
The syntax of a version range is:
version-range ::= interval | atleast
interval ::= ( '[' | '(' ) floor ',' ceiling ( ']' | ')' )
atleast ::= version
floor ::= version
ceiling ::= version
Example |
Predicate |
[1.2.3, 4.5.6) |
1.2.3 <= x < 4.5.6 |
[1.2.3, 4.5.6] |
1.2.3 <= x <= 4.5.6 |
(1.2.3, 4.5.6) |
1.2.3 < x < 4.5.6 |
(1.2.3, 4.5.6] |
1.2.3 < x <= 4.5.6 |
1.2.3 |
1.2.3 <= x |
发表评论
-
基于Spring/Hibernate/Hessian的RCP客户端系统框架
2012-08-14 11:23 2688本文同步发表在 http://www.xeclips ... -
【资料整理】中国Eclipse社区开发资料整理
2012-05-13 21:53 4320前言 中国Eclipse社区(www.ceclipse ... -
【Eclipse plug-in】 org.eclipse.ui.activities 的使用
2011-11-30 15:20 2776整理一下org.eclipse.ui.activities的使 ... -
Eclipse plugin中获取工程的几种办法
2011-10-10 15:56 2806在Eclipse开发中,涉及到Resource的时候,经常会需 ... -
【SDK or Binary】Eclipse 开发版本选择
2011-08-19 14:11 5707前言:老手直接忽略。打开Eclipse的download页面, ... -
Eclipse Spring Application Context XML 小工具
2011-08-18 15:35 2210概述 Spring 开发经常需要配置bean clas ... -
【Eclipse所有示例】Eclipse CVS 平台源码
2011-04-21 10:06 1859总有TX上论坛要各种源码,首先并不提倡这种做法,这与间接的 ... -
中文版的Eclipse 帮助文档
2011-04-14 13:43 3524偶然在IBM的一个帮助网站上发现了部分Eclipse的部分的中 ... -
深入 Common Navigator Framework 完整版下载
2011-04-11 15:19 2584写完整个Common Navigator Framework之 ... -
深入 Common Navigator Framework 之 Link with Editor Support
2011-04-11 15:15 19908.1 概述 这个功能简单的说,就是将选中的节点与对应的编辑 ... -
深入 Common Navigator Framework 之 Drag and Drop Support
2011-04-11 15:11 22637.1 概述 顾名思义,Drag and Drop Supp ... -
深入 Common Navigator Framework 之 Action Providers
2011-04-11 15:05 22776.1 概述 有了工程的树形结构显示,自然就要考虑到菜单的配 ... -
深入 Common Navigator Framework 之 Common Wizards
2011-04-11 15:00 17955.1 概述 Common Wizard用于定制Naviga ... -
深入 Common Navigator Framework 之 Common Filters
2011-04-11 14:56 20194.1 概述 Common Filter负责进行节点过滤,类 ... -
深入 Common Navigator Framework 之 navigatorContent
2011-04-07 14:31 24813.1 概述 Eclipse为了方便 ... -
深入 Common Navigator Framework 之 Navigator
2011-04-07 14:18 31182.1 概述 Navigator 是CNF中用来显示资源结构 ... -
深入 Common Navigator Framework 之概述
2011-04-07 14:07 28641.1 概述 CNF,全称Common Navigato ... -
Common Navigator Framework初探
2011-03-30 17:14 4969这篇文章是继《Eclipse RCP/Plugin 入门自学教 ... -
利用Eclipse SDK 学习 Extension Point
2011-03-07 11:27 4180很多Eclipser在开发RCP时候,会遇到Extension ... -
Eclipse Property Testers (Test expression) 的使用
2011-03-07 10:55 4661Eclipse Resource Plugin里面很多值得一看 ...
相关推荐
标题中的"org.osgi.framework.BundleException-glassfish"指的是在使用Glassfish应用服务器时遇到的OSGi框架相关的异常。OSGi(Open Services Gateway Initiative)是一种Java模块化系统,它允许动态地管理和部署...
在MANIFEST.MF文件中,定义Bundle-SymbolicName和Bundle-Version属性,以标识bundle的唯一性和版本。 3. **导入导出包**:在MANIFEST.MF中,声明bundle需要导入和导出的包。导入表示对其他bundle的依赖,导出表示向...
org.jbundle.util.osgi.wrapped.org.apache.http.client-4.1.2.jar
标题 "org.osgi.core-4.2.0" 指的是一个特定版本的 OSGi(Open Services Gateway Initiative)核心框架库,版本号为 4.2.0。OSGi 是一个 Java 平台的模块化系统和服务平台,它提供了一种标准的方式来组织和管理 Java...
例如,`org.eclipse.osgi.framework.internal.core.BundleHost`类负责管理bundle的启动和停止,`org.eclipse.osgi.framework.eventmgr.EventAdmin`则展示了OSGi事件模型的实现。 五、应用场景 OSGi在许多领域有着...
3. 开发Bundle:讲解Bundle的生命周期,如何编写Bundle的元数据(MANIFEST.MF),以及Bundle内代码的组织结构。 4. 开发、发布和使用Service:介绍OSGI服务的概念,如何定义、注册服务,以及服务消费者如何查找和...
osgi的jar包,第一次上传,有需要的可以自取,联网下载很慢,希望对你们有帮助,偶然间遇到了
org.osgi.namespace.extender-1.0.1.jar
- **导出相应的包:**还需要在`MANIFEST.MF`文件中通过`Export-Package`指令导出相应的包,以便其他Bundle能够访问这些服务。 以上内容为Spring OSGi入门的基本知识点,涵盖了Spring DM的基础概念、配置方法以及...
1. **配置管理**:理解和掌握Bundle的配置元数据,如MANIFEST.MF文件,是使用OSGI的关键。 2. **服务设计**:合理设计服务接口,避免过度耦合,提升服务的可重用性。 3. **依赖管理**:学会利用OSGI的依赖注入机制...
基于java的开发源码-OSGi 分布式通讯组件 R-OSGi.zip 基于java的开发源码-OSGi 分布式通讯组件 R-OSGi.zip 基于java的开发源码-OSGi 分布式通讯组件 R-OSGi.zip 基于java的开发源码-OSGi 分布式通讯组件 R-OSGi.zip ...
例如,"org.salever.osgi.depends.clientbundle"很可能是一个依赖于其他服务的bundle,它在MANIFEST.MF中声明了对外部服务的依赖。而"org.salever.osgi.depends.hostbundle"可能是提供这些服务的bundle,或者是...
[OSGi实战].(OSGi.in.Action).R.S.Hall&K.Pauls&S.McCulloch&D.Savage.文字版.pdf
- **依赖管理**:通过MANIFEST.MF文件声明bundle的依赖,避免了类路径冲突。 - **版本控制**:支持多版本共存,每个bundle可以指定其依赖的特定版本。 - **动态性**:bundle可以动态地加入或离开系统,增强了软件...
总的来说,OSGi开发jar包需要掌握模块化编程思想、MANIFEST.MF配置、OSGi框架使用、服务模型以及安全机制等多个方面。通过熟练运用这些知识,开发者可以构建出高度可扩展、灵活且易于维护的Java应用程序。
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 ...
OSGi(Open Services Gateway initiative)是一种Java动态模块化系统规范,其核心思想是将应用分割成一系列的 bundles(模块),每个 bundle 都可以独立地安装、启动、停止、更新,而不会影响到其他 bundles。OSGi ...
Spring OSGi 是一个将流行的Spring框架与OSGi(Open Service Gateway Initiative)规范结合的开源项目,它允许开发者在OSGi环境中充分利用Spring的功能。OSGi是一种模块化系统,旨在创建可伸缩、灵活且可维护的Java...