Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Sufficiently detailed description of the standard Felix launcher to go here.

Custom Felix Launcher

...

This section creates a bare-bones launcher to demonstrate the minimum requirements for creating an interactive launcher for the Felix framework. This example uses the standard Felix shell bundles for interactivity, but any other bundles could be used too. For example, the shell and telnet bundles could be used to lauch Felix and make it remotely accessible.

This example launcher has the following directory structure:

No Format

[rickhall@heavy launcher]$ ls -R
.:
bundle/
   org.apache.felix.shell-0.8.0-SNAPSHOT.jar
   org.apache.felix.shell.tui-0.8.0-SNAPSHOT.jar
lib/
   org.apache.felix.framework-0.8.0-SNAPSHOT.jar
   org.osgi.core-0.8.0-SNAPSHOT.jar
src/
   example/
      Main.java
Code Block

package example;

import java.util.Map;
import org.apache.felix.framework.Felix;
import org.apache.felix.framework.cache.BundleCache;
import org.apache.felix.framework.util.MutablePropertyResolverImpl;
import org.apache.felix.framework.util.StringMap;
import org.apache.felix.framework.util.FelixConstants;

public class Main
{
    private static Felix m_felix = null;

    public static void main(String[] argv) throws Exception
    {
        // Print welcome banner.
        System.out.println("\nWelcome to Felix.");
        System.out.println("=================\n");

        Map configMap = new StringMap(false);
        configMap.put(FelixConstants.FRAMEWORK_SYSTEMPACKAGES,
            "org.osgi.framework; version=1.3.0," +
            "org.osgi.service.packageadmin; version=1.2.0," +
            "org.osgi.service.startlevel; version=1.0.0," +
            "org.osgi.service.url; version=1.0.0");
        configMap.put(FelixConstants.AUTO_START_PROP + ".1",
            "file:bundle/org.apache.felix.shell-0.8.0-SNAPSHOT.jar " +
            "file:bundle/org.apache.felix.shell.tui-0.8.0-SNAPSHOT.jar");
        configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, "cache");

        try
        {
            // Now create an instance of the framework.
            m_felix = new Felix();
            m_felix.start(
                new MutablePropertyResolverImpl(configMap),
                null);
        }
        catch (Exception ex)
        {
            System.err.println("Could not create framework: " + ex);
            ex.printStackTrace();
            System.exit(-1);
        }
    }
}

Embedding Felix

to do

Host/Felix Interaction

...