[Ordering] Osgi and Eclipse3

xiaoxiao2021-03-06  14

This article is taken from: http://blog.μicp.net/?play=reply&id=79 osgi, I really pay attention to this vocabulary is at last week's BEA User Group Communication, a Taiwanese did a relevant speech, actually OSGi Just a business specification, I didn't expect to be applied by the Eclipse. An important difference between the Eclipse 3.0 platform and the Eclipse2.1 platform is that the Eclipse3.0 platform is built on a Java framework, namely the OSGi service platform. Osgi adopts, so that Eclipse has stepped up the development path of the full dynamic platform. From Eclipse 3.0 m5 begins, Runtime uses an OSGI standard, but is still compatible with the existing Extension mechanism. Osgi, Open Services Gateway Initiative, originated in March 1999, is organized by some household gateway related industrial manufacturers, and there are currently more than 80 manufacturers. Includes IBM, Sun, BMW, Motorola, Nortel, Nokia, Philips, Panasonic, Sony, Toshiba, Echelon, etc. The latest standard is Osgi Specification 3.0. The most important purpose of the OSGI standard was developed, and it is to provide a complete point-to-point service delivery solution for the remote service provider (Service Provider) and the local device (Device). Therefore, OSGI defines an open platform that allows the applications and the value-added services provided by the remote software service provider to download the user's gateway, and automatically Installation execution, and the gateway referred to herein is usually a device connected to home network, office network and a wide area network, such as machine box (SET-TOP BOX; STB), ADSL data machine, Cable Modem, Residential Gateway, etc. Through this open platform, the service software and equipment developed by different manufacturers can communicate and use each other. In the FAQ on the OSGi web site, pointed out that OSGi application directions include: Services in the Home: Communication Information / entertainment Safety and security monitoring Energy management and metering Appliance diagnostics and servicing Telemedicine and healthcare monitoring Services in the Car: Navigation Emergency assistance Mobile commerce Information / entertainment Vehicle diagnostics Location-based services Again, we see java succeeded in J2ME. We can see many big-name companies in the OSGi member name list which include many companies come from many industries. recent developments OSGi in the software industry, most people jump for joy Mo, is the Eclpise Java IDE support Osgi standard. This is an interesting phenomenon that is originally designed to other industries, but there is an extraordinary performance in the soft industry.

This also reminds me of the history of Java, which is also designed for the Embedded system, but unexpectedly won the attention of all parties in the age of Internet, and in Enterprise Application is unbeaten ... Osgi uses Micro-Kernel (According to the manner's statement, it is an architecture that is derived from the microcaround of the Linux operating system, and an unlimited extension can be provided. OSGi's bundles online update feature, as well as the labor execution capability of the application, is the niche of the development of applications. Eclipse 3.0 does not replace the original Plugin mechanism with OSGI. It has just made work with standard compatibility: gives users a series of APIs to access. In this process, you must do some changes (such as Plugin Registry and Loading mechanisms) to complete compatibility with OSGi standards. The initial Plugin core only supports static extensions, that is, if you want to change a already existing PLUG, you must restart Core, that is, to exit Eclipse and restart. There are many people asking if eclipse is compatible with OSGi specifications rather than other specifications? Before Eclipse was donated, Eclipse was developed by OTI, and its goal was to develop an embedded Java software development platform. On the Internet now, there are still many connections to Visual Age Micro Edition (Vame). This is also a reason why SWT is conceived, they want to use SWT to use the user interface in the embedded device. This kind of origin explained why I chose the OSGi specification. Another reason is that there is no other specification in addition to OSGI. The OSGI specification is widely supported in lightweight service architecture applications. Moreover, Osgi is supported by a well-known company in many telecommunications industry and a well-known company in other industries. They need to use Osgi to compete with Sun's J2ME. The Eclipse 3.0 platform is based on the OSGi (Open Services Gateway Initiative service platform, so it is necessary to introduce the OSGi framework. The OSGi framework OSGi framework is a general, secure, manageable Java framework, which supports Deployment for "Bundle" and downloadable service applications. With OSGi-compatible devices, you can download and install an OSGi standard Bundle, and you can also delete bundle no longer need. In addition, installed bundle can register Group Services, these services can be shared by other bundle in strict control of the OSGi framework. The OSGI framework manages Bundle installation and updates in an OSGi environment in a dynamic and upgradeable manner, and manages Bundle and services. (Service) dependencies. Bundle In the OSGi service platform, bundle is the only entity for deploying Java applications. A bundle consists of Java classes and other resources, providing features to end users, providing service components (Serveices) to other Bundle. Bundle is deployed as a JAR file. It can be said that a bundle is a JAR file, which includes: 1> to accommodate resources for zero or more services. These resources can be a Java class file or other Data files such as HTML files, icon files, etc. 2> accommodate a manifest file. This file describes the content of the JAR file and configuration information related to Bundle. 3> State up the package (package) of other resources such as Java Dependencies. 4>

Indicates a Java class in bundle as an implementation class for the Bundle Activator interface. Sosci framework must instantiate the class and call the Start and STOP methods to start and stop bundle. Manifest.mf files Each bundle has a manifest that describes its own information .Mf file, this file is located in the meta-inf directory in the JAR file. We know that when generating a normal Java JAR file, you will ask for a manifest.mf file with the JAR file together. Manifest.mf file content The format may be as follows: Manifest-Version: 1.0 Ant-Version: Apache Ant 1.5.3 Created-by: 1.4.2_04-b05 (Sun Microsystems Inc.) In the OSGI frame, each bundle's manifest.mf file may include the above In addition, you have defined your own OSGi Manifest content format, for example: manifest-version: 1.0 Ant-version: Apache Ant 1.5.3 Created-by: 1.4.2_04-b05 (Sun Microsystems Inc.) bundle-activator: test. osgi.exam2.Activator Export-Package: test.osgi.exam2.service Bundle-Name: English dictionary Bundle-Description: a bundle that registers an English dictionary service Bundle-Version: 1.0.0 the embodiment shown is a set MANIFEST Header / Value, such as the value of the bundle-activator header is TEST.OSGI.Exam2.activator. Defines a set of standard Manif in the OSGi framework. EST header, each header has its own specific meaning. The value of the bundle-activator header information defined in the above example Test.osgi.exam2.actiVator is used to start and stop the class name of "English Dictionary" bundle. The value of the export-package header information TEST.OSGI.Exam2.service indicates the package name that can be exported, namely TEST.OSGI.EXAM2.Service Packets can be imported and used in other bundle (service). Bundle controlled A bundle may be in the following state: ■ Installed (INSTALLED) When the OSGi framework is installed, the dependency of the Bundle's local code will be parsed. If it fails, the bundle will not be installed. Once Bundle is Installing, the OSGi framework will control the entire lifecycle of the bundle (such as start, stop, update, uninstall). ■ Resolved) When the OSGi framework successfully parses the dependencies of the Bundle's local code, the bundle is Enter the parsing state. These dependencies include: 1> Bundle's manifest.mf file, the class path dependencies defined by the Manifest head bundle-classpath. 2>

In the manifest.mf file of the bundle, the dependency defined by the manifest header export-package and import-package. ■ STARTING once the bundle is started, the Bundle's status is set to Active and continues until the bundle is stopped Before starting, the class of Manifest Head Bundle-Activator defined in the manifest.mf file will be instantiated. The START method of this class is called to start bundle. ■ Stopping, once bundle is stopped, the Bundle's status It is set to resolved. Before stop, the Bundle-Activator class defined above is called to stop bundle. ■ Active The bundle that has been activated can be updated. At any time, OSGi The framework can only meet a bundle's unique version available. Bundle's update operation Support This bundle is ported to a high version or backward-compatible version. ■ Uninstalled, before uninstall, the bundle-activator class definition mentioned above The Uninstall method is called to uninstall bundle, which will make the OSGI framework to remind other bundle it is performing uninstall operation, and set the Bundle's state to Uninstall. If the bundle is related to other bundle, if it exports some Bundle The package (ie, the export-package value is defined in the bundle), and the OSGi framework will continue to ensure that these packages are still available without being restarted. If the bundle doesn't matter with other bundle, the OSGi framework will restore it to the Bundle is installed in a state. The following Bundle status describes the control status of bundle. Class loading bundle is a JAR file, the primary problem facing the OSGi framework is how to get it at any time. "The class files and other resources in the Bundle in the frame. For each installed or resolved bundle, the OSGi framework creates the bundle's classloader. This ClassLoader It is also built in the entrustment model shown in Figure 3 below. Where: 1> Bootstrap class load is loaded in the Java core API. 2> SystemClassLoader class loader can be a system class route loader and a standard extension loader It can also be a class or user specified class or user specified class or user-specified class or user-specified class on a class or Java extended path on a class or a Java extension path. 3> Bundle-classPath header in the bundle-classpath header Class file. If the bundle needs to import the package exported in other bundles, the instance of these bundle's class-loaded instances should be built in the delegate model as shown in FIG. And provide the bundle. In the above, please refer to the OSGi framework, please refer to it: http://www.osgi.org Eclipse3.0 plugin and OSGi Bundle OSGi service platform specification is an open architecture, users can Your own needs to achieve this specification. Eclipse3.0 provides an implementation of this specification. We know that the basic module units in OSGI are bundle, and Plug-in is in Eclipse2.1. The plug-in is often manifested as a folder in the Plugins directory. For example, the following directory structure: D: / Eclipse Plugins Eclipseme DOCS ICONS

Lib - About.html - Changes.txt - Credits.txt - Eclipseme.jar - jetty-license.html - license.txt - plugin.properties - plugin.xml - rm.txt - Toc.xml Org.Apache.ant_1. 5.3 The above Eclipseme plug-in provides an Eclipse2.1 platform and J2ME integration. In each Eclipse2.1 plugin, it contains a plugin.xml file, which describes the plug-in, version number, JAR package and plug-in to use. Extended points, etc. ■ Plugin.xml plug-in list file ■ Plugin.properties is accommodated by Plugin.xml references. ■ About.html certificate information ■ * .jar plugin required class file ■ lib houses third-party JAR package ■ ICons Accommine ICON files, usually GIF format ■ DOCS accommodation document file, usually HTML format ■ Toc.xml document structure list file ■ (Other files) In Eclipse 3.0, plugins not only express as a folder in the plugins directory, Includes an MF file. This MF file can be located in the plugin folder. It can also be in the configuration / org.eclipse.osci / manifests directory. Such as: Example 1: D: / Eclipse Configuration Org.eclipse.osgi Manifests - Eclipseme_0.1.0.mf Example 2: D: / Eclipse Plugins Org.eclipse.osci_3.0.0 Meta-INF - Manifest.mf In Eclipse3.0, the plugin can also be called bundle.bundle class files and resource files are the JAR files and other resource files under the plugin folder, and the bundle's Manifest file is the MF file mentioned above. The plugin information of Eclipse is configured in PLUGIN.XML .Osgi bundle information is configured in the manifest.mf file. Let's talk about their contacts. Plugin.xml consists of three parts. 1> Plugin Basic information. Such as plug-name, plugin ID number, plugin version number, plugin provider name, and plug-in class full-defined name. 2> Plugin's dependencies and plug-ins of plug-ins. 3>

转载请注明原文地址:https://www.9cbs.com/read-48911.html

New Post(0)