JSR-277 :Java Module System
JSR-291 :Dynamic Component Support for Java,based on OSGi principles.
1. OSGi实现模块化的4种方式
(1) It defines exactly what a module is (Java defines only deployment units, like JAR or WAR).
(2) It provides ways to finely set visibility rules between modules.
(3) It defines the lifecycle of a module (a module can be installed, started, stopped, and so on).
(4) It lets modules interact with each other via services.
2.OSGi分层
2.1.Module Layer
The module layer enforces visibility rules between modules, and it achieves this thanks to strict
classloader isolation. By default, a component is really a black box in OSGi. If you want to make
things visible, you need to specify them explicitly; conversely, when using classes, the required
packages must be specified as being visible before you can reference them from other bundles.
2.2. Lifecycle Layer
The lifecycle layer relies on the module layer for classloading and provides a dynamic approach
to bundle management, making it possible to update parts of an application without stopping
it. When a bundle gets to the active state, it’s then able to interact with the service registry,
powered by the top layer of OSGi.
2.3. Service Register Layer
It allows bundles to be used and to interact in a way that takes the dynamic nature of the
system into account.Through the service registry, OSGi offers the ability to register one or
several access points to components through services.
2.4 Security Layer
OSGi security is based on the Java 2 security model, there is no OSGi security service API.
Instead the framework relies on the presence of this former API to provide security functionality
to a bundle.
见附件分层结构图。
3. OSGi Features
3.1 Hot-pluggability
一个技术性的术语指变动一个系统的功能而无需中断当前正在进行的操作。
3.2 Autodiscovery
一台设备能够重复使用另一台设备上的软件。
而上面这两个特性统称为:Dynamic Behavior.