Persistence in desktop applications
Will you bundle a full RDMBS with your GUI applications? How are you persisting the model in your desktop applications? What are the trends in this area?
Well. If you build a Swing application that needs to persist your model then you don't probably want your users to download and install MySQL first. Right?
This is the problem I'm facing with the RSS feed reader I'm buildling. I want to store all the RSS feeds somewhere and be able to search them. Stuff there should be indexed. That easy. Easy? Or not?
Relational or non relational?
So, do I really need a relational database? I mean, there're lots of different relational databases that are (probably) lightweight enough to be downloaded using Java Web Start. But, do I really need one?
Furthermore, is there any advantage of using one? Since I program in Java I'll have to map my objects to relational tables. And all the way round. And use JDBC. I'm fluent in JDBC, but the mapping and the tables are a hassle for me. I would prefer an object oriented database. A tiny, embeddable, lightweight one. Or even a filesystem based non-relational storage mechanism. Or a lightweight XML database.
Open source, please...
Since my project will be open source I'd like the database to be open source too. And, of course, it should not force me to use any sort of license. I don't know much about licenses, but I think the LGPL, the CDDL, the Apache license, the SPL and the MPL would to, but the GPL would not (since it'd force me to be GPL too).
The database is out there... or not?
To summarize the constraints: a lightweight, embeddable storage mechanism that is open source. What's out there in the Internet? Is this possible?
I've done some research and this is what I've found. Please let me know if the list is not complete or if you know of any other storage mechanism (whatever that is) that I'm not considering.
NetBeans is delivered under the Sun Public License, a variation of the Mozilla Public License, so I think I can bundle parts of it even in commercial applications. That's good.
The NetBeans MetaData Repository module of NetBeans may use a B-Tree storage mechanism (let's call it NBP, for NetBeans Persistence). This NBP is simple, lightweight and performs very well. The only problem I've seen is that since the storage mechanism is not a part of the NetBeans Open APIs, there's little documentation about it.
This B-Tree storage mechanism is used by many non-relational databases, such as the famous Berkeley SleepyCat database (which, by the way, is bundled with many commercial applications, including different Sun products. UPDATE: Oracle has adquired the Berkeley SleepyCat Database as of today).
The NBP allows you to store any object and index it (using one or more indexes, indexes may be multivalued). Indexes may be Strings, MOFIDs (and probably Integers, and Longs, not sure, though). Good enough for most applications.
I am still investigating how NBP works. I'll have to find out how well NBP supports multithreading and if NBP is transactional or not.
NBP databases consist of two files: a file with all the records and another file with all the indexes.
I have not found yet how to use the NBP (but the sources, of course). Anyway this test cases exercise the NBP and thus may be a good starting point for knowing how to work with this NBP.
So, to summarize: NBP is delivered under a nice license (SPL), seems to be sound enough (has been in production for quite a long time), is lightweight to be bundled with desktop applications and seems to be easy to use. I like it. If you find good pointers on how to use NBP please tell me.
Jalisto was a commercial product by Xcalia that has been open-sourced and is available as Jalisto in ObjectWeb. Version 1.0 is available since sept. 2005. The project is licensed under the LGPL.
What I like about Jalisto is that is quite modular, so you can plug-in different modules as you need (or remove them if you don't) to make your applications easier to embed. It seems the project is available for J2ME too.
As far as I've seen Jalisto stores arrays of objects (so it's somewhat harder to use than object-oriented databases), it works in multithreaded environments, contains a (pluggable) caching mechanism and provides transactions.
Jalisto is probably my best choice at the moment. I'll investigate about performance, but the design and architecture of this database seems to be very good.
EyeDB is a variation of IDB, a database used to store Genome information. I think it was a multivalued database (the same type of databases used by the Pick operating system, and that are becoming fashionable nowadays for storing XML documents) but I'm not sure. The fact is that EyeDB can handle databases of several terabytes and hundred of millions of objects.
EyeDB was released last month as an open source project. It is released under the LGPL license.
EyeDB is a native database (not pure Java) but provides a Java binding. That's probably a good idea if you want to read the database from within native applications. There's no version for Windows, though.
For working with EyeDB you have to define objects using a language based on the ODMG ODL (Object Definition Language) and you query the database using a language based on ODMG OQL (Object Query Language).
I assume this is thread safe. I've seen it implements transactionality. It's seems to be heavier than Jalisto.
Maybe EyeDB is not good for embedding, but I thought it was good mentioning it. After all it's just been released a few days ago.
Ozone has been around for quite a long time. It's probably not a good choice if you want to embed it in your desktop application.
Ozone does not need any RDBMS (well, of course!). May be used for storing XML data. It's almost ODMG 3.0 compliant.
As you can see I'm still doing research on the embeddable storage for Java desktop applications. I'd appreciate if you send me pointers to any other project or storage mechanism or if you share experiences. At the moment Jalisto seems to be the way to go, but I'll have to do a small test to see how performant it is.
Cheers, Antonioblog comments powered by Disqus