« Return to Thread: Problem with starting bundles

Problem with starting bundles

by Marta Luse :: Rate this Message:

Reply to Author | View in Thread

Hi everyone!!
I try to embbed felix into a Web page, I have follow the way that it is
explain here:
http://felix.apache.org/site/launching-and-embedding-apache-felix.html
But when I oppen the browser, I find that there are no bundles in the
cache...
I have no errors in the Java Console...
This is my code:

private static final String AUTO_START_PROP = AutoActivator.AUTO_START_PROP;


    // the felix instance
    private Felix felix = null;

    private HostActivator m_activator = null;

    // the activator for the applet bundle
    private AppletActivator appletActivator = null;


    public void init()
    {

        userHome = System.getProperty("user.home") + File.separator;
// remove the cache dir from a previous startup to make sure that the new
bundles are loaded
        File existingCacheDir = new File(userHome + CACHE_DIR);
        //if (existingCacheDir.exists())
        //{
            //boolean deleted = deleteDirectory(existingCacheDir);
        //}

        // use the codeBase as the server we are running on
        String server = getCodeBase().toString();

        // Print welcome banner.
        System.out.println("\nWelcome to Felix.");
        System.out.println("=================\n");

       // Map<String, String> configMap = new StringMap(false);

        // Configure the Felix instance to be embedded.
        // Create a configuration property map.
       Map configMap = new StringMap(false);

        // Create host activator;
        m_activator = new HostActivator();
        List list = new ArrayList();
        list.add(m_activator);
        configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);

        //configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
"true");

        // add all the framework system packages to the config map
        //configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP,"true");
        configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
            "org.osgi.framework; version=1.3.0," +


            "javax.swing;" +
            "javax.swing.event;" +
            "javax.swing.table;" +
            "javax.swing.text;" + .....

        // add all the bundles we need to the config map
       /* configMap.put(AUTO_START_PROP + ".10",
                server +
"lib/bundle/org.apache.felix.bundlerepository-1.0.0.jar " +
                server +
"lib/bundle/org.apache.felix.servicebinder-0.9.0-SNAPSHOT.jar");
        // And more bundles


        configMap.put("org.osgi.framework.startlevel", "100");

        configMap.put("felix.startlevel.framework", "100");

        configMap.put("felix.startlevel.bundle", "100");

        // this prevents felix from loading stream and content factories a
second time
        configMap.put("felix.service.urlhandlers", "false");


        // create an AppletActivator to make this applet available to the
framework
        appletActivator = new AppletActivator(this);

        // add this appletActivator to the parameter list for felix
    //    List list = new ArrayList();
        list.add(appletActivator);

        // add an autoActivator to start the bundles - only in Felix 1.0.3
//        list.add(new AutoActivator(configMap));

        try
       {
            // Now create an instance of the framework.
            //System.out.println(configMap);
            felix = new Felix(configMap);
            // and start it!
            felix.start();
            System.out.println("Se crea el framework");
        }
        catch (Exception ex)
        {
            System.err.println("Could not create framework: " + ex);
            ex.printStackTrace();
        }
    }

Can anybody help me?
Thanks in advance,
Regards
Marta

 « Return to Thread: Problem with starting bundles