Skip to content

Instantly share code, notes, and snippets.

What would you like to do?


The possible reference :

blueprintBundle Provides bundle's Bundle object.

blueprintBundleContext Provides bundle's BundleContext object.

blueprintContainer Provides the BlueprintContainer object for the bundle.

blueprintConverter Provides the Converter object for the bundle that provides access to the Blueprint Container type conversion facility. Type conversion has more information. source:

And in your class :

import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext public class MyBean {

public BundleContext bcontext;
public boolean start(){
try {
Bundle bundle = bcontext.getBundle();
InputStream is = bundle.getEntry("/file.json").openStream();
String jsondb =  readFile(is);

} catch (IOException e) {
            LOG.error("The file treefield.json not found", e);



private String readFile(InputStream is ) throws IOException {
    java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
    return s.hasNext() ? : "";

} public void setBcontext(BundleContext bcontext) { this.bcontext = bcontext; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment