Hey Tmhull,
There are two stages of installation which are covered by fileinstall - first 
one is bringing bundle to system, second starting it up. You can manage to do 
such thing via BundleContext instance. Code is not hard since all necessary 
functionalities are delivered by OSGi framework out of the box.

String url = "file:/opt/repository/bundle-1.0.jar";
try {
    Bundle bundle = bundleContext.install(url);

    try {
        bundle.start();
    } catch (BundleException e) {
        // bundle could not be started due to:
                // {@link BundleException#NATIVECODE_ERROR},
                // {@link BundleException#RESOLVE_ERROR},
                // {@link BundleException#STATECHANGE_ERROR}, and
                // {@link BundleException#ACTIVATOR_ERROR}.
        } catch (IllegalStateException e) {
                // bundle is uninstalled OR bundle tries to update itself
        } catch (SecurityException e)
                // no privileges to run
    }
} catch (BundleException e) {
        // unable to install bundle due one of these reasons:
        // {@link BundleException#READ_ERROR}
        // {@link BundleException#DUPLICATE_BUNDLE_ERROR},
        // {@link BundleException#MANIFEST_ERROR}, and
        // {@link BundleException#REJECTED_BY_HOOK}
} catch (IllegalStateException e) {
        // called bundle context is invalid
} catch (SecurityException e) {
        // no privileges to install 
}

I don’t know details of your system, however most of cases are
a) bundle installation location is invalid
b) resolving bundle dependencies fails

Kind regards,
Lukasz,
—
[email protected]
Twitter: ldywicki
Blog: http://dywicki.pl
Code-House - http://code-house.org

> Wiadomość napisana przez thully <[email protected]> w dniu 2 kwi 2015, o 
> godz. 04:43:
> 
> Hi,
> 
> Our project (Cytoscape) utilizes Karaf 3 as its framework for OSGi bundle
> management. In our application, end users are able to install bundles -
> either from our App Store or from disk. These bundles are stored in a
> subdirectory of the user's home that is managed by Felix FileInstall.
> 
> Anyway, I was wondering if there is any way to capture bundle load errors
> programmatically so that our application can respond to them (i.e. by
> displaying an error message, offering the user the choice to uninstall the
> bundle, etc etc). It seems that since FileInstall starts the bundles, there
> is no way to capture these aside from scraping the log. 
> 
> Would it be a better approach to simply not use FileInstall at all and
> manage our own local bundles? If that might be a good approach, how can we
> change its settings such that it won't scan for JAR files?
> 
> 
> 
> --
> View this message in context: 
> http://karaf.922171.n3.nabble.com/Capturing-bundle-load-errors-tp4039419.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to