Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Getting a bundles jar location
Getting a bundles jar location [message #108609] Wed, 23 April 2008 16:12 Go to next message
Eclipse UserFriend
Originally posted by: Boyan.Yurukov.softwareag.com

Hello,

How can I get the absolute location of a bundle's jar file? I need to build
a FileInputStream out of it. I tried with :

bundle.getResource(bundle.getLocation())

but it doesn't return anything back. bundle.getLocation() returns something
like :

update@plugins/org.eclipse.ui_3.3.1.M20070910-0800b.jar

which seems to be an identifier. I don't know where to use it.

Thanks,
Boyan.
Re: Getting a bundles jar location [message #108721 is a reply to message #108609] Thu, 24 April 2008 04:59 Go to previous messageGo to next message
Karsten Panier is currently offline Karsten PanierFriend
Messages: 57
Registered: July 2009
Member
Boyan Yurukov wrote:
> Hello,
>
> How can I get the absolute location of a bundle's jar file? I need to build
> a FileInputStream out of it. I tried with :
>
> bundle.getResource(bundle.getLocation())
>
> but it doesn't return anything back. bundle.getLocation() returns something
> like :
>
> update@plugins/org.eclipse.ui_3.3.1.M20070910-0800b.jar
>
> which seems to be an identifier. I don't know where to use it.
>
> Thanks,
> Boyan.
>
>
Hi,

I had similar problem. I need a InputStream on a Ressource in my Bundle.
It works with:
FileLocator.resolve(bundle().getEntry("relativePath"))

If you use:
FileLocator.resolve(bundle.getResource(bundle.getLocation()) )
it should work.

Hope that helps.
Karsten
Re: Getting a bundles jar location [message #108736 is a reply to message #108721] Thu, 24 April 2008 06:07 Go to previous messageGo to next message
Danail Nachev is currently offline Danail NachevFriend
Messages: 110
Registered: July 2009
Senior Member
The correct way, should be:

FileLocator.resolve(bundle.getEntry("/"))

bundle.getLocation() returns unique string, identifying the bundle in
the framework. Before R4, the bundles didn't have symbolic names and
versions, the location was used for identifying a particular bundle.

The location of the bundle is usually an URL to the original bundle
contents, but the framework doesn't make an assumption about this. So,
the update.configurator is marking each bundle it is responsible for by
installing it with location starting with update@. The framework core
also does something like that by marking the bundles from osgi.bundles
property with initial@

BR,
Danail

Karsten Panier wrote:
> Boyan Yurukov wrote:
>> Hello,
>>
>> How can I get the absolute location of a bundle's jar file? I need to
>> build a FileInputStream out of it. I tried with :
>>
>> bundle.getResource(bundle.getLocation())
>>
>> but it doesn't return anything back. bundle.getLocation() returns
>> something like :
>>
>> update@plugins/org.eclipse.ui_3.3.1.M20070910-0800b.jar
>>
>> which seems to be an identifier. I don't know where to use it.
>>
>> Thanks,
>> Boyan.
>>
> Hi,
>
> I had similar problem. I need a InputStream on a Ressource in my Bundle.
> It works with:
> FileLocator.resolve(bundle().getEntry("relativePath"))
>
> If you use:
> FileLocator.resolve(bundle.getResource(bundle.getLocation()) )
> it should work.
>
> Hope that helps.
> Karsten
Re: Getting a bundles jar location [message #109129 is a reply to message #108736] Tue, 06 May 2008 12:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Boyan.Yurukov.softwareag.com

Thanks for the help. There is however a problem with FileLocator.resolve:
with some configs it returns URLs like this one:
jar:file:D:\eclipse\plugins\org.eclipse.ui_3.3.1.M20070910-0 800b.jar!/

Then I pass that one to a FileInputStream, I get an error. I don't think
that a simple cutting of the jar: part will work in the general case. I also
tried

FileLocator.openStream(bundle, new Path("\"),null)

but I also get an exception.

I would appreciate any other ideas?

Boyan.



"Danail Nachev" <d.nachev@prosyst.bg> wrote in message
news:fup82i$buh$1@build.eclipse.org...
> The correct way, should be:
>
> FileLocator.resolve(bundle.getEntry("/"))
>
> bundle.getLocation() returns unique string, identifying the bundle in
> the framework. Before R4, the bundles didn't have symbolic names and
> versions, the location was used for identifying a particular bundle.
>
> The location of the bundle is usually an URL to the original bundle
> contents, but the framework doesn't make an assumption about this. So,
> the update.configurator is marking each bundle it is responsible for by
> installing it with location starting with update@. The framework core
> also does something like that by marking the bundles from osgi.bundles
> property with initial@
>
> BR,
> Danail
>
> Karsten Panier wrote:
>> Boyan Yurukov wrote:
>>> Hello,
>>>
>>> How can I get the absolute location of a bundle's jar file? I need to
>>> build a FileInputStream out of it. I tried with :
>>>
>>> bundle.getResource(bundle.getLocation())
>>>
>>> but it doesn't return anything back. bundle.getLocation() returns
>>> something like :
>>>
>>> update@plugins/org.eclipse.ui_3.3.1.M20070910-0800b.jar
>>>
>>> which seems to be an identifier. I don't know where to use it.
>>>
>>> Thanks,
>>> Boyan.
>>>
>> Hi,
>>
>> I had similar problem. I need a InputStream on a Ressource in my Bundle.
>> It works with:
>> FileLocator.resolve(bundle().getEntry("relativePath"))
>>
>> If you use:
>> FileLocator.resolve(bundle.getResource(bundle.getLocation()) )
>> it should work.
>>
>> Hope that helps.
>> Karsten
Re: Getting a bundles jar location [message #109140 is a reply to message #109129] Tue, 06 May 2008 12:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Boyan.Yurukov.softwareag.com

Another thing that might work in the general case:

Platform.getInstallLocation().getURL().toString()+bundle.get Location().substring(7)

It does work on my computer. If bundle.getLocation() always starts with
update@ there should be no problem.

Boyan.


"Boyan Yurukov" <Boyan.Yurukov@softwareag.com> wrote in message
news:fvpikf$37e$1@build.eclipse.org...
> Thanks for the help. There is however a problem with FileLocator.resolve:
> with some configs it returns URLs like this one:
> jar:file:D:\eclipse\plugins\org.eclipse.ui_3.3.1.M20070910-0 800b.jar!/
>
> Then I pass that one to a FileInputStream, I get an error. I don't think
> that a simple cutting of the jar: part will work in the general case. I
> also tried
>
> FileLocator.openStream(bundle, new Path("\"),null)
>
> but I also get an exception.
>
> I would appreciate any other ideas?
>
> Boyan.
>
>
>
> "Danail Nachev" <d.nachev@prosyst.bg> wrote in message
> news:fup82i$buh$1@build.eclipse.org...
>> The correct way, should be:
>>
>> FileLocator.resolve(bundle.getEntry("/"))
>>
>> bundle.getLocation() returns unique string, identifying the bundle in
>> the framework. Before R4, the bundles didn't have symbolic names and
>> versions, the location was used for identifying a particular bundle.
>>
>> The location of the bundle is usually an URL to the original bundle
>> contents, but the framework doesn't make an assumption about this. So,
>> the update.configurator is marking each bundle it is responsible for by
>> installing it with location starting with update@. The framework core
>> also does something like that by marking the bundles from osgi.bundles
>> property with initial@
>>
>> BR,
>> Danail
>>
>> Karsten Panier wrote:
>>> Boyan Yurukov wrote:
>>>> Hello,
>>>>
>>>> How can I get the absolute location of a bundle's jar file? I need to
>>>> build a FileInputStream out of it. I tried with :
>>>>
>>>> bundle.getResource(bundle.getLocation())
>>>>
>>>> but it doesn't return anything back. bundle.getLocation() returns
>>>> something like :
>>>>
>>>> update@plugins/org.eclipse.ui_3.3.1.M20070910-0800b.jar
>>>>
>>>> which seems to be an identifier. I don't know where to use it.
>>>>
>>>> Thanks,
>>>> Boyan.
>>>>
>>> Hi,
>>>
>>> I had similar problem. I need a InputStream on a Ressource in my Bundle.
>>> It works with:
>>> FileLocator.resolve(bundle().getEntry("relativePath"))
>>>
>>> If you use:
>>> FileLocator.resolve(bundle.getResource(bundle.getLocation()) )
>>> it should work.
>>>
>>> Hope that helps.
>>> Karsten
>
>
Re: Getting a bundles jar location [message #109153 is a reply to message #109140] Tue, 06 May 2008 13:02 Go to previous messageGo to next message
Danail Nachev is currently offline Danail NachevFriend
Messages: 110
Registered: July 2009
Senior Member
Using the code I suggested, will give an URL which points to the root of
the bundle. In case a bundle is .jar file, it will be jar: URL, pointing
to the root of the jar file (as you already know:). In case of directory
bundle, it will point to the directory containing the bundle. So, if you
get jar: URL, you need to extract the file: URL inside.

What question arise? why do you need to get the location of the bundle
and use FileInputStream on it? Are you sure there isn't a better
solution for your problem?

BR,
Danail

Boyan Yurukov wrote:
> Another thing that might work in the general case:
>
> Platform.getInstallLocation().getURL().toString()+bundle.get Location().substring(7)
>
> It does work on my computer. If bundle.getLocation() always starts with
> update@ there should be no problem.
>
> Boyan.
>
>
> "Boyan Yurukov" <Boyan.Yurukov@softwareag.com> wrote in message
> news:fvpikf$37e$1@build.eclipse.org...
>> Thanks for the help. There is however a problem with FileLocator.resolve:
>> with some configs it returns URLs like this one:
>> jar:file:D:\eclipse\plugins\org.eclipse.ui_3.3.1.M20070910-0 800b.jar!/
>>
>> Then I pass that one to a FileInputStream, I get an error. I don't think
>> that a simple cutting of the jar: part will work in the general case. I
>> also tried
>>
>> FileLocator.openStream(bundle, new Path("\"),null)
>>
>> but I also get an exception.
>>
>> I would appreciate any other ideas?
>>
>> Boyan.
>>
>>
>>
>> "Danail Nachev" <d.nachev@prosyst.bg> wrote in message
>> news:fup82i$buh$1@build.eclipse.org...
>>> The correct way, should be:
>>>
>>> FileLocator.resolve(bundle.getEntry("/"))
>>>
>>> bundle.getLocation() returns unique string, identifying the bundle in
>>> the framework. Before R4, the bundles didn't have symbolic names and
>>> versions, the location was used for identifying a particular bundle.
>>>
>>> The location of the bundle is usually an URL to the original bundle
>>> contents, but the framework doesn't make an assumption about this. So,
>>> the update.configurator is marking each bundle it is responsible for by
>>> installing it with location starting with update@. The framework core
>>> also does something like that by marking the bundles from osgi.bundles
>>> property with initial@
>>>
>>> BR,
>>> Danail
>>>
>>> Karsten Panier wrote:
>>>> Boyan Yurukov wrote:
>>>>> Hello,
>>>>>
>>>>> How can I get the absolute location of a bundle's jar file? I need to
>>>>> build a FileInputStream out of it. I tried with :
>>>>>
>>>>> bundle.getResource(bundle.getLocation())
>>>>>
>>>>> but it doesn't return anything back. bundle.getLocation() returns
>>>>> something like :
>>>>>
>>>>> update@plugins/org.eclipse.ui_3.3.1.M20070910-0800b.jar
>>>>>
>>>>> which seems to be an identifier. I don't know where to use it.
>>>>>
>>>>> Thanks,
>>>>> Boyan.
>>>>>
>>>> Hi,
>>>>
>>>> I had similar problem. I need a InputStream on a Ressource in my Bundle.
>>>> It works with:
>>>> FileLocator.resolve(bundle().getEntry("relativePath"))
>>>>
>>>> If you use:
>>>> FileLocator.resolve(bundle.getResource(bundle.getLocation()) )
>>>> it should work.
>>>>
>>>> Hope that helps.
>>>> Karsten
>>
>
>
Re: Getting a bundles jar location [message #109164 is a reply to message #109153] Tue, 06 May 2008 13:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Boyan.Yurukov.softwareag.com

I am writing a wizard that should take a plugin and all its required
plugins, pack them in a stream, send them through http and install them in
another eclipse. With BundleContext.installBundle I can install from a
stream on the target eclipse, so the only thing I need is to be able to get
all the bundles I need as streams on the source eclipse. Basically the task
can be narrowed down to getting a jar or folder of a plugin as an
inputstream.

I did the thing you said and extracted the location of a jar (file:...), but
then I found that I can't read it. File.canRead returns false, so I can't
create and inputstream. I guess the same will happen with a plugin installed
in a folder.

Another method I though of is reading all the files in a bundle, packing
them as a jar in a temp folder and streaming that though http. Haven't tried
it yet though.

Boyan.


"Danail Nachev" <d.nachev@prosyst.bg> wrote in message
news:fvpkt4$qbm$1@build.eclipse.org...
> Using the code I suggested, will give an URL which points to the root of
> the bundle. In case a bundle is .jar file, it will be jar: URL, pointing
> to the root of the jar file (as you already know:). In case of directory
> bundle, it will point to the directory containing the bundle. So, if you
> get jar: URL, you need to extract the file: URL inside.
>
> What question arise? why do you need to get the location of the bundle
> and use FileInputStream on it? Are you sure there isn't a better
> solution for your problem?
>
> BR,
> Danail
>
> Boyan Yurukov wrote:
>> Another thing that might work in the general case:
>>
>> Platform.getInstallLocation().getURL().toString()+bundle.get Location().substring(7)
>>
>> It does work on my computer. If bundle.getLocation() always starts with
>> update@ there should be no problem.
>>
>> Boyan.
>>
>>
>> "Boyan Yurukov" <Boyan.Yurukov@softwareag.com> wrote in message
>> news:fvpikf$37e$1@build.eclipse.org...
>>> Thanks for the help. There is however a problem with
>>> FileLocator.resolve:
>>> with some configs it returns URLs like this one:
>>> jar:file:D:\eclipse\plugins\org.eclipse.ui_3.3.1.M20070910-0 800b.jar!/
>>>
>>> Then I pass that one to a FileInputStream, I get an error. I don't think
>>> that a simple cutting of the jar: part will work in the general case. I
>>> also tried
>>>
>>> FileLocator.openStream(bundle, new Path("\"),null)
>>>
>>> but I also get an exception.
>>>
>>> I would appreciate any other ideas?
>>>
>>> Boyan.
>>>
>>>
>>>
>>> "Danail Nachev" <d.nachev@prosyst.bg> wrote in message
>>> news:fup82i$buh$1@build.eclipse.org...
>>>> The correct way, should be:
>>>>
>>>> FileLocator.resolve(bundle.getEntry("/"))
>>>>
>>>> bundle.getLocation() returns unique string, identifying the bundle in
>>>> the framework. Before R4, the bundles didn't have symbolic names and
>>>> versions, the location was used for identifying a particular bundle.
>>>>
>>>> The location of the bundle is usually an URL to the original bundle
>>>> contents, but the framework doesn't make an assumption about this. So,
>>>> the update.configurator is marking each bundle it is responsible for by
>>>> installing it with location starting with update@. The framework core
>>>> also does something like that by marking the bundles from osgi.bundles
>>>> property with initial@
>>>>
>>>> BR,
>>>> Danail
>>>>
>>>> Karsten Panier wrote:
>>>>> Boyan Yurukov wrote:
>>>>>> Hello,
>>>>>>
>>>>>> How can I get the absolute location of a bundle's jar file? I need to
>>>>>> build a FileInputStream out of it. I tried with :
>>>>>>
>>>>>> bundle.getResource(bundle.getLocation())
>>>>>>
>>>>>> but it doesn't return anything back. bundle.getLocation() returns
>>>>>> something like :
>>>>>>
>>>>>> update@plugins/org.eclipse.ui_3.3.1.M20070910-0800b.jar
>>>>>>
>>>>>> which seems to be an identifier. I don't know where to use it.
>>>>>>
>>>>>> Thanks,
>>>>>> Boyan.
>>>>>>
>>>>> Hi,
>>>>>
>>>>> I had similar problem. I need a InputStream on a Ressource in my
>>>>> Bundle.
>>>>> It works with:
>>>>> FileLocator.resolve(bundle().getEntry("relativePath"))
>>>>>
>>>>> If you use:
>>>>> FileLocator.resolve(bundle.getResource(bundle.getLocation()) )
>>>>> it should work.
>>>>>
>>>>> Hope that helps.
>>>>> Karsten
>>>
>>
>>
Re: Getting a bundles jar location [message #109178 is a reply to message #109164] Tue, 06 May 2008 15:52 Go to previous messageGo to next message
Danail Nachev is currently offline Danail NachevFriend
Messages: 110
Registered: July 2009
Senior Member
This is strange. If you extract the correct path, then File.canRead
should return true (how Eclipse itself reads this path). So, check that
the path you use for creating the File object is correct. If you have
trouble, can you post the:

- the result from FileLocator.resolve()
- the parameters to new File() or new FileInputStream()

Regarding the folders -> you'll need to detect and most probably need to
pack them before forwarding obviously:)

Boyan Yurukov wrote:
> I am writing a wizard that should take a plugin and all its required
> plugins, pack them in a stream, send them through http and install them in
> another eclipse. With BundleContext.installBundle I can install from a
> stream on the target eclipse, so the only thing I need is to be able to get
> all the bundles I need as streams on the source eclipse. Basically the task
> can be narrowed down to getting a jar or folder of a plugin as an
> inputstream.
>
> I did the thing you said and extracted the location of a jar (file:...), but
> then I found that I can't read it. File.canRead returns false, so I can't
> create and inputstream. I guess the same will happen with a plugin installed
> in a folder.
>
> Another method I though of is reading all the files in a bundle, packing
> them as a jar in a temp folder and streaming that though http. Haven't tried
> it yet though.
>
> Boyan.
>
>
> "Danail Nachev" <d.nachev@prosyst.bg> wrote in message
> news:fvpkt4$qbm$1@build.eclipse.org...
>> Using the code I suggested, will give an URL which points to the root of
>> the bundle. In case a bundle is .jar file, it will be jar: URL, pointing
>> to the root of the jar file (as you already know:). In case of directory
>> bundle, it will point to the directory containing the bundle. So, if you
>> get jar: URL, you need to extract the file: URL inside.
>>
>> What question arise? why do you need to get the location of the bundle
>> and use FileInputStream on it? Are you sure there isn't a better
>> solution for your problem?
>>
>> BR,
>> Danail
>>
>> Boyan Yurukov wrote:
>>> Another thing that might work in the general case:
>>>
>>> Platform.getInstallLocation().getURL().toString()+bundle.get Location().substring(7)
>>>
>>> It does work on my computer. If bundle.getLocation() always starts with
>>> update@ there should be no problem.
>>>
>>> Boyan.
>>>
>>>
>>> "Boyan Yurukov" <Boyan.Yurukov@softwareag.com> wrote in message
>>> news:fvpikf$37e$1@build.eclipse.org...
>>>> Thanks for the help. There is however a problem with
>>>> FileLocator.resolve:
>>>> with some configs it returns URLs like this one:
>>>> jar:file:D:\eclipse\plugins\org.eclipse.ui_3.3.1.M20070910-0 800b.jar!/
>>>>
>>>> Then I pass that one to a FileInputStream, I get an error. I don't think
>>>> that a simple cutting of the jar: part will work in the general case. I
>>>> also tried
>>>>
>>>> FileLocator.openStream(bundle, new Path("\"),null)
>>>>
>>>> but I also get an exception.
>>>>
>>>> I would appreciate any other ideas?
>>>>
>>>> Boyan.
>>>>
>>>>
>>>>
>>>> "Danail Nachev" <d.nachev@prosyst.bg> wrote in message
>>>> news:fup82i$buh$1@build.eclipse.org...
>>>>> The correct way, should be:
>>>>>
>>>>> FileLocator.resolve(bundle.getEntry("/"))
>>>>>
>>>>> bundle.getLocation() returns unique string, identifying the bundle in
>>>>> the framework. Before R4, the bundles didn't have symbolic names and
>>>>> versions, the location was used for identifying a particular bundle.
>>>>>
>>>>> The location of the bundle is usually an URL to the original bundle
>>>>> contents, but the framework doesn't make an assumption about this. So,
>>>>> the update.configurator is marking each bundle it is responsible for by
>>>>> installing it with location starting with update@. The framework core
>>>>> also does something like that by marking the bundles from osgi.bundles
>>>>> property with initial@
>>>>>
>>>>> BR,
>>>>> Danail
>>>>>
>>>>> Karsten Panier wrote:
>>>>>> Boyan Yurukov wrote:
>>>>>>> Hello,
>>>>>>>
>>>>>>> How can I get the absolute location of a bundle's jar file? I need to
>>>>>>> build a FileInputStream out of it. I tried with :
>>>>>>>
>>>>>>> bundle.getResource(bundle.getLocation())
>>>>>>>
>>>>>>> but it doesn't return anything back. bundle.getLocation() returns
>>>>>>> something like :
>>>>>>>
>>>>>>> update@plugins/org.eclipse.ui_3.3.1.M20070910-0800b.jar
>>>>>>>
>>>>>>> which seems to be an identifier. I don't know where to use it.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Boyan.
>>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I had similar problem. I need a InputStream on a Ressource in my
>>>>>> Bundle.
>>>>>> It works with:
>>>>>> FileLocator.resolve(bundle().getEntry("relativePath"))
>>>>>>
>>>>>> If you use:
>>>>>> FileLocator.resolve(bundle.getResource(bundle.getLocation()) )
>>>>>> it should work.
>>>>>>
>>>>>> Hope that helps.
>>>>>> Karsten
>>>
>
>
Re: Getting a bundles jar location [message #109546 is a reply to message #109178] Tue, 13 May 2008 12:48 Go to previous message
Eclipse UserFriend
Originally posted by: Boyan.Yurukov.softwareag.com

Oh my mistake - I parsed the address wrongly. It works fine. Thanks a lot
for the help.

Boyan.


"Danail Nachev" <d.nachev@prosyst.bg> wrote in message
news:fvpusk$gq9$1@build.eclipse.org...
> This is strange. If you extract the correct path, then File.canRead
> should return true (how Eclipse itself reads this path). So, check that
> the path you use for creating the File object is correct. If you have
> trouble, can you post the:
>
> - the result from FileLocator.resolve()
> - the parameters to new File() or new FileInputStream()
>
> Regarding the folders -> you'll need to detect and most probably need to
> pack them before forwarding obviously:)
>
> Boyan Yurukov wrote:
>> I am writing a wizard that should take a plugin and all its required
>> plugins, pack them in a stream, send them through http and install them
>> in
>> another eclipse. With BundleContext.installBundle I can install from a
>> stream on the target eclipse, so the only thing I need is to be able to
>> get
>> all the bundles I need as streams on the source eclipse. Basically the
>> task
>> can be narrowed down to getting a jar or folder of a plugin as an
>> inputstream.
>>
>> I did the thing you said and extracted the location of a jar (file:...),
>> but
>> then I found that I can't read it. File.canRead returns false, so I can't
>> create and inputstream. I guess the same will happen with a plugin
>> installed
>> in a folder.
>>
>> Another method I though of is reading all the files in a bundle, packing
>> them as a jar in a temp folder and streaming that though http. Haven't
>> tried
>> it yet though.
>>
>> Boyan.
>>
>>
>> "Danail Nachev" <d.nachev@prosyst.bg> wrote in message
>> news:fvpkt4$qbm$1@build.eclipse.org...
>>> Using the code I suggested, will give an URL which points to the root of
>>> the bundle. In case a bundle is .jar file, it will be jar: URL, pointing
>>> to the root of the jar file (as you already know:). In case of directory
>>> bundle, it will point to the directory containing the bundle. So, if you
>>> get jar: URL, you need to extract the file: URL inside.
>>>
>>> What question arise? why do you need to get the location of the bundle
>>> and use FileInputStream on it? Are you sure there isn't a better
>>> solution for your problem?
>>>
>>> BR,
>>> Danail
>>>
>>> Boyan Yurukov wrote:
>>>> Another thing that might work in the general case:
>>>>
>>>> Platform.getInstallLocation().getURL().toString()+bundle.get Location().substring(7)
>>>>
>>>> It does work on my computer. If bundle.getLocation() always starts with
>>>> update@ there should be no problem.
>>>>
>>>> Boyan.
>>>>
>>>>
>>>> "Boyan Yurukov" <Boyan.Yurukov@softwareag.com> wrote in message
>>>> news:fvpikf$37e$1@build.eclipse.org...
>>>>> Thanks for the help. There is however a problem with
>>>>> FileLocator.resolve:
>>>>> with some configs it returns URLs like this one:
>>>>> jar:file:D:\eclipse\plugins\org.eclipse.ui_3.3.1.M20070910-0 800b.jar!/
>>>>>
>>>>> Then I pass that one to a FileInputStream, I get an error. I don't
>>>>> think
>>>>> that a simple cutting of the jar: part will work in the general case.
>>>>> I
>>>>> also tried
>>>>>
>>>>> FileLocator.openStream(bundle, new Path("\"),null)
>>>>>
>>>>> but I also get an exception.
>>>>>
>>>>> I would appreciate any other ideas?
>>>>>
>>>>> Boyan.
>>>>>
>>>>>
>>>>>
>>>>> "Danail Nachev" <d.nachev@prosyst.bg> wrote in message
>>>>> news:fup82i$buh$1@build.eclipse.org...
>>>>>> The correct way, should be:
>>>>>>
>>>>>> FileLocator.resolve(bundle.getEntry("/"))
>>>>>>
>>>>>> bundle.getLocation() returns unique string, identifying the bundle in
>>>>>> the framework. Before R4, the bundles didn't have symbolic names and
>>>>>> versions, the location was used for identifying a particular bundle.
>>>>>>
>>>>>> The location of the bundle is usually an URL to the original bundle
>>>>>> contents, but the framework doesn't make an assumption about this.
>>>>>> So,
>>>>>> the update.configurator is marking each bundle it is responsible for
>>>>>> by
>>>>>> installing it with location starting with update@. The framework core
>>>>>> also does something like that by marking the bundles from
>>>>>> osgi.bundles
>>>>>> property with initial@
>>>>>>
>>>>>> BR,
>>>>>> Danail
>>>>>>
>>>>>> Karsten Panier wrote:
>>>>>>> Boyan Yurukov wrote:
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> How can I get the absolute location of a bundle's jar file? I need
>>>>>>>> to
>>>>>>>> build a FileInputStream out of it. I tried with :
>>>>>>>>
>>>>>>>> bundle.getResource(bundle.getLocation())
>>>>>>>>
>>>>>>>> but it doesn't return anything back. bundle.getLocation() returns
>>>>>>>> something like :
>>>>>>>>
>>>>>>>> update@plugins/org.eclipse.ui_3.3.1.M20070910-0800b.jar
>>>>>>>>
>>>>>>>> which seems to be an identifier. I don't know where to use it.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Boyan.
>>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I had similar problem. I need a InputStream on a Ressource in my
>>>>>>> Bundle.
>>>>>>> It works with:
>>>>>>> FileLocator.resolve(bundle().getEntry("relativePath"))
>>>>>>>
>>>>>>> If you use:
>>>>>>> FileLocator.resolve(bundle.getResource(bundle.getLocation()) )
>>>>>>> it should work.
>>>>>>>
>>>>>>> Hope that helps.
>>>>>>> Karsten
>>>>
>>
>>
Previous Topic:ApplicationDescriptor + OSX
Next Topic:self-provisioning
Goto Forum:
  


Current Time: Thu Mar 28 21:50:01 GMT 2024

Powered by FUDForum. Page generated in 0.03168 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top