@Override
    public void init(String appLocation, boolean privileged) throws Exception {
        log.finer("Initializing application loader.");
        osgiFramework.start();
        BundleContext ctx = osgiFramework.bundleContext();
        if (ctx != null) {
            ctx.registerService(CurrentContainer.class.getName(), this, null);
        }
        if(appLocation == null) {
            return; // application class bound by another module
        }
        try {
            Class<Application> appClass = ContainerBuilder.safeClassCast(Application.class, Class.forName(appLocation));
            guiceModules.install(new AbstractModule()  {
                @Override
                public void configure() {
                    bind(Application.class).to(appClass);
                }
            });
            return; // application class found on class path
        } catch (ClassNotFoundException e) {
            // location is not a class name
            if (log.isLoggable(Level.FINE)) {
                log.fine("App location is not a class name. Installing bundle");
            }
        }
        appBundles.addAll(osgiFramework.installBundle(appLocation));
        if (OsgiHeader.isSet(appBundles.get(0), OsgiHeader.PRIVILEGED_ACTIVATOR)) {
            osgiFramework.startBundles(appBundles, privileged);
        }

    }
@author Simon Thoresen Hult
@author bjorncs
jdisc_core/src/main/java/com/yahoo/jdisc/core/ApplicationLoader.java