This article has multiple issues. Please help improve it or discuss these issues on the talk page.
This article needs attention from an expert on the subject. Please add a reason or a talk parameter to this template to explain the issue with the article. Consider associating this request with a WikiProject.(October 2011)
The OSGi (Open Service Gateway initiative) specification describes a modular system and a service platform for the Java programming language that implements a complete and dynamic component model, something that does not exist in standalone Java/VM environments. Applications or components, coming in the form of bundles for deployment, can be remotely installed, started, stopped, updated, and uninstalled without requiring a reboot; management of Java packages/classes is specified in great detail. Application life cycle management is implemented via APIs that allow for remote downloading of management policies. The service registry allows bundles to detect the addition of new services, or the removal of services, and adapt accordingly.
The OSGi Alliance, formerly known as the Open Services Gateway initiative, now an obsolete name, is an open standards organization founded in March 1999 that originally specified and continues to maintain the OSGi standard.
The OSGi specification is developed by the members in an open process and made available to the public free of charge under the OSGi Specification License. The OSGi Alliance has a compliance program that is open to members only. As of November 2010, there are seven certified OSGi framework implementations. A separate page lists both certified and non-certified OSGi Specification Implementations, which include OSGi frameworks and other OSGi specifications.
Any framework that implements the OSGi standard provides an environment for the modularization of applications into smaller bundles. Each bundle is a tightly coupled, dynamically loadable collection of classes, jars, and configuration files that explicitly declare their external dependencies (if any).
The framework is conceptually divided into the following areas:
Bundles are normal jar components with extra manifest headers.
The services layer connects bundles in a dynamic way by offering a publish-find-bind model for Plain Old Java Interfaces (POJI) or Plain Old Java Objects (POJO).
The layer that defines encapsulation and declaration of dependencies (how a bundle can import and export code).
The layer that handles the security aspects by limiting bundle functionality to pre-defined capabilities.
Defines what methods and classes are available in a specific platform. There is no fixed list of execution environments, since it is subject to change as the Java Community Process creates new versions and editions of Java. However, the following set is currently supported by most OSGi implementations:
A bundle is a group of Java classes and additional resources equipped with a detailed manifest MANIFEST.MF file on all its contents, as well as additional services needed to give the included group of Java classes more sophisticated behaviors, to the extent of deeming the entire aggregate a component.
Below is an example of a typical MANIFEST.MF file with OSGi Headers:
Bundle-Name: Hello World
Bundle-Description: A Hello World bundle
The meaning of the contents in the example is as follows:
Bundle-Name: Defines a human-readable name for this bundle, Simply assigns a short name to the bundle.
Bundle-SymbolicName: The only required header, this entry specifies a unique identifier for a bundle, based on the reverse domain name convention (used also by the java packages).
Bundle-Description: A description of the bundle's functionality.
Bundle-ManifestVersion: Indicates the OSGi specification to use for reading this bundle.
Bundle-Version: Designates a version number to the bundle.
Bundle-Activator: Indicates the class name to be invoked once a bundle is activated.
Export-Package: Expresses which Java packages contained in a bundle will be made available to the outside world.
Import-Package: Indicates which Java packages will be required from the outside world to fulfill the dependencies needed in a bundle.
A Life Cycle layer adds bundles that can be dynamically installed, started, stopped, updated and uninstalled. Bundles rely on the module layer for class loading but add an API to manage the modules in run time. The life cycle layer introduces dynamics that are normally not part of an application. Extensive dependency mechanisms are used to assure the correct operation of the environment. Life cycle operations are fully protected with the security architecture.
The bundle has been successfully installed.
All Java classes that the bundle needs are available. This state indicates that the bundle is either ready to be started or has stopped.
The bundle is being started, the BundleActivator.start method will be called, and this method has not yet returned. When the bundle has an activation policy, the bundle will remain in the STARTING state until the bundle is activated according to its activation policy.
The bundle has been successfully activated and is running; its Bundle Activator start method has been called and returned.
The bundle is being stopped. The BundleActivator.stop method has been called but the stop method has not yet returned.
The bundle has been uninstalled. It cannot move into another state.
Below is an example of a typical Java class implementing the BundleActivator interface:
The OSGi Alliance has specified many services. Services are specified by a Java interface. Bundles can implement this interface and register the service with the Service Registry. Clients of the service can find it in the registry, or react to it when it appears or disappears.
The table below shows a description of OSGi System Services:
The logging of information, warnings, debug information or errors is handled through the Log Service. It receives log entries and then dispatches these entries to other bundles that subscribed to this information.
This service allows an operator to set and get the configuration information of deployed bundles
Facilitates the coordination of automatic detection and attachment of existing devices. This is used for Plug and Play scenarios.
This service uses a database with user information (private and public) for authentication and authorization purposes.
The IO Connector Service implements the CDC/CLDCjavax.microedition.io package as a service. This service allows bundles to provide new and alternative protocol schemes.
Offers an alternative, more OSGi-friendly mechanism to using Java’s default Properties for storing preferences.
The dynamic nature of services—they can come and go at any time—makes writing software harder. The Component Runtime specification can simplify handling these dynamic aspects by providing an XML based declaration of the dependencies.
Standardizes access to some of the responsibilities of the management agent.
Provides an inter-bundle communication mechanism based on a publish-and-subscribe model.
Simplifies the management of an environment with many different types of applications that are simultaneously available.
The table below shows a description of OSGi Protocol Services:
Allows information to be sent and received from OSGi using HTTP.
The Alliance has a board of directors that provides the organization's overall governance. OSGi officers have various roles and responsibilities in supporting the alliance. Technical work is conducted within Expert Groups (EGs) chartered by the board of directors, and non-technical work is conducted in various working groups and committees. The technical work conducted within Expert Groups include developing specifications, reference implementations, and compliance tests. These Expert Groups have produced five major releases of the OSGi specifications (As of 2012[update]).
Dedicated Expert Groups exist for the enterprise, mobile, vehicle and the core platform areas.
The Enterprise Expert Group (EEG) is the newest EG and is addressing Enterprise / Server-side applications. In November 2007 the Residential Expert Group (REG) started to work on specifications to remotely manage residential/home-gateways. In October 2003, Nokia, Motorola, IBM, ProSyst and other OSGi members formed a Mobile Expert Group (MEG) that will specify a MIDP-based service platform for the next generation of smart mobile phones, addressing some of the needs that CLDC cannot manage - other than CDC. MEG became part of OSGi as with R4.
In 2003, Eclipse selected OSGi as the underlying runtime for the plug-in architecture used for the Eclipse Rich Client Platform and the IDE platform. Eclipse itself includes sophisticated tooling for developing OSGi bundles and there are a number of other Eclipse plug-ins aimed at supporting OSGi behaviour (e.g., both ProSyst and Knopflerfish have Eclipse plug-ins available specifically for OSGi developers).
Enhancements in security and policies: The new Conditional Permission Admin service provides an elegant and simple way to manage networked services securely. It also supports dynamic policies that can depend on external (custom) conditions. Combined with R4 support for digital signatures, this provides a central security solution to large deployments of products using the OSGi Service Platform.
A Declarative Services specification that addresses memory footprint issues that can prevent small embedded devices from using a service oriented architecture to support multiple applications. Additionally, it significantly simplifies the service-oriented programming model by declaratively handling the dynamics of services.
Compatibility with Release 3, requiring no changes for existing OSGi bundles, applications, or services.
Bundle Tracker: Track and respond to changes in bundle presence and state
Service Hooks: Allow introspection and behavior modification of service calls to inject security or dynamicism
Conditional Permissions: Support negative permissions, forbidding specific actions instead of just allowing them
More information can also be specified in each bundle header, such as license information, MIME types and icons. Additionally, changes to Declarative Services allow the easier setting of permissions. Finally, OSGi bundles can now have their return values read.
OSGi R4.2 also introduced a new specification release for the enterprise including support for:
Web Applications: A standardized format for building OSGi web applications packaged using the WAR file format (Sun)