The OSGi Service Compendium is described in the OSGi Compendium and Enterprise specifications . It specifies a number of services that may be available in an OSGi runtime environment. Although the OSGi Core Framework specification is useful in itself already, it only defines the OSGi core infrastructure. The services defined in the compendium specification define the scope and functionality of some common services that bundle developers might want to use. Here is a quick summary of the popular ones:
Log Service
Chapter 101 in the Compendium and Enterprise specifications.
The Log Service provides a general purpose message logger for the OSGi Service Platform. It consists of two services, one for logging information and another for retrieving current or previously recorded log information.
The JBoss OSGi Framework provides an implementation of the Log Service which channels logging information through to the currently configured system logger.
Http Service
Chapter 102 in the Compendium and Enterprise specifications.
The Http Service supports a standard mechanism for registering servlets and resources from inside an OSGi Framework. This can be used to develop communication and user interface solutions for standard technologies such as HTTP, HTML, XML, etc.
Configuration Admin Service
Chapter 104 in the Compendium and Enterprise specifications.
The Configuration Admin service allows an operator to set the configuration information of deployed bundles.
The JBoss OSGi Framework provides an implementation of the Configuration Admin Service which obtains its configuration information from the JBoss Application Server configuration data, for instance the
standalone.xml
file.
Metatype Service
Chapter 105 in the Compendium and Enterprise specifications.
The Metatype Service specification defines interfaces that allow bundle developers to describe attribute types in a computer readable form using so-called metadata. This service is mostly used to define the attributes and datatypes used by Configuration Admin Service information.
User Admin Service
Chapter 107 in the Compendium and Enterprise specifications.
Bundles can use the User Admin Service to authenticate an initiator and represent this authentication as an Authorization object. Bundles that execute actions on behalf of this user can use the Authorization object to verify if that user is authorized.
Declarative Services Specification
Chapter 112 in the Compendium and Enterprise specifications.
The Declarative Services (DS) specification describes a component model to be used with OSGi services. It enables the creation and consumption of OSGi services without directly using any OSGi APIs. Service consumers are informed of their services through injection. The handling of the OSGi service dynamics is done by DS. See also the Blueprint Specification .
Event Admin Service
Chapter 113 in the Compendium and Enterprise specifications.
The Event Admin Service provides an asynchronous inter-bundle communication mechanism. It is based on a event publish and subscribe model, popular in many message based systems.
Chapter 121 in the Enterprise specification.
The OSGi Blueprint Specification describes a component framework which simplifies working with OSGi services significantly. To a certain extent, Blueprint and DS have goals in common, but the realization is different. One of the main differences between Blueprint and DS is in the way service-consumer components react to a change in the availability of required services. In the case of DS the service-consumer will disappear when its required dependencies disappear, while in Blueprint the component stays around and waits for a replacement service to appear. Each model has its uses and it can be safely said that both Blueprint as well as DS each have their supporters. The Blueprint specification was heavily influenced by the Spring framework.
Remote Services Specifications
Chapters 13 and 122 in the Enterprise specification.
OSGi Remote Services add distributed computing to the OSGi service programming model. Where in an ordinary OSGi Framework services are strictly local to the Java VM, with Remote Services the services can be remote. Services are registered and looked up just like local OSGi services, the Remote Services specifications define standard service properties to indicate that a service is suitable for remoting and to find out whether a service reference is a local one or a remote one.
JTA Specification
Chapter 123 in the Enterprise specification.
The OSGi-JTA specification describes how JTA can be used from an OSGi environment. It includes standard JTA-related services that can be obtained from the OSGi registry if an OSGi application needs to make use of JTA.
JMX Specification
Chapter 124 in the Enterprise specification.
The OSGi-JMX specification defines a number of MBeans that provide management and control over the OSGi Framework.
JDBC Specification
Chapter 125 in the Enterprise specification.
The OSGi-JDBC specification makes using JDBC drivers from within OSGi easy. Rather than loading a database driver by class-name (the traditional approach, which causes issues with modularity in general and often requires external access to internal implementation classes), this specification registers the available JDBC drivers under a standard interface in the Service Registry from where they can be obtained by other Bundles without the need to expose internal implementation packages of the drivers.
JNDI Specification
Chapter 126 in the Enterprise specification.
The OSGi-JNDI specification provides access to JNDI through the OSGi Service Registry. Additionally, it provides access to the OSGi Service Registry through JNDI. The special
osgi:
namespace can be used to look up OSGi services via JNDI.
JPA Specification
Chapter 127 in the Enterprise specification.
The OSGi-JPA specification describes how JPA works from within an OSGi framework.
Web Applications Specification
Chapter 128 in the Enterprise specification.
The Web Applications specification describes Web Application Bundles. A WAB is a
.WAR
file which is effectively turned into a bundle. The specification describes how Servlets can interact with the OSGi Service Registry and also how to find all the available Web Applications in an OSGi Framework.
Additionally, the Web Applications spec defines a mechanism to automatically turn an ordinary
.WAR
file into a Web Application Bundle.
Service Tracker Specification
Chapter 701 in the Compendium and Enterprise specifications.
The Service Tracker specification defines a utility class, ServiceTracker. The ServiceTracker API makes tracking the registration, modification, and unregistration of services much easier.
Images courtesy of the OSGi Alliance .