Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » how to extract additional file types from bundle(Not all files are being extracted from plugin)
how to extract additional file types from bundle [message #651521] Mon, 31 January 2011 14:34 Go to next message
Bo Ens is currently offline Bo EnsFriend
Messages: 10
Registered: January 2010
Junior Member
In our RCP app, we have a set of data files that are required to be read by in by one of our plug-ins. When the plug-in is extracted into "configuration/org.eclipse.osgi/bundles", these data files are not extracted from the plug-in jar file. How do I add support for these file types so they are extracted?

Thanks.
Re: how to extract additional file types from bundle [message #651534 is a reply to message #651521] Mon, 31 January 2011 15:24 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 01/31/2011 09:34 AM, Ens wrote:
> In our RCP app, we have a set of data files that are required to be read
> by in by one of our plug-ins. When the plug-in is extracted into
> "configuration/org.eclipse.osgi/bundles", these data files are not
> extracted from the plug-in jar file. How do I add support for these file
> types so they are extracted?

In general, you make sure the files are included in your bundle using
the build.properties file (for files that are in the root of your plugin
project, as resources within the source tree are included automatically).

If they really were resources, you simply use
getClass().getResourceAsStream(*).

If they were included in your plugin, you use Bundle.getEntry(*) to get
the InputStream from the URL.

If you need files on the disk ... first I'd ask why, then send you to
FileLocator (which for a given bundle entry, will return a URL that
points to a file on disk).

PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: how to extract additional file types from bundle [message #651566 is a reply to message #651534] Mon, 31 January 2011 16:38 Go to previous messageGo to next message
Bo Ens is currently offline Bo EnsFriend
Messages: 10
Registered: January 2010
Junior Member
These files are included in the build.properties (and exist in the jar file).

We have a 3rd-party map wrapped by our plug-in and we are including a basic set of default shape files inside the plug-in. We do get the shape files using the getResource and FileLocator, but unfortunately, the shape files have 5 or 6 additional supporting files that we may not know about in the code.

Is it possible to enumerate all files in the map data directory and use the getResource/FileLocator to extract them. If we cannot determine at runtime which files are there, then we could just use a zip file and extract it at startup (this would be a last resort).

We just want all files required by 3rd-party application to be extracted from bundle, regardless of file type. they are all located under the same directory.
Re: how to extract additional file types from bundle [message #651585 is a reply to message #651566] Mon, 31 January 2011 17:50 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 01/31/2011 11:38 AM, Ens wrote:
> Is it possible to enumerate all files in the map data directory and use
> the getResource/FileLocator to extract them. If we cannot determine at
> runtime which files are there, then we could just use a zip file and
> extract it at startup (this would be a last resort).

getResource(*) works on specific resources. But bundle entries can
enumerate all entries, and even without that FileLocator can extract an
entire folder with one call. Just use getEntry(*) with the folder name
(AFAIK).


PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: how to extract additional file types from bundle [message #651618 is a reply to message #651585] Mon, 31 January 2011 22:06 Go to previous messageGo to next message
Bo Ens is currently offline Bo EnsFriend
Messages: 10
Registered: January 2010
Junior Member
Thanks for the info. I ended up having to use Bundle.getEntryPaths to list all files inside the directory and then called Bundle.getResource/FileLocator.toFileURL on each file in the directory. Calling Bundle.getEntry did not pull any files from the bundle jar file into the cache.
Re: how to extract additional file types from bundle [message #651734 is a reply to message #651618] Tue, 01 February 2011 12:58 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 01/31/2011 05:06 PM, Ens wrote:
> Calling Bundle.getEntry did not pull any files from the bundle jar file
> into the cache.

Bundle.getEntry(*) can be used to find the folder location (and return a
URL). If that URL is run through FileLocator.toFileURL(*) it will
extract the contents of the folder to the filesystem.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: how to extract additional file types from bundle [message #651771 is a reply to message #651734] Tue, 01 February 2011 14:35 Go to previous message
Bo Ens is currently offline Bo EnsFriend
Messages: 10
Registered: January 2010
Junior Member
That worked and is much cleaner, didn't realize you could specify the folder in the FileLocator.toFileURL call. Thanks for your help.
Previous Topic:Property Change listener query
Next Topic:How to load custom perspective from XML Memento
Goto Forum:
  


Current Time: Wed Apr 24 20:27:30 GMT 2024

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

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

Back to the top