Portable Java Contract Definitions

Background

One of the promises of OSGi is the ability for a bundle to know that the runtime provides the capabilities it needs. At one level this is based on the code package required, however this is insufficient. Packages evolve over time with new methods, interfaces and classes being added. The provider of a package can express the version of the package so a client can select the minimum version it needs and the maximum it will accept. Making use of semantic versioning also allows the provider to make breaking API changes without affecting client bundles. This is the promise, however the Java platform itself does not version its packages, and consequently a variety of versioning strategies are already being employed in the industry.

Approach

Rather than define package versions for each individual package in all Java platform packages, a task that will be neither fun, nor will produce consensus, this document page defines a set of OSGi contracts for various Java specifications. These contracts are then versioned according to the Java specification version. A client bundle can then import the packages required with no version and express a dependency on the OSGi contract that defines the packages and the exact specification version required. A provider of the contract then expresses every version of the contract they support. Consequently, the client bundle is only tied to the specification version and each provider of the contract is free to continue using their chosen versioning strategy. It is worth restating that this contracts approach is only necessary for the Java specifications that do not semantically version their packages. It is neither necessary nor recommended for packages that do follow semantic versioning.

Jakarta EE Contracts

OSGi contract names are advised to be upper camel case (aka Pascal case) with the first segment or segments corresponding to a namespace to ensure uniqueness. The OSGi Specification Project reserves the first segment “OSGi”. Similarly, this design uses the first segment “Jakarta” to define contracts corresponding to the Java based standards defined by the Jakarta EE Working Group, and “Java” to define contracts corresponding to the Java based standards defined by the JCP. The “Javax” prefix is also be reserved, but is not used. What follows is the set of contracts.

A JSON version is also available for download.

Contract Version Packages Comments
JakartaActivation 2.1 jakarta.activation,
jakarta.activation.spi
JakartaActivation 2.0 jakarta.activation Packages renamed for Jakarta EE
JakartaAnnotations 2.1 jakarta.annotation,
jakarta.annotation.security,
jakarta.annotation.sql
JakartaAnnotations 2.0 jakarta.annotation,
jakarta.annotation.security,
jakarta.annotation.sql
Packages renamed for Jakarta EE
JakartaAuthentication 3.0 jakarta.security.auth.message,
jakarta.security.auth.message.callback,
jakarta.security.auth.message.config,
jakarta.security.auth.message.module
JakartaAuthentication 2.0 jakarta.security.auth.message,
jakarta.security.auth.message.callback,
jakarta.security.auth.message.config,
jakarta.security.auth.message.module
Packages renamed for Jakarta EE
JakartaAuthorization 2.1 jakarta.security.jacc
JakartaAuthorization 2.0 jakarta.security.jacc Packages renamed for Jakarta EE
JakartaBatch 2.1 jakarta.batch.api,
jakarta.batch.api.chunk,
jakarta.batch.api.chunk.listener,
jakarta.batch.api.listener,
jakarta.batch.api.partition,
jakarta.batch.operations,
jakarta.batch.runtime,
jakarta.batch.runtime.context
JakartaBatch 2.0 jakarta.batch.api,
jakarta.batch.api.chunk,
jakarta.batch.api.chunk.listener,
jakarta.batch.api.listener,
jakarta.batch.api.partition,
jakarta.batch.operations,
jakarta.batch.runtime,
jakarta.batch.runtime.context
Packages renamed for Jakarta EE
JakartaBeanValidation 3.0 jakarta.validation,
jakarta.validation.bootstrap,
jakarta.validation.constraints,
jakarta.validation.constraintvalidation,
jakarta.validation.executable,
jakarta.validation.groups,
jakarta.validation.metadata,
jakarta.validation.spi,
jakarta.validation.valueextraction
Packages renamed for Jakarta EE
JakartaCDI 4.0 jakarta.decorator,
jakarta.enterprise.context,
jakarta.enterprise.context.control,
jakarta.enterprise.context.spi,
jakarta.enterprise.event,
jakarta.enterprise.inject,
jakarta.enterprise.inject.build.compatible.spi,
jakarta.enterprise.inject.literal,
jakarta.enterprise.inject.se,
jakarta.enterprise.inject.spi,
jakarta.enterprise.inject.spi.configurator,
jakarta.enterprise.util
JakartaCDI 3.0 jakarta.decorator,
jakarta.enterprise.context,
jakarta.enterprise.context.control,
jakarta.enterprise.context.spi,
jakarta.enterprise.event,
jakarta.enterprise.inject,
jakarta.enterprise.inject.literal,
jakarta.enterprise.inject.se,
jakarta.enterprise.inject.spi,
jakarta.enterprise.inject.spi.configurator,
jakarta.enterprise.util
Packages renamed for Jakarta EE
JakartaConcurrency 3.0 jakarta.enterprise.concurrent,
jakarta.enterprise.concurrent.spi
JakartaConcurrency 2.0 jakarta.enterprise.concurrent Packages renamed for Jakarta EE
JakartaConnectors 2.1 jakarta.resource,
jakarta.resource.cci,
jakarta.resource.spi,
jakarta.resource.spi.endpoint,
jakarta.resource.spi.security,
jakarta.resource.spi.work
JakartaConnectors 2.0 jakarta.resource,
jakarta.resource.cci,
jakarta.resource.spi,
jakarta.resource.spi.endpoint,
jakarta.resource.spi.security,
jakarta.resource.spi.work
Packages renamed for Jakarta EE
JakartaEnterpriseBeans 4.0 jakarta.ejb,
jakarta.ejb.embeddable,
jakarta.ejb.spi
Packages renamed for Jakarta EE
JakartaExpressionLanguage 5.0 jakarta.el
JakartaExpressionLanguage 4.0 jakarta.el Packages renamed for Jakarta EE
JakartaFaces 4.0 jakarta.faces,
jakarta.faces.annotation,
jakarta.faces.application,
jakarta.faces.bean,
jakarta.faces.component,
jakarta.faces.component.behavior,
jakarta.faces.component.html,
jakarta.faces.component.search,
jakarta.faces.component.visit,
jakarta.faces.context,
jakarta.faces.convert,
jakarta.faces.el,
jakarta.faces.event,
jakarta.faces.flow,
jakarta.faces.flow.builder,
jakarta.faces.lifecycle,
jakarta.faces.model,
jakarta.faces.push,
jakarta.faces.render,
jakarta.faces.validator,
jakarta.faces.view,
jakarta.faces.view.facelets,
jakarta.faces.webapp
JakartaFaces 3.0 jakarta.faces,
jakarta.faces.annotation,
jakarta.faces.application,
jakarta.faces.bean,
jakarta.faces.component,
jakarta.faces.component.behavior,
jakarta.faces.component.html,
jakarta.faces.component.search,
jakarta.faces.component.visit,
jakarta.faces.context,
jakarta.faces.convert,
jakarta.faces.el,
jakarta.faces.event,
jakarta.faces.flow,
jakarta.faces.flow.builder,
jakarta.faces.lifecycle,
jakarta.faces.model,
jakarta.faces.push,
jakarta.faces.render,
jakarta.faces.validator,
jakarta.faces.view,
jakarta.faces.view.facelets,
jakarta.faces.webapp
Packages renamed for Jakarta EE
JakartaInject 2.0 jakarta.inject Packages renamed for Jakarta EE
JakartaInterceptors 2.1 jakarta.interceptor
JakartaInterceptors 2.0 jakarta.interceptor Packages renamed for Jakarta EE
JakartaJSONBinding 3.0 jakarta.json.bind,
jakarta.json.bind.adapter,
jakarta.json.bind.annotation,
jakarta.json.bind.config,
jakarta.json.bind.serializer,
jakarta.json.bind.spi
JakartaJSONBinding 2.0 jakarta.json.bind,
jakarta.json.bind.adapter,
jakarta.json.bind.annotation,
jakarta.json.bind.config,
jakarta.json.bind.serializer,
jakarta.json.bind.spi
Packages renamed for Jakarta EE
JakartaJSONProcessing 2.1 jakarta.json,
jakarta.json.spi,
jakarta.json.stream
JakartaJSONProcessing 2.0 jakarta.json,
jakarta.json.spi,
jakarta.json.stream
Packages renamed for Jakarta EE
JakartaMVC 2.0 jakarta.mvc,
jakarta.mvc.binding,
jakarta.mvc.engine,
jakarta.mvc.event,
jakarta.mvc.locale,
jakarta.mvc.security
Packages renamed for Jakarta EE
JakartaMail 2.1 jakarta.mail,
jakarta.mail.event,
jakarta.mail.internet,
jakarta.mail.search,
jakarta.mail.util
JakartaMail 2.0 jakarta.mail,
jakarta.mail.event,
jakarta.mail.internet,
jakarta.mail.search,
jakarta.mail.util
Packages renamed for Jakarta EE
JakartaMessaging 3.1 jakarta.jms
JakartaMessaging 3.0 jakarta.jms Packages renamed for Jakarta EE
JakartaPersistence 3.1 jakarta.persistence,
jakarta.persistence.criteria,
jakarta.persistence.metamodel,
jakarta.persistence.spi
JakartaPersistence 3.0 jakarta.persistence,
jakarta.persistence.criteria,
jakarta.persistence.metamodel,
jakarta.persistence.spi
Packages renamed for Jakarta EE
JakartaRESTfulWebServices 3.1 jakarta.ws.rs,
jakarta.ws.rs.client,
jakarta.ws.rs.container,
jakarta.ws.rs.core,
jakarta.ws.rs.ext,
jakarta.ws.rs.sse
JakartaRESTfulWebServices 3.0 jakarta.ws.rs,
jakarta.ws.rs.client,
jakarta.ws.rs.container,
jakarta.ws.rs.core,
jakarta.ws.rs.ext,
jakarta.ws.rs.sse
Packages renamed for Jakarta EE
JakartaSOAP 2.1 jakarta.xml.soap
JakartaSOAP 2.0 jakarta.xml.soap Packages renamed for Jakarta EE
JakartaSecurity 2.0 jakarta.security.enterprise,
jakarta.security.enterprise.authentication.mechanism.http,
jakarta.security.enterprise.credential,
jakarta.security.enterprise.identitystore
Packages renamed for Jakarta EE
JakartaServerPages 3.1 jakarta.servlet.jsp,
jakarta.servlet.jsp.el,
jakarta.servlet.jsp.tagext
JakartaServerPages 3.0 jakarta.servlet.jsp,
jakarta.servlet.jsp.el,
jakarta.servlet.jsp.tagext
Packages renamed for Jakarta EE
JakartaServlet 5.0 jakarta.servlet,
jakarta.servlet.annotation,
jakarta.servlet.descriptor,
jakarta.servlet.http
Packages renamed for Jakarta EE
JakartaStandardTagLibrary 3.0 jakarta.servlet.jsp.jstl.core,
jakarta.servlet.jsp.jstl.fmt,
jakarta.servlet.jsp.jstl.sql,
jakarta.servlet.jsp.jstl.tlv
JakartaStandardTagLibrary 2.0 jakarta.servlet.jsp.jstl.core,
jakarta.servlet.jsp.jstl.fmt,
jakarta.servlet.jsp.jstl.sql,
jakarta.servlet.jsp.jstl.tlv
Packages renamed for Jakarta EE
JakartaTransactions 2.0 jakarta.transaction Packages renamed for Jakarta EE
JakartaWebServicesMetadata 3.0 jakarta.jws,
jakarta.jws.soap
Packages renamed for Jakarta EE
JakartaWebSocket 2.0 jakarta.websocket,
jakarta.websocket.server
Packages renamed for Jakarta EE
JakartaXMLBinding 4.0 jakarta.xml.bind,
jakarta.xml.bind.annotation,
jakarta.xml.bind.annotation.adapters,
jakarta.xml.bind.attachment,
jakarta.xml.bind.helpers,
jakarta.xml.bind.util
JakartaXMLBinding 3.0 jakarta.xml.bind,
jakarta.xml.bind.annotation,
jakarta.xml.bind.annotation.adapters,
jakarta.xml.bind.attachment,
jakarta.xml.bind.helpers,
jakarta.xml.bind.util
Packages renamed for Jakarta EE
JakartaXMLWebServices 4.0 jakarta.jws,
jakarta.jws.soap,
jakarta.xml.ws,
jakarta.xml.ws.handler,
jakarta.xml.ws.handler.soap,
jakarta.xml.ws.http,
jakarta.xml.ws.soap,
jakarta.xml.ws.spi,
jakarta.xml.ws.spi.http,
jakarta.xml.ws.wsaddressing
Includes JakartaWebServicesMetadata 3.0 which is no longer independent
JakartaXMLWebServices 3.0 jakarta.xml.ws,
jakarta.xml.ws.handler,
jakarta.xml.ws.handler.soap,
jakarta.xml.ws.http,
jakarta.xml.ws.soap,
jakarta.xml.ws.spi,
jakarta.xml.ws.spi.http,
jakarta.xml.ws.wsaddressing
Packages renamed for Jakarta EE
JavaActivation 1.2 javax.activation Compatible with 1.1
JavaActivation 1.1.1 javax.activation Compatible with 1.1
JavaActivation 1.1 javax.activation
JavaAnnotation 1.3 javax.annotation,
javax.annotation.security,
javax.annotation.sql
Compatible with 1.0, 1.1, 1.2. Subset available in SE 8
JavaAnnotation 1.2 javax.annotation,
javax.annotation.security,
javax.annotation.sql
Compatible with 1.0, 1.1. Subset available in SE 8
JavaAnnotation 1.1 javax.annotation,
javax.annotation.security,
javax.annotation.sql
Compatible with 1.0
JavaAnnotation 1.0 javax.annotation,
javax.annotation.security
JavaBatch 1.0 javax.batch.api,
javax.batch.api.chunk,
javax.batch.api.chunk.listener,
javax.batch.api.listener,
javax.batch.api.partition,
javax.batch.operations,
javax.batch.runtime,
javax.batch.runtime.context
JavaBeanValidation 2.0 javax.validation,
javax.validation.bootstrap,
javax.validation.constraints,
javax.validation.constraintvalidation,
javax.validation.executable,
javax.validation.groups,
javax.validation.metadata,
javax.validation.spi,
javax.validation.valueextraction
JavaBeanValidation 1.1 javax.validation,
javax.validation.bootstrap,
javax.validation.constraints,
javax.validation.constraintvalidation,
javax.validation.executable,
javax.validation.groups,
javax.validation.metadata,
javax.validation.spi
Compatible with 1.0
JavaBeanValidation 1.0 javax.validation,
javax.validation.bootstrap,
javax.validation.constraints,
javax.validation.groups,
javax.validation.metadata,
javax.validation.spi
JavaCDI 2.0 javax.decorator,
javax.enterprise.context,
javax.enterprise.context.control,
javax.enterprise.context.spi,
javax.enterprise.event,
javax.enterprise.inject,
javax.enterprise.inject.literal,
javax.enterprise.inject.se,
javax.enterprise.inject.spi,
javax.enterprise.inject.spi.configurator,
javax.enterprise.util
Compatible with 1.2
JavaCDI 1.2 javax.decorator,
javax.enterprise.context,
javax.enterprise.context.spi,
javax.enterprise.event,
javax.enterprise.inject,
javax.enterprise.inject.spi,
javax.enterprise.util
Compatible with 1.1
JavaCDI 1.1 javax.decorator,
javax.enterprise.context,
javax.enterprise.context.spi,
javax.enterprise.event,
javax.enterprise.inject,
javax.enterprise.inject.spi,
javax.enterprise.util
Compatible with 1.0
JavaCDI 1.0 javax.decorator,
javax.enterprise.context,
javax.enterprise.context.spi,
javax.enterprise.event,
javax.enterprise.inject,
javax.enterprise.inject.spi,
javax.enterprise.util
JavaEJB 3.2 javax.ejb,
javax.ejb.embeddable,
javax.ejb.spi
Compatible with 2.1, 3.0, 3.1
JavaEJB 3.1 javax.ejb,
javax.ejb.embeddable,
javax.ejb.spi
Compatible with 2.1, 3.0
JavaEJB 3.0 javax.ejb,
javax.ejb.spi
Compatible with 2.1
JavaEJB 2.1 javax.ejb,
javax.ejb.spi
JavaEJBLite 3.2 javax.ejb EJBlite is a subset of the EJB specification. The package content is logically subset. A provider of JavaEJB is required to also provide this contract. A provider of JavaEJBLite is not required to provide JavaEJB. This contract is not backwards compatible with 3.1 because of the removal of javax.ejb.embeddable.
JavaEJBLite 3.1 javax.ejb,
javax.ejb.embeddable,
javax.ejb.spi
EJBlite is a subset of the EJB specification. The package content is logically subset. A provider of JavaEJB is required to also provide this contract. A provider of JavaEJBLite is not required to provide JavaEJB.
JavaEL 3.0 javax.el Compatible with 2.2
JavaEL 2.2 javax.el Compatible with 2.1
JavaEL 2.1 javax.el
JavaEnterpriseConcurrency 1.1 javax.enterprise.concurrent Compatible with 1.0
JavaEnterpriseConcurrency 1.0 javax.enterprise.concurrent
JavaInject 1.0 javax.inject
JavaInterceptor 1.2 javax.interceptor Compatible with 1.1
JavaInterceptor 1.1 javax.interceptor
JavaJACC 1.5 javax.security.jacc Compatible with 1.1, 1.4
JavaJACC 1.4 javax.security.jacc Compatible with 1.1
JavaJACC 1.1 javax.security.jacc
JavaJASPIC 1.1 javax.security.auth.message,
javax.security.auth.message.callback,
javax.security.auth.message.config,
javax.security.auth.message.module
Compatible with 1.0
JavaJASPIC 1.0 javax.security.auth.message,
javax.security.auth.message.callback,
javax.security.auth.message.config,
javax.security.auth.message.module
JavaJAXB 2.2 javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.bind.annotation.adapters,
javax.xml.bind.attachment,
javax.xml.bind.helpers,
javax.xml.bind.util
Compatible with 2.1
JavaJAXB 2.1 javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.bind.annotation.adapters,
javax.xml.bind.attachment,
javax.xml.bind.helpers,
javax.xml.bind.util
JavaJAXR 1.0 javax.xml.registry,
javax.xml.registry.infomodel
JavaJAXRS 2.0 javax.ws.rs,
javax.ws.rs.core,
javax.ws.rs.ext,
javax.ws.rs.client,
javax.ws.rs.container
JavaJAXRS 1.1 javax.ws.rs,
javax.ws.rs.core,
javax.ws.rs.ext
JavaJAXWS 2.2 javax.xml.ws,
javax.xml.ws.handler,
javax.xml.ws.handler.soap,
javax.xml.ws.http,
javax.xml.ws.soap,
javax.xml.ws.spi,
javax.xml.ws.spi.http,
javax.xml.ws.wsaddressing
Compatible with 2.1
JavaJAXWS 2.1 javax.xml.ws,
javax.xml.ws.handler,
javax.xml.ws.handler.soap,
javax.xml.ws.http,
javax.xml.ws.soap,
javax.xml.ws.spi,
javax.xml.ws.wsaddressing
JavaJCA 1.7 javax.resource,
javax.resource.cci,
javax.resource.spi,
javax.resource.spi.endpoint,
javax.resource.spi.security,
javax.resource.spi.work
Compatible with 1.5, 1.6
JavaJCA 1.6 javax.resource,
javax.resource.cci,
javax.resource.spi,
javax.resource.spi.endpoint,
javax.resource.spi.security,
javax.resource.spi.work
Compatible with 1.5
JavaJCA 1.5 javax.resource,
javax.resource.cci,
javax.resource.spi. javax.resource.spi.endpoint. javax.resource.spi.security,
javax.resource.spi.work
JavaJMS 2.0 javax.jms Compatible with 1.1
JavaJMS 1.1 javax.jms
JavaJPA 2.2 javax.persistence,
javax.persistence.criteria,
javax.persistence.metamodel,
javax.persistence.spi
Compatible with 1.0, 2.1
JavaJPA 2.1 javax.persistence,
javax.persistence.criteria,
javax.persistence.metamodel,
javax.persistence.spi
Compatible with 1.0, 2.0
JavaJPA 2.0 javax.persistence,
javax.persistence.criteria,
javax.persistence.metamodel,
javax.persistence.spi
Compatible with 1.0
JavaJPA 1.0 javax.persistence,
javax.persistence.spi
JavaJSF 2.3 javax.faces,
javax.faces.annotation,
javax.faces.application,
javax.faces.bean,
javax.faces.component,
javax.faces.component.behavior,
javax.faces.component.html,
javax.faces.component.search,
javax.faces.component.visit,
javax.faces.context,
javax.faces.convert,
javax.faces.el,
javax.faces.event,
javax.faces.flow,
javax.faces.flow.builder,
javax.faces.lifecycle,
javax.faces.model,
javax.faces.push,
javax.faces.render,
javax.faces.validator,
javax.faces.view,
javax.faces.view.facelets,
javax.faces.webapp
Compatible with 2.2
JavaJSF 2.2 javax.faces,
javax.faces.application,
javax.faces.bean,
javax.faces.component,
javax.faces.component.behavior,
javax.faces.component.html,
javax.faces.component.visit,
javax.faces.context,
javax.faces.convert,
javax.faces.el,
javax.faces.event,
javax.faces.flow,
javax.faces.flow.builder,
javax.faces.lifecycle,
javax.faces.model,
javax.faces.render,
javax.faces.validator,
javax.faces.view,
javax.faces.view.facelets,
javax.faces.webapp
Compatible with 2.0
JavaJSF 2.0 javax.faces,
javax.faces.application,
javax.faces.bean,
javax.faces.component,
javax.faces.component.behavior,
javax.faces.component.html,
javax.faces.component.visit,
javax.faces.context,
javax.faces.convert,
javax.faces.el,
javax.faces.event,
javax.faces.lifecycle,
javax.faces.model,
javax.faces.render,
javax.faces.validator,
javax.faces.view,
javax.faces.view.facelets,
javax.faces.webapp
JavaJSONP 1.1 javax.json,
javax.json.spi,
javax.json.stream
Compatible with 1.0
JavaJSONP 1.0 javax.json,
javax.json.spi,
javax.json.stream
JavaJSP 2.3 javax.servlet.jsp,
javax.servlet.jsp.el,
javax.servlet.jsp.tagext
Compatible with 2.0, 2.1, 2.2
JavaJSP 2.2 javax.servlet.jsp,
javax.servlet.jsp.el,
javax.servlet.jsp.tagext
Compatible with 2.0, 2.1
JavaJSP 2.1 javax.servlet.jsp,
javax.servlet.jsp.el,
javax.servlet.jsp.tagext
Compatible with 2.0
JavaJSP 2.0 javax.servlet.jsp,
javax.servlet.jsp.el,
javax.servlet.jsp.tagext
JavaJSTL 1.2 javax.servlet.jsp.jstl.core,
javax.servlet.jsp.jstl.fmt,
javax.servlet.jsp.jstl.sql,
javax.servlet.jsp.jstl.tlv
Compatible with 1.1
JavaJSTL 1.1 javax.servlet.jsp.jstl.core,
javax.servlet.jsp.jstl.fmt,
javax.servlet.jsp.jstl.sql,
javax.servlet.jsp.jstl.tlv
Compatible with 1.0
JavaJSTL 1.0 javax.servlet.jsp.jstl.core,
javax.servlet.jsp.jstl.fmt,
javax.servlet.jsp.jstl.sql,
javax.servlet.jsp.jstl.tlv
JavaJTA 1.3 javax.transaction javax.transaction.xa is now owned by Java SE
JavaJTA 1.2 javax.transaction,
javax.transaction.xa
Compatible with 1.1
JavaJTA 1.1 javax.transaction,
javax.transaction.xa
JavaJTAJRE 1.1 javax.transaction,
javax.transaction.xa
This contains a subset of the package javax.transaction. It only contains 3 exceptions. A provider of JavaJTA must also provide this contract. The OSGi system bundle must provide this contract. The creation of JTA 1.2 has so far not affected the SE subset and so there is currently no 1.2 version of this contract.
JavaMail 1.6 javax.mail,
javax.mail.event,
javax.mail.internet,
javax.mail.search,
javax.mail.util
Compatible with 1.5
JavaMail 1.5 javax.mail,
javax.mail.event,
javax.mail.internet,
javax.mail.search,
javax.mail.util
Compatible with 1.4
JavaMail 1.4 javax.mail,
javax.mail.event,
javax.mail.internet,
javax.mail.search,
javax.mail.util
JavaSAAJ 1.4 javax.xml.soap Compatible with 1.1, 1.2, 1.3
JavaSAAJ 1.3 javax.xml.soap Compatible with 1.1, 1.2
JavaSAAJ 1.2 javax.xml.soap Compatible with 1.1
JavaSAAJ 1.1 javax.xml.soap
JavaServlet 4.0 javax.servlet,
javax.servlet.annotation,
javax.servlet.descriptor,
javax.servlet.http
Compatible with 2.5, 3.1
JavaServlet 3.1 javax.servlet,
javax.servlet.annotation,
javax.servlet.descriptor,
javax.servlet.http
Compatible with 2.5, 3.0
JavaServlet 3.0 javax.servlet,
javax.servlet.annotation,
javax.servlet.descriptor,
javax.servlet.http
Compatible with 2.5
JavaServlet 2.5 javax.servlet,
javax.servlet.http
JavaWebServicesMetadata 2.1 javax.jws,
javax.jws.soap
JavaWebServicesMetadata 2.0 javax.jws,
javax.jws.soap
JavaWebSockets 1.1 javax.websocket,
javax.websocket.server
Compatible with 1.0
JavaWebSockets 1.0 javax.websocket,
javax.websocket.server

Examples

Note: properties syntax is used, not MANIFEST

A bundle that provides servlet packages unversioned

Bundle-SymbolicName: jee.vendor1
Bundle-Version: 3
Export-Package: javax.servlet, javax.servlet.annotation, \
 javax.servlet.descriptor, javax.servlet.http
Provide-Capability: osgi.contract; osgi.contract=JavaServlet; version:List<Version>="3,2.5"; \
 uses:="javax.servlet, javax.servlet.annotation, javax.servlet.descriptor, javax.servlet.http"

A bundle that provides servlet packages using semantic versions

Bundle-SymbolicName: jee.vendor2
Bundle-Version: 3
Export-Package: javax.servlet; version=2.6, javax.servlet.annotation; version=2.6, \
 javax.servlet.descriptor; version=2.6, javax.servlet.http; version=2.6,
Provide-Capability: osgi.contract; osgi.contract=JavaServlet; version:List<Version>="3,2.5"; \
 uses:="javax.servlet, javax.servlet.annotation, javax.servlet.descriptor, javax.servlet.http"

A bundle that provides servlet packages using specification marketing versions

Bundle-SymbolicName: jee.vendor3
Bundle-Version: 3
Export-Package: javax.servlet; version=3, javax.servlet.annotation; version=3, \
 javax.servlet.descriptor; version=3, javax.servlet.http; version=3,
Provide-Capability: osgi.contract; osgi.contract=JavaServlet; version:List<Version>="3,2.5"; \
 uses:="javax.servlet, javax.servlet.annotation, javax.servlet.descriptor, javax.servlet.http"

A bundle that provides JavaServlet 2.5, but not 3

Bundle-SymbolicName: jee.vendor4
Bundle-Version: 2.5
Export-Package: javax.servlet; version=2.5, javax.servlet.http; version=2.5
Provide-Capability: osgi.contract; osgi.contract=JavaServlet; version:Version=2.5; \
 uses:="javax.servlet, javax.servlet.http"

A bundle that uses JavaServlet 2.5

Bundle-SymbolicName: my.company.wab2
Bundle-Version: 2
Import-Package: javax.servlet, javax.servlet.http
Require-Capability: osgi.contract; filter:="(&(osgi.contract=JavaServlet) \
 (version=2.5))"

A bundle that uses JavaServlet 3

Bundle-SymbolicName: my.company.wab
Bundle-Version: 2
Import-Package: javax.servlet, javax.servlet.http
Require-Capability: osgi.contract; filter:="(&(osgi.contract=JavaServlet) \
 (version=3.0))"

References

Semantic Versioning Whitepaper