HTTP Connection Bundle

The HTTP Connection Bundle wraps a connection factory implementing the http scheme. This scheme provides means for communication over HTTP. It can be used by bundles which need to establish connection with bundles running on the local or remote framework.

Contents:


Bundle Information

Bundle JAR

The JAR file of this bundle is httpconn.jar, located in the bundles folder.

Import

Package Exporter Description
com.prosyst.util.ref ProSyst Util Bundle/ProSyst Util Full Bundle Allows storing log messages in the Log Service.
javax.microedition.io Connector Service Bundle/System Bundle Generic connection API.
javax.servlet OSGi Library Bundle Standard Java Servlet API.
javax.servlet.http Standard Java Servlet API.
org.mbs.services.io Connector Service Bundle/System Bundle The ProSyst connection API. Provides means for creating connection listeners.
org.osgi.service.io The OSGi communication API.
org.osgi.service.http HTTP Bundle Wraps the OSGi HTTP Service.

Note: The HTTP Connection Bundle uses the HTTP Service for transferring information over HTTP. Hence, you cannot start the bundle if the HTTP Bundle is not active too.

Note: If the bundle is started on the Standard Version of the framework, the connection APIs are exported by the Connector Service Bundle. If the bundle is started on the Connector Version of the framework, these APIs are exported by the System Bundle.

Note: If the bundle is started on ProSyst mBS, the com.prosyst.util.ref package is exported by the ProSyst Util Bundle. If it is started on an OSGi framework provided by another vendor, the package is exported by the ProSyst Util Full Bundle.

Export

None.

HTTP Connection Factory Service

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 Connector Service Bundle 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:

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

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:

http:/<alias>

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:

http:/http_serv_alias

Client-Side URIs

A client connection URI must have the following form:

http://<host>[:<port>]/<alias>

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:

http://127.0.0.1:8080/http_serv_alias

Note: 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 Service Bundle description. You can manage the created connections using the methods of the respective subinterfaces of javax.microedition.io.Connection. See Client-side connections and Server side connections for details.

System Properties

The HTTP Connection Bundle owns a number of user-definable system properties. The first two serve for debug purposes. The rest of the properties are applied when using a proxy.

System Property Description
mbs.io.http.console If set to true, the log information messages created by the HTTP Connection Bundle will be printed in the server's runtime console. By default its value is false.
mbs.io.http.debug If set to true, the messages at DEBUG level created by the HTTP Connection Bundle will be stored through the Log Service. By default its value is false.
http.proxyHost Indicates the host running the proxy.
http.proxyPort Indicates the port occupied by the proxy. If this is the default 80 port, its value can be omitted.
mbs.io.http.proxy.always Accepts boolean values. If it is set to true then proxy will be used for every connection (if proxy host is set).

If you set/change these properties after the bundle has been activated, you must restart it so that it will accept the new values.

References


Connection Bundles