June 17 is Apache Karaf as Apache top project. Karaf is a run-time package that contains an OSGI framework (Equinox or Felix), a command shell (Felix Gogo), and a number of utilities built into it by default.
Although Equinox and Felix can be used alone, the KARAF is designed to combine the excellent OSGI capabilities of both frameworks and ensure that they are out of the box. For example, it contains a configurable log system (based on log4j, but is packaged for many common logging systems), remote access via SSH, configuration via configadmin (source code in the ETC directory), and built-in Jaas support. Not only that, Karaf also installs the Pax URL's MVN protocol, which allows the bundle to be installed from the MAVEN central repository (which is automatically packaged as bundles if necessary).
In addition, KARAF proposes the concept of a feature, which is a collection of bundles that can be installed as a group into the running OSGi runtime. Features include support for the OBR, jetty, and spring, which is available out of the box. That way, if you need to install multiple bundles, but there is no strict run-time dependency between these bundles, this kind of support can be greatly simplified.
Before migrating to the Apache Felix Project, Karaf was ServiceMix Kernel and eventually became the top project of Apache. Karaf is also part of other frameworks, such as Eclipse Virgo and Eclipsert packages, which provide preconfigured frameworks and easy-to-use OSGi bundles, which makes it easier than ever to get started with OSGi runtime.
Http://felix.apache.org/downloads.cgi#framework
Http://git.eclipse.org/c/equinox/rt.equinox.framework.git/commit/bundles/org.eclipse.osgi
Karaf as a mature and excellent OSGi operating environment and container has been a lot of Apache projects as a base container, such as: Apache Geronimo, Apacheservicemix, Fuse ESB, this shows Karaf in performance, It is a good choice for both function and stability.
The Karf is analyzed from four aspects, which are KARAF environment variable, starting level, new concept and core technology appearing in Karaf.
Karaf involves two environment variables, the Karaf_home and Karaf_base,karaf_home directories are the required files for the boot Karaf, and the directory structure is as follows:
The Lib directory contains three files, Karaf.jar, Karaf-client.jar, and Karaf-jaas-boot.jar, which are added to Karaf classpath by default.
The ETC directory mainly contains the selection configuration of the OSGi framework, such as what OSGi framework implementation is used.
The system directory contains the OSGi framework implementation jar packages implemented by Eclipse and Felix.
The KARAF has 6 boot levels, 5, 8, 10, 15, 30, 40, respectively. The order in which they are started is to start with a small number first.
- Level 5 contains the MVN protocol and the Wrap protocol that comply with the OSGi URL handlers Service Specification (11th chapter of the OSGi Core specification).
- Level 8, including log adapters (including log4j,slf4j,commons-logging, etc.) and log services.
- Level 10, including the specification API, Configuration Management Service (104), User Preference Service (106).
- Level 15, including the thermal deployer.
- 30 levels, including Gshell, Spring DM, JMX and so on.
- Level 40, which contains the initiator of the Gshell, Gshell converted to a usable state when running to this level.
Karaf set two default levels, 60 and 100,60, which means that when an external application is deployed to Karaf, Karaf will set the application's startup level to 60;100 by default when Karaf starts to level 100. That is, all bundles below 100 will be started.
The concept of feature is referenced in Karaf. Feature is a deployment descriptor for a bundle set that conforms to a feature, as shown in the following configuration file:
XML code
- <features>
- <repository>urn:r1</repository>
- <feature name="F1">
- <config name="C1">
- k=v
- </config>
- <bundle>b1</bundle>
- <bundle>b2</bundle>
- </feature>
- <feature name="F2">
- <feature>f1</feature>
- <bundle>b3</bundle>
- </feature>
- </features>
The KRARF can be statically switched to the OSGi framework implementation, which is implemented as follows:
- To get the relative path of the OSGi implementation jar package from the configuration file
- Use the reflection mechanism to add this jar package to the current ClassLoader
- Read the/meta-inf/services/org.osgi.framework.launch.frameworkfactory file to get the Frameworkfactory implementation class name
- Instantiate this class with a reflection mechanism and create a framework instance and start
Karaf relies on Equinox and Felix,karaf many of the Apache projects as the foundation framework