Apache Felix Framework Frequently Asked Questions

Is the Felix framework compliant with the OSGi specification?

Refer to the Apache Felix Framework OSGi R4.2 CT Results document.

If I use bundles from Felix, will my application be tied to the Felix framework?

See the answer in the OSGi FAQ.

When I update my bundle, why are my bundle's old classes still being used?

See the answer in the OSGi FAQ.

Why do I get an "Unknown protocol: http" exception when I run Felix on a non-Sun JRE?

Felix installs the URL Handlers service by default. If you do not want this service you can disable it, by setting the felix.service.urlhandlers property to false in the config.properties file. It is not recommended to disable this, but the main reason for doing so it because the URL Handlers implementation invokes methods to set the singleton factories for URL stream and content handler factories. Assuming that you want to use URL Handlers service, you must configure it if you aren't running on the standard Sun JRE.

The URL Handlers service extends the standard Java URL stream and content handler mechanism to work in an OSGi environment. The way that built-in URL protocol and content handlers are discovered is by probing packages for the appropriate classes to handle the protocol/content. For example, the default package for Sun protocol handlers is:

sun.net.www.protocol

If someone tries to create a URL for the "http" protocol, then the class to handle the protocol will be:

sun.net.www.protocol.http.Handler

A similar process is followed for content handlers, whose default package is:

sun.net.www.content

If you are running on a VM that is different than Sun's, then you must determine what are the default packages used for its protocol and content handlers. Once you know this information, then you can configure Felix to use those packages instead of the default one. You can configure Felix by setting the following system properties:

java.protocol.handler.pkgs

and

java.content.handler.pkgs

The value of these properties is a list of "|" delimited package names to be searched for protocol and content handlers, respectively. See the Java documentation for stream and content handlers for more information.

There are two ways to set these system properties. The first way is using the standard -D<property>=<value> syntax when executing java or if you are using Felix' standard Main.java launcher, you can put the system properties into the conf/system.properties file so that they get set automatically each time you execute Felix.

What is the daemon status of framework created threads?

The framework creates a few threads for handling specific tasks, such as event delivery or handling start level change requests. All framework threads are explicitly started as daemon threads except the event dispatcher thread. The logic behind this is that the event dispatcher thread should exit when it is done delivering events. However, if an application is hosting an instance of the framework, it is possible to make the event dispatcher thread a daemon by starting your framework instance from a daemon thread, in which case the event dispatcher thread will inherit this setting.

For bundle developers, it is probably best to explicitly define any created threads as daemon or non-daemon to avoid any ambiguity.

  • No labels