OSGi doesn’t allow you to specify class visibility at the class level, but instead at the level of the containing package.
1. The header:Export-Package and The directives for the Export-Package header
当指定一个package export,默认的它的subpackage是没有exportde,需特别指定。
Directives for the Export-Package header:
(1)exclude
: Specifies a list of packages that must be invisible to the component importing the
package.
(2)include
: Specifies a list of packages that must be visible to the component importing the
package.
(3)mandatory:
Specifies a list of mandatory properties that must be specified when using the
exported package in other components.
(4)uses
: Specifies a list of packages that an exported package uses. This directive is used by
the dependency resolver to ensure that imported package versions correspond to those
specified here.
默认情况下,在Export Package是,OSGi框架会自动将ExportBundles的bundle-symbolic-name和Bundle
-Version属性添加上。
例如:Export-Package:
org.springframework.beans.factory.serviceloader;
uses:="org.springframework.util,
org.springframework.beans. factory.config,
org.springframework.beans.factory";
version=2.5.5,
org.springframework.beans.annotation;
uses:="org.springframework.util,
org.springframework.beans";
version=2.5.5,
...
2. The header:Import-Package and It's stand attributes
Standard attributes usable with the Import-Package header:
(1)version
: Specifies the version range for matching exported packages. If this attribute
isn’t specified, the default value is [0.0.0, ∞).
(2)bundle-symbolic-name
: Specifies the symbolic name of the component that exports the
packages. In the case of a fragment bundle, the name will correspond to the host bundle’s
symbolic name instead. A fragment is a special bundle that allows extending an existing
bundle.
(3)bundle-version
: Specifies the version of the component that exports the packages. As
with version, the default value is [0.0.0, ∞) and the fragment behavior is as for bundle-
symbolic-name.
例如:
Import-Package: javax.el;version="[2.1.0, 3.0.0)";resolution:=optional
net.sf.cglib.proxy;version="[2.1.3, 2.2.0)";resolution:=optional,
org.apache.commons.logging;version="[1.0.4, 2.0.0)",
org.springframework.core;version="[2.5.6, 2.5.6]";resolution:=optional,
org.springframework.core.annotation;version="[2.5.6, 2.5.6]";
resolution:=optional
In addition to the previous attribute, the resolution directive of the Import-Package header
makes it possible to change the behavior of this resolution mechanism.The first possible value
of the directive is mandatory, which is also the default.When a package is marked as
mandatory, it means that if the package can’t be resolved, the component itself can’t be
resolved. The other value is optional. In this case, if the package isn’t present during the
resolution phase, the package isn’t considered imported by the component.
3. The header: DynamicImport-Package
It bypass the regular class-resolution mechanism we have described and instead allows
classes to be loaded on demand at runtime. Dependencies specified in this way are ignored
during the transition between the installed and resolved states.
The DynamicImport-Package header can contain a list of packages, but it also supports two
wildcards for specifying package names. Moreover, these imports are searched for in the order
in which they are specified. This ordering is important, especially when using wildcards,
because it determines the order in which matching occurs. In the following snippet, packages
with the value test for the attribute myattribute will be preferred over other packages.
DynamicImport-Package: *;myattribute=test, *
No directives are defined for this header, but the standard version, bundlesymbolic-name,
and bundle-version attributes can all be used for package matching with the same semantics
as Import-Package.
4. The header: Require-Bundle
The Require-Bundle header is provided by the OSGi specification so you can consume all
exported packages from other components based on component symbolic names.
The Require-Bundle only has one attribute:bundle-version,the bundle-version attribute uses
the same semantics as the version attribute of the Import-Package header and specifies
the component version of the dependency.
例如:
Manifest-Version: 1.0
(...)
Import-Package: javax.servlet;version="2.5.0",
javax.servlet.http;version="2.5.0",
javax.servlet.jsp;version="2.0.0",
(...)
Require-Bundle: com.springsource.javax.servlet.jsp.jstl;
bundle-version=1.1.2,com.springsource.org.apache.taglibs.standard;
bundle-version=1.1.2
注意:同一份MANIFEST.MF配置文件中,Import-Package header takes priority over the Require
-Bundle header.
Directives usable with the Require-Bundle header:
(1)visibility
: When set to private (the default value), the exported packages of the
corresponding bundles aren’t re-exported. Setting this to reexport will achieve the opposite.
(2)resolution
: Controls dependency resolution. If set to mandatory (the default value), the
dependency must be successfully resolved for the bundle to resolve. With the optional value,
dependencies are only resolved if they’re present, and the bundle will resolve regardless.
5. Split packages
You saw that referencing bundles with the Require-Bundle header is equivalent to importing
all of their exported packages. A problematic case occurs when two different required bundles
export the same package. Such packages are named split packages because their content
comes from several bundles.
Although OSGi allows split packages, you’ll notice that they have several obvious drawbacks.
When different bundles provide the same classes, unpredictable shadowing of classes can arise.
6. Matching and Versioning
6.1 Version Matching
The different parts of a version value:
(1)Major number
: For major updates with no provision for compatibility with previous major
versions.
(2)Minor number
: For functional updates compatible with the current major version (compatible
for clients using an interface, but not for implementers).
(3)Micro number
: For bug fixes.
(4)Qualifier
: Values like “–SNAPSHOT” for the current development version can also be added
at the end of the value. The version number with a qualifier is lower than the number without.
6.2 Optional Depedencies
OSGi supports optional dependencies on both packages and bundles with the Import-Package
and Require-Bundle headers.
6.3 Attribute Matching
模式:
Header-Name: header-value1;directive-name1:=directive-value1;attribute-name1= attribute
-value1;attribute-name2=attribute-value2,
(...)
例如:
Export-Package: com.manning.osgi.simple;criteria="Manning";mandatory:="criteria"
Import-Package: com.manning.osgi.simple;criteria="Manning"
分享到:
相关推荐
OSGi提供了一个动态应用程序的执行环境,在这个环境中组件(bundles)可以在运行中被安装、更新、删除。它同时也可以很好地支持模块化及版本化。 Spring’OSGi的目标是使得写基于Spring的应用程序尽可能的容易,这些...
Java应用架构设计:模块化模式与OSGi 英文版 中文版介绍: 全球资深Java技术专家的力作,系统、全面地讲解如何...17.3.2 基于组件的开发(CBD)不是已经成功了吗 17.4 生态系统 17.5 结论 附录A 类设计的SOLID原则
它提供了一个轻量级的容易和一个用于依赖注入的非侵入式编程模块,AOP功能和便携式服务抽取。OSGI服务平台提供了一个动态应用执行环境,模块能随时被加载,更新或卸载。当然它对模块和版本控制有很好的支持。 ...
Java应用架构设计:模块化模式与OSGi 英文版 中文版介绍: 全球资深Java技术专家的力作,系统、全面地讲解如何将模块...17.3.2 基于组件的开发(CBD)不是已经成功了吗 17.4 生态系统 17.5 结论 附录A 类设计的SOLID原则
实施此服务的DS组件通常: 接收DataSourceFactory服务从该DataSourceFactory中: 创建一个数据源(例如,通过连接到诸如PostgreSQL之类的远程RDBMS或例如创建内存中的derby数据库) 使用liquibase创建架构并为...
该存储库包含JGrapes组件,这些组件构建在之上,并且依赖于OSGi框架。 之所以将它们放在一个单独的存储库中,是因为它们需要与可以用作OSGi捆绑包但不依赖于OSGi框架的库不同的顶层构建方法。 建筑 该项目是作为bnd...
注:下文中的 *** 代表文件名中的组件名称。 # 包含: 中文-英文对照文档:【***-javadoc-API文档-中文(简体)-英语-对照版.zip】 jar包下载地址:【***.jar下载地址(官方地址+国内镜像地址).txt】 Maven依赖:【*...
持续集成状态 分支 GCC 5.4和8.0 Visual Studio 2015 Xcode 7.3和11.6 ... 包括所有第三方库依赖关系,并且大多数用于实现详细信息。 支持平台 该库利用C ++ 14语言和库功能,并可以在许多不同的平台上进
软件依赖关系 Windows 10(1903)内部版本17063或更高版本使用tar进行档案管理的要求如果不可能,请安装7z 可通过PATH环境变量访问 [可选] AEM OSGi组件配置为了使用脚本管理软件包,CSRF和引荐来源过滤器OSGi配置将...
it.tests:基于Java的集成测试ui.apps:包含项目的/ apps(和/ etc)部分,即JS&CSS clientlib,组件和模板ui.content:使用ui.apps中的组件包含样本内容ui.config:包含项目的特定于运行方式的OSGi配置ui....
核心:包含所有核心功能(例如OSGi服务,侦听器或调度程序)以及与组件相关的Java代码(例如Servlet或请求过滤器)的Java捆绑包。 it.tests:基于Java的集成测试 ui.apps:包含项目的/ apps(和/ etc)部分,即JS...
it.tests:基于Java的集成测试ui.apps:包含项目的/ apps(和/ etc)部分,即JS&CSS clientlib,组件和模板ui.content:使用ui.apps中的组件包含样本内容ui.config:包含项目的特定于运行方式的OSGi配置ui....
it.tests:基于Java的集成测试ui.apps:包含项目的/ apps(和/ etc)部分,即JS&CSS clientlib,组件和模板ui.content:使用ui.apps中的组件包含样本内容ui.config:包含项目的特定于运行方式的OSGi配置ui....
这个jar文件包含Spring框架基本的核心工具类,Spring其它组件要都要使用到这个包里的类,是其它组件的基本核心,当然你也可以在自己的应用系统中使用这些工具类。 (2) spring-beans.jar 这个jar文件是所有应用都要...
较新的开发提供了大多数关键的CS-Studio组件,而没有任何Eclipse依赖关系,请参见它通常提供更快的启动速度,并且还大大简化了构建过程。 -一般信息开发人员说明(EPICS邮件列表)-用于用户查询和讨论如何贡献欢迎...
java后台程序源码日蚀库拉:trade_mark: 詹金斯: 一个基于 OSGi 的 M2M 服务网关应用框架 背景 直到最近,机器对机器项目一直被视为围绕...调用的,并且依赖于 Linux 操作系统。 有关更多信息,请参阅 . 系统要求 Ec
核心:Java 包,包含所有核心功能,如 OSGi 服务、侦听器或调度程序,以及与组件相关的 Java 代码,如 servlet 或请求过滤器。 ui.apps:包含项目的 /apps(和 /etc)部分,即 JS&CSS 客户端库、组件、模板、运行...
核心:Java 包,包含所有核心功能,如 OSGi 服务、侦听器或调度程序,以及与组件相关的 Java 代码,如 servlet 或请求过滤器。 ui.apps:包含项目的 /apps(和 /etc)部分,即 JS&CSS 客户端库、组件、模板、运行...
这是(以下简称为OSGi CDI )的实现。 执照 从源头建造 该构建使用Maven,因此对于大多数开发人员来说应该看起来很熟悉。 mvn clean install 代言人 主要工件是CDI组件运行时( CCR )实现。 又名扩展包: ...
R-OSGi 是一套适用于任意满足 OSGi 架构的分布式通讯组件。它以 jar 的形式发布,部署容易,使用也较为便捷。 Java邮箱地址验证 jaev jaev 是一个用来验证电子邮箱地址是否有效的 Java 项目。 Java的FastCGI网关 ...