How to find a plugin's physical location [message #303160] |
Tue, 09 May 2006 22:14 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: gjipp_nospam.ca.ibm.com
In PDE is there a wat to determine exactly where an plugin is located on the drive?
I have a plugin that is NOT a java plugin, just a plain plugin with data files. it has an id like: com.company.myplugin
Is there a way to find out where com.compaany.myplugin is located?
Thanks
|
|
|
Re: How to find a plugin's physical location [message #303196 is a reply to message #303160] |
Wed, 10 May 2006 12:08 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
|
Gary J wrote:
> In PDE is there a wat to determine exactly where an plugin is located on the drive?
>
> I have a plugin that is NOT a java plugin, just a plain plugin with data files. it has an id like: com.company.myplugin
>
> Is there a way to find out where com.compaany.myplugin is located?
The best way to use it is:
URL textfile =
MyPlugin.getDefault().getBundle().getEntry("/path/to/file.txt ");
You can then get the input stream from textfile and copy it where ever
you want.
In theory, you can get your plugin location by using:
URL dir =
MyPlugin.getDefault().getBundle().getEntry("/");
URL localdir = Platform.asLocalURL(dir); # FileLocator in 3.2
localdir will be a file: url, but if your plugin was a jar plugin it
will have to expand the contents into a temp location ... chewing up
space and taking time.
Later,
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
Re: How to find a plugin's physical location [message #303242 is a reply to message #303196] |
Wed, 10 May 2006 16:17 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: gjipp_nospam.ca.ibm.com
Thanks, the asLocalURL() method is really useful. When its a java plugin I can use that to resolve the actual file location. That
actually solves a different issue I was having much nicer.
How about in the case where MyPlugin is NOT a java plugin? Its an OSGI-type plugin with a manifest.MF file but no java code, just a
bunch of jar and other data files.
How can I find out where it is if there's no plugin class and therefore no getBundle method to call? Eclipse obviously knows where
it is?
It might be in the eclipse/plugins directory or it might be in another directory referenced by a link file so I can not assume its
under my Eclipse directory.
Perhaps there's a different approach. As there any methods to enumerate all the plugins loaded and "get" back some class with a
"I'm here" method?
Thanks
GVJ
"Paul Webster" <pwebster@ca.ibm.com> wrote in message news:e3sl4u$ep1$1@utils.eclipse.org...
Gary J wrote:
> In PDE is there a wat to determine exactly where an plugin is located on the drive?
>
> I have a plugin that is NOT a java plugin, just a plain plugin with data files. it has an id like: com.company.myplugin
>
> Is there a way to find out where com.compaany.myplugin is located?
The best way to use it is:
URL textfile =
MyPlugin.getDefault().getBundle().getEntry("/path/to/file.txt ");
You can then get the input stream from textfile and copy it where ever
you want.
In theory, you can get your plugin location by using:
URL dir =
MyPlugin.getDefault().getBundle().getEntry("/");
URL localdir = Platform.asLocalURL(dir); # FileLocator in 3.2
localdir will be a file: url, but if your plugin was a jar plugin it
will have to expand the contents into a temp location ... chewing up
space and taking time.
Later,
PW
|
|
|
Re: How to find a plugin's physical location [message #303243 is a reply to message #303242] |
Wed, 10 May 2006 16:50 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
|
Gary J wrote:
> Thanks, the asLocalURL() method is really useful. When its a java plugin I can use that to resolve the actual file location. That
> actually solves a different issue I was having much nicer.
>
> How about in the case where MyPlugin is NOT a java plugin? Its an OSGI-type plugin with a manifest.MF file but no java code, just a
> bunch of jar and other data files.
>
> How can I find out where it is if there's no plugin class and therefore no getBundle method to call? Eclipse obviously knows where
> it is?
>
> It might be in the eclipse/plugins directory or it might be in another directory referenced by a link file so I can not assume its
> under my Eclipse directory.
>
> Perhaps there's a different approach. As there any methods to enumerate all the plugins loaded and "get" back some class with a
> "I'm here" method?
>
If you don't have a plugin, you can use the static method
Platform.getBundle("bundle.id") instead of
MyPlugin.getDefault().getBundle().
From there it's the same.
Try as much as possible to use InputStreams from URLs.
Later,
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
Re: How to find a plugin's physical location [message #303247 is a reply to message #303242] |
Wed, 10 May 2006 19:38 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
Be very careful with asLocalURL(). This will make a cached copy of the
contents on your local system if it is not a local file (or if the file
being pointed to is within a jar). This can be very wasteful.
It is usually better to access the contents of the file as a stream.
--
Thanks,
Rich Kulp
|
|
|
Powered by
FUDForum. Page generated in 0.03814 seconds