camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject OSGi resource loading question
Date Thu, 26 Apr 2012 12:09:32 GMT

I was looking into

And that leads me to the camel-core-osgi component where we have our
OSGi empowered Camel stuff.
And the class org.apache.camel.core.osgi.OsgiClassResolver is used for
loading resources and classes from OSGi.

Now I got a bit baffled that the method to load a resource from the
classpath, such as a .xslt file, or what ever the user wants is
implemented as:

    public URL loadResourceAsURL(String uri) {
        ObjectHelper.notEmpty(uri, "uri");
        return bundleContext.getBundle().getEntry(uri);

Now reading the javadoc for getEntry it seems that it doesnt use
classloader at all, but some other means of loading the resource.
There is another method called getResource.

So I wonder if it should have been implemented as

    public URL loadResourceAsURL(String uri) {
        ObjectHelper.notEmpty(uri, "uri");
        return bundleContext.getBundle().getResource(uri);

Guillaume in case you read this. The code was developed by you. So
maybe you have a thought about this?

Claus Ibsen
CamelOne 2012 Conference, May 15-16, 2012:
Twitter: davsclaus, fusenews
Author of Camel in Action:

View raw message