Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » where to store a derby database in a plugin?
where to store a derby database in a plugin? [message #436412] Wed, 07 September 2005 17:22 Go to next message
Eclipse UserFriend
Originally posted by: bdberry.us.ibm.com

Hi,

My RCP app uses a derby database that will be common to all of the
projects in the workspace. Where is the recommended location to store a
comon resource like this. Also, a web service will be updating the db
from time to time.

Thanks
Re: where to store a derby database in a plugin? [message #436413 is a reply to message #436412] Wed, 07 September 2005 17:53 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
Have a plugin that stores the database contents in its own storage area; then have all other plugins depend on that?
Re: where to store a derby database in a plugin? [message #436493 is a reply to message #436413] Fri, 09 September 2005 13:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bdberry.us.ibm.com

Alex Blewitt wrote:
> Have a plugin that stores the database contents in its own storage area; then have all other plugins depend on that?

that was my question - where is a good place to store these types of
resources? Is there some sort of best practice for that? Also, this is
a derby database so I need to know the location when creating the DB URL
for making connections.
Re: where to store a derby database in a plugin? [message #436689 is a reply to message #436493] Thu, 15 September 2005 03:10 Go to previous messageGo to next message
David Ayre is currently offline David AyreFriend
Messages: 3
Registered: July 2009
Junior Member
I've been doing something similar. I've been storing the derby database in a data directory within the plugin location. Basically, i have a derby plugin which wraps the derby jars, then i have this utility method which i'm using for a bunch of plugins. It takes the plugin ID, and most of this code came from the Eclipse 3.0 FAQ book (good resource). It looks up the plugin's data directory by id and returns an absolute File instance which can be used to initiate the Derby database home location. Hope this helps... just looking at it now i see some excessive exception handling... but you get the idea...

	/**
	 * Returns a File instance representing the directory or file of the given
	 * filename in the Plugin data directory for the plugin with the given id.
	 * @param eclipsePluginId
	 * @param filename
	 * @return
	 */
	public static File getPluginData(String eclipsePluginId, String filename) {
		try {
			System.out.println(new File(".").getAbsolutePath());
			
			Bundle bundle = null;
			try {
				bundle = Platform.getBundle(eclipsePluginId);
				
				URL fileURL = Platform.find(bundle, new Path("data/" + filename));
				URI fileURI = new URI(Platform.resolve(fileURL).toString().replaceAll(" ", "%20"));
				
				return new File(fileURI);
			}
			catch (Throwable e) {
				File dir = new File("." + File.separatorChar + "data");
				LogManager.theInstance().getDefaultLog().warn("Failed to get plugin data directory (not in headless mode ?) using: " + dir.getAbsolutePath());
				return dir;
			}

		}
		catch (Exception e) {
			throw new InternalException("Error creating file '" + filename + 
					"' for plug-in data for plug-in '" + 
					eclipsePluginId + "': " + e.getMessage(), e);
		}
		
	}
Re: where to store a derby database in a plugin? [message #436742 is a reply to message #436689] Fri, 16 September 2005 14:44 Go to previous message
Peter Manahan is currently offline Peter ManahanFriend
Messages: 131
Registered: July 2009
Senior Member
Plugins should be considered readonly for the most part. If you were
using update manager for example to update your application then your
data directory is now in a different plugin that the one returned by
Platform.find.

It is probably a better idea to put the data into the instance area of a
workspace or the configuration area or even in the users home directory
depending on the scope.

The eclipse help search on "Eclipse multi-user installs" has a nice
little overview of some different area's stuff can go into.

Although it depends on the usage of your application you never know
how a user will use it. If it is ever required for example to be
installed by an administrator and run by a user without write access to
the plugin then the idea of keeping the data in the plugin should be
reconsidered.

Peter
Previous Topic:triggering isDirty from EMF model change
Next Topic:Openning external files with the System Editor
Goto Forum:
  


Current Time: Fri Dec 06 15:03:46 GMT 2024

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

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

Back to the top