OSGi
![]() | This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
No issues specified. Please specify issues, or remove this template. |
![]() | |
Developer(s) | OSGi Alliance |
---|---|
Stable release | 5
/ June 2012[1] |
Operating system | Java |
Type | Standards organization |
License | OSGi Specification License, Version 1.0 |
Website | www |
The OSGi framework is a module system and service platform for the Java programming language that implements a complete and dynamic component model, something that as of 2012[update] 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 (start, stop, install, etc.) is done 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 specifications have moved beyond the original focus of service gateways, and are now used in applications ranging from mobile phones to the open source Eclipse IDE. Other application areas include automobiles, industrial automation, building automation, PDAs, grid computing, entertainment, fleet management and application servers.
Sponsoring organization
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.
Specification process
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.[2] The OSGi Alliance has a compliance program that is open to members only. As of November 2010, there are seven certified OSGi framework implementations.[3] A separate page lists both certified and non-certified OSGi Specification Implementations, which include OSGi frameworks and other OSGi specifications.
Architecture
![](http://upload.wikimedia.org/wikipedia/commons/thumb/2/28/Osgi_framework.svg/250px-Osgi_framework.svg.png)
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
- Bundles are normal jar components with extra manifest headers.
- Services
- 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.
- Services Registry
- The API for management services (ServiceRegistration, ServiceTracker and ServiceReference).
- Life-Cycle
- The API for life cycle management for (install, start, stop, update, and uninstall) bundles.
- Modules
- The layer that defines encapsulation and declaration of dependencies (how a bundle can import and export code).
- Security
- The layer that handles the security aspects by limiting bundle functionality to pre-defined capabilities.
- Execution Environment
- 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:
- CDC-1.0/Foundation-1.0
- CDC-1.1/Foundation-1.1
- OSGi/Minimum-1.0
- OSGi/Minimum-1.1
- JRE-1.1
- From J2SE-1.2 up to J2SE-1.6
Bundles
![](http://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/Osgi-system-layering.svg/250px-Osgi-system-layering.svg.png)
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-SymbolicName: org.wikipedia.helloworld Bundle-Description: A Hello World bundle Bundle-ManifestVersion: 2 Bundle-Version: 1.0.0 Bundle-Activator: org.wikipedia.Activator Export-Package: org.wikipedia.helloworld;version="1.0.0" Import-Package: org.osgi.framework;version="1.3.0"
The meaning of the contents in the example is as follows[4]:
- 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.
Life-cycle
![](http://upload.wikimedia.org/wikipedia/commons/thumb/c/cc/OSGi_Bundle_Life-Cycle.svg/250px-OSGi_Bundle_Life-Cycle.svg.png)
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.
Bundle State | Description |
---|---|
INSTALLED | The bundle has been successfully installed. |
RESOLVED | All Java classes that the bundle needs are available. This state indicates that the bundle is either ready to be started or has stopped. |
STARTING | 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..
|
ACTIVE | The bundle has been successfully activated and is running; its Bundle Activator start method has been called and returned. |
STOPPING | The bundle is being stopped. The BundleActivator.stop method has been called but the stop method has not yet returned.
|
UNINSTALLED | The bundle has been uninstalled. It cannot move into another state. |
Below is an example of a typical Java class implementing the BundleActivator
interface:
package org.wikipedia;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
private BundleContext context;
public void start(BundleContext context) throws Exception {
System.out.println("Starting: Hello World");
this.context = context;
}
public void stop(BundleContext context) throws Exception {
System.out.println("Stopping: Goodbye Cruel World");
this.context = null;
}
}
Services
![]() | This section needs expansion. You can help by adding to it. (March 2009) |
Standard services
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:
System Services | Description |
---|---|
Logging | 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. |
Configuration Admin | This service allows an operator to set and get the configuration information of deployed bundles |
Device Access | Facilitates the coordination of automatic detection and attachment of existing devices. This is used for Plug and Play scenarios. |
User Admin | This service uses a database with user information (private and public) for authentication and authorization purposes. |
IO Connector | The IO Connector Service implements the CDC/CLDC javax.microedition.io package as a service. This service allows bundles to provide new and alternative protocol schemes.
|
Preferences | Offers an alternative, more OSGi-friendly mechanism to using Java’s default Properties for storing preferences.
|
Component Runtime | 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. |
Deployment Admin | Standardizes access to some of the responsibilities of the management agent. |
Event Admin | Provides an inter-bundle communication mechanism based on a publish-and-subscribe model. |
Application Admin | 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:
Protocol Services | Description |
---|---|
HTTP Service | Allows information to be sent and received from OSGi using HTTP. |
UPnP Device Service | Specifies how OSGi bundles can be developed to interoperate with Universal Plug and Play (UPnP) devices. |
DMT Admin | Defines an API for managing a device using concepts from the Open Mobile Alliance (OMA) device management specifications. |
The table below shows a description of OSGi Miscellaneous Services:
Miscellaneous Services | Description |
---|---|
Wire Admin | Allows the connection between a Producer service and a Consumer service. |
XML Parser | The XML Parser service allows a bundle to locate a parser with desired properties and compatibility with JAXP. |
Measurement and State | The Measurement and State service allows and simplifies the correct handling of measurements in an OSGi service platform. |
Organization
The OSGi Alliance was founded by Ericsson, IBM, Motorola, Sun Microsystems and others in March 1999 (before incorporating as a nonprofit corporation it was called the Connected Alliance).
Among its members are (as of May 2007[update]) more than 35 companies from quite different business areas, for example IONA Technologies, Ericsson, Deutsche Telekom, IBM, Makewave (formerly Gatespace Telematics), Motorola, Orga Systems, Nokia, NTT, Oracle, ProSyst, Red Hat, Samsung Electronics, Siemens, VMware (SpringSource), and Telefonica.
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 four major releases of the OSGi specifications (As of 2007[update]).
There are dedicated Expert Groups 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.
Community
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).
There is a vibrant free software community revolving around the OSGi specification. Some widely used open source implementations are Equinox OSGi, Apache Felix and Knopflerfish OSGi. Regarding tooling, build system support and testing, the OPS4J Pax projects provide a lot of useful components and expertise.
Specification versions
- OSGi Release 1 (R1): May 2000
- OSGi Release 2 (R2): October 2001
- OSGi Release 3 (R3): March 2003
- OSGi Release 4 (R4): October 2005 / September 2006
- Core Specification (R4 Core): October 2005
- Mobile Specification (R4 Mobile / JSR-232): September 2006
- OSGi Release 4.1 (R4.1): May 2007 (AKA JSR-291)
- OSGi Release 4.2 (R4.2): September 2009
- Enterprise Specification (R4.2): March 2010
- OSGi Release 4.3 (R4.3): April 2011
- Core: April 2011
- Compendium and Residential: May 2012
- OSGi Release 5 (R5): June 2012
- Core and Enterprise: June 2012
New in OSGi Release 4
The new features of OSGi R4 in brief are as follows:
- New modularization capabilities providing enhanced encapsulation of networked services that can share a single Virtual Machine (VM).
- Modularized class sharing and hiding of implementation details.
- Methods for handling multiple versions of the same classes so old and new applications can execute within the same VM.
- Localization of OSGi bundle manifests enabling service deployment anywhere.
- 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.
New in Release 4.1
OSGi R4.1 was a minor revision intended to clarify certain aspects of bundle initialization and loading in order to improve third party usage. It added no new services or major features.
New in Release 4.2
OSGi R4.2 was a significant release that added several new services and capabilities,[5] including:
- Framework launching: Standardized means to launch OSGi from various providers
- Remote Services: Allows the exporting of services to remote VMs (formerly known as Distribute OSGi)
- Blueprint Service: Dependency injection and inversion of control (similar to Spring) that allows external configuration of bundle dependencies
- 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[6] including support for:
- Web Applications: A standardized format for building OSGi web applications packaged using the WAR file format (Sun)
- JPA Service: Provides a reliable standard mechanism to use the Java Persistence API in OSGi
- JNDI Service: Allows integration of the OSGi service registry and the Java Naming and Directory Interface
- JDBC Service: Provides an OSGi lifecycle-aware mechanism to obtain connections to an external Database
New in Release 4.3
- Generics: The framework now uses JDK5 generics in several places. However, Java 1.4 can still be targeted using "-source 1.5 -target jsr14" switches to javac.
- Capabilities: A set of attributes in a namespace in a module's meta information, such as osgi.wiring.package Export-Package.
- Requirements: A filter expression over the attribute set of a capability, such as osgi.wiring.package Import-Package.
- adapt: Replaces Framework services; adapts Bundle to another type (if supported). Replaces PackageAdmin and StartLevel services with APIs which a Bundle can be adapted to.
- WeavingHook: The WeavingHook services allows load-time bytecode weaving.
- ResolverHooks and BundleHooks: Replaces the nested frameworks and composite bundles proposal with low-level capabilities to influence requirement-capability matching.
- Service EventListener Hook: Replaces Service Event Hook with finer-grained event delivery control.
Related RFCs and Java Specifications
- RFC-2608 (Service Location Protocol)
- Sun JINI (Java Intelligent Network Infrastructure)
- Sun JCP JSR-8 (Open Services Gateway Specification)
- Sun JCP JSR-232 (Mobile Operational Management)
- Sun JCP JSR-246 (Device Management API)
- Sun JCP JSR-249 (Mobile Service Architecture for CDC)
- Sun JCP JSR-277 (Java Module System)
- Sun JCP JSR-291 (Dynamic Component Support for Java SE - AKA OSGi 4.1)
- Sun JCP JSR-294 (Improved Modularity Support in the Java Programming Language)
Related standards
- MHP / OCAP
- Universal Plug and Play (UPnP)
- DPWS
- ITU-T G.hn
- LonWorks
- CORBA
- CEBus
- EHS (KNX) / CECED CHAIN
- Java Management Extensions
Projects using OSGi
- Apache Aries - Blueprint Container implementations and extensions of application-focused specifications defined by OSGi Enterprise Expert Group.
- Apache Karaf - an OSGi based runtime that provides a lightweight container onto which various components and applications can be deployed.
- Apache Felix - an implementation of the OSGi R4 Service Platform and other OSGi-related technologies
- Apache Sling - OSGi-based applications layer for JCR content repositories
- Business Intelligence and Reporting Tools (BIRT) Project - Open source reporting engine
- DataNucleus - open source data services and persistence platform in service oriented architectures
- EasyBeans - open source EJB 3 container
- Eclipse - open source IDE and rich client platform
- Paremus Service Fabric - an autonomic OSGi based private Cloud runtime that supports BluePrint, Declarative Services & Scala based applications.
- Eclipse Virgo - open source microkernel-based server constructed of OSGi bundles and supporting OSGi applications
- Event Insight - SAP BusinessObjects complex event processing sdn
- GlassFish (v3) - application server for Java EE
- Fuse ESB - a productized and supported release of ServiceMix 4.
- GX WebManager Community Edition - An Enterprise Web Content Management System based on OSGi, spring and JCR
- JBoss - Red Hat's JBoss Application Server
- JOnAS 5 - open source Java EE 5 application server
- JOSSO 2 - Atricore's open source standards-based Identity and Access Management Platform
- Netbeans - open source IDE and rich client platform
- Nuxeo - open source ECM Service Platform
- OpenEJB - open source OSGi-enabled EJB 3.0 container that can be run both in standalone or embedded mode
- SpringSource dm Server - open source microkernel-based server constructed of OSGi bundles and supporting OSGi applications
- Weblogic - Oracle Weblogic Application Server
- WebSphere - IBM Websphere JEE Application Server
- WSO2 Carbon - Base platform for WSO2’s enterprise-grade Open source middleware stack.
- Atlassian Confluence and JIRA - the plug-in architecture for this enterprise wiki and issue tracker uses OSGi
Current framework implementations
Name | License |
---|---|
Knopflerfish | Open source |
Apache Felix | Open source |
Concierge OSGi | Open source |
Equinox OSGi | Open source |
References cited
- ^ "OSGi Alliance | Specifications / HomePage". osgi.org. 2012 [last update]. Retrieved July 12, 2012.
{{cite web}}
: Check date values in:|year=
(help)CS1 maint: year (link) - ^ OSGi Specification License
- ^ "Certified Products". OSGi Alliance. Retrieved 2010-11-01.
- ^ Creating OSGi bundles by Costin Leau
- ^ "OSGi 4.2 released". Retrieved February 16, 2010.
- ^ "OSGi ALLIANCE PUBLISHES ENTERPRISE SPECIFICATION" (PDF). Retrieved November 28, 2011.
See also
- Apache Felix
- Concierge OSGi
- Equinox
- Knopflerfish
- OSGi Specification Implementations
- OSGi-Tooling tooling page on OSGi
- ProSyst mBS
Further reading
![]() | This "Further reading" section may need cleanup. (April 2011) |
- Alves, Alexandre de Castro (July 28, 2011), OSGi in Depth (1st ed.), Manning Publications, p. 325, ISBN 1-935182-17-X
- McAffer, Jeff; VanderLei, Paul; Archer, Simon (February 24, 2010), OSGi and Equinox: Creating Highly Modular Java Systems (1st ed.), Addison-Wesley Professional, p. 460, ISBN 0-321-58571-2
- Joseph Gédéon, Walid (November 5, 2010), OSGi and Apache Felix 3.0 Beginner's Guide (1st ed.), Packt Publishing, p. 336, ISBN 1-84951-138-1
- Walls, Craig (July 2009), Modular Java with OSGi and Spring (1st ed.), Pragmatic Bookshelf, p. 250, ISBN 978-1-934356-40-1
- Hall, Richard S (September 2009), OSGi in Action (1st ed.), Manning Publications, p. 375, ISBN 1-933988-91-6
{{citation}}
: Unknown parameter|coauthors=
ignored (|author=
suggested) (help) - Alves, Alexandre de Castro (March 2009), OSGi Application Frameworks (1st ed.), Manning Publications, p. 325, ISBN 978-1-935182-17-7
{{citation}}
: Cite has empty unknown parameter:|coauthors=
(help) - Bartlett, Neil (2009-01-10), OSGi In Practice (PDF) (DRAFT ed.), p. 229
- McAffer, Jeff; VanderLei, Paul; Archer, Simon (September 7, 2009), Equinox and OSGi: The Power Behind Eclipse (1st ed.), Addison-Wesley Professional, p. 480, ISBN 0-321-58571-2
- Mak, Gary (2009), Pro SpringSource dm Server, Apress, p. 250, ISBN 1-4302-1640-9
- Rubio, Daniel (2009-02-12), Pro Spring Dynamic Modules for OSGi Service Platforms (First ed.), Apress, p. 392, ISBN 1-4302-1612-3
- The OSGi Alliance (2003), OSGi Service Platform, Release 3, IOS Press, p. 604, ISBN 1-58603-311-5
- OSGi Service Platform, Core Specification, Release 4, Version 4.1, OSGi Alliance., 2007, p. 228, ISBN 978-90-79350-01-8
- OSGi Service Platform, Core Specification, Release 4, Version 4.2, OSGi Alliance., 2009, p. 332, ISBN 978-90-79350-04-9
- OSGi Service Platform, Service Compendium, Release 4, Version 4.1, OSGi Alliance., 2007, p. 594, ISBN 978-90-79350-02-5
- OSGi Service Platform, Mobile Specification, Release 4, Version 4, OSGi Alliance., 2007, p. 426, ISBN 978-90-79350-03-2
- Kirk Chen, Li Gong. (2001), Programming Open Service Gateways with Java Embedded Server(TM) Technology, Prentice Hall PTR, p. 480, ISBN 0-201-71102-8
- Kayode Odeyemi (2010), Building an OSGI Declarative Service with Maven using Netbeans
- BJ Hargrave (IBM) (2011), OSGi 4.3 Technical Update: What's new?, The Eclipse Foundation
External links
![](http://upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/30px-Commons-logo.svg.png)
![](http://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/40px-Wikibooks-logo-en-noslogan.svg.png)
- Official website
- Oredev 2008 - Architecture - OSGi Now and Tomorrow
- OSGi Training
- Information on Java software components in the form of Enterprise JavaBeans and OSGi bundles
- OSGi Core Concepts Overview
Guidance and information exchange
- Frequently Asked Questions
- OSGi Developer Mail List
- OSGi Open Forum and Discussion Central
- Eclipse Equinox Article Index - Articles on an open source OSGi implementation
- OSGi Users' Forums - Belgium, Brazil, China, France, Germany, Japan, Korea, Spain, Sweden, UK and soon : Italy