Hi Sergey,

I don't know if I have right understood your needs :).

I guess that you need to read a file located in your application classpath, correct ?

In this case, using PAX, you can use classpath protocol like this:

classpath:/mybundle/file.conf

You can find some documentation here:
http://wiki.ops4j.org/display/paxurl/Classpath+Protocol

Regards
JB

Sergey Shcherbakov wrote:
Hello all,

I am very new to OSGi and Servicemix.

Let's say, I have a running Servicemix instance. A [local] maven
repository can be and is usually used to find resources required by
dependencies etc.

From my bundle or better to say from my application that embeds
Servicemix I need to figure out a full file name of the resource
referenced by the maven url (mvn:...).

That is, I have an URL string that uses maven protocol and want to get a
local file name of the artifact referenced by this URL or even an input
stream representing that resource (that would be OK too).

I believe this is possible with help of the Servicemix preinstalled
bundle services.

Could you please give a hint in which direction should I look?

In the out of the box running Servicemix instance I have found several
bundles that provide
org.osgi.service.url.URLStreamHandlerService

Do I need a maven implementation one of them? This interface requires a
further a reference to the org.osgi.service.url.URLStreamHandlerSetter
implementation. Should I implement it by myself?

Is there a more simple way to convert maven URL into the local file
system path?

The PAX documentation

http://wiki.ops4j.org/display/paxurl/Mvn+Protocol

is very brief and I could not find examples of how to use it.

The way I found to be recommended for use from inside bundles:

URL url = new URL(s);

InputStream in = url.openStream();

Doesn't work for me since I have an embedded Servicemix instance.

I have only a Felix, BundleContext and a ServiceTracker references and
the code above throws "unknown protocol" Runtime exception.

Thank you!

Best Regards,

Sergey Shcherbakov.


Reply via email to