Skip to content

Instantly share code, notes, and snippets.

@emrekgn
Created January 17, 2017 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emrekgn/2ae9db06dbb603ea35b68e98accf5e0e to your computer and use it in GitHub Desktop.
Save emrekgn/2ae9db06dbb603ea35b68e98accf5e0e to your computer and use it in GitHub Desktop.

blueprint.xml

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:http://www.ibm.com/developerworks/opensource/library/os-osgiblueprint/

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);
            return(false);
        }

    }

    return(true);
}

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

} 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