Previous Topic

Next Topic

Book Contents

Book Index

HTTP Connection Factory Service

Represents a connection factory for the OSGi communication model (described in the OSGi IO Connector Service Specification) for creating connections over the http scheme.

Overview

This service publishes the org.osgi.service.io.ConnectionFactory interface and represents a connection factory for the OSGi communication model, described in the OSGi IO Connector Service Specification. It is used by the IO Connector Service (exported by the OSGi Connector HTTPBundle or by the System Bundle, depending on the version of the framework) for creating connections over the http scheme.

The HTTP Connection Factory handles connection requests for the http scheme.

It provides communication over the HTTP v 1.1 protocol. This means that the keep connection alive option and proxy management are implemented.

The HTTP Connection Factory supports two connection types:

If the connection factory is unregistered, all created connections are closed.

Registering Bundle

The service is registered by OSGi Connector HTTP Bundle.

HTTP Uniform Resource Identifiers (URIs)

All URIs processed by the HTTP Connection Factory must start with "http:". However, there is a slight difference between client side URIs and server side URIs.

Server-Side URIs

A valid server URI must have the following syntax:

where <alias> stands for the HTTP alias with which the servlet registered by the server HTTP connection is created.

For example, a server http URI may look like this:

Client-Side URIs

A client connection URI must have the following form:

where <host> stands for the machine on which the server socket is waiting. The [..] brackets represent an optional part. They are not part of the URI itself. If the port occupied by the server is different from the default value: 80, it must be passed to the URI. If the occupied port is 80, it may be omitted from the URI. The <alias> part represents the HTTP alias under which the server connection has registered its servlet.

For example, the client URI may look like this:

Some parts of the URI are case sensitive! For details, refer to RFC 2396.

Using the Service

If you want to use the HTTP Connection Factory as an underlying transport implementation for your connections, you must invoke the IO Connector Service, exported by the Connector Service Bundle/System Bundle, and pass an http URI to its open method. For more information refer to the Connector Bundle description. You can manage the created connections using the methods of the respective subinterfaces of javax.microedition.io.Connection. Refer to the "Client-Side URIs" and "Server-Side URIs" sections above for details.