Banner logo

hosted by SourceForge.net

JavaMatch does not stand on its own. Data structures are typically not only kept in memory, but also stored in a file system or database. This page describes how JavaMatch works in combination with such storage mechanisms.

JDO

JDO, the standard for transparent object persistence, enables you to match in databases. JDO has a query language, JDOQL. This language can be used to improve JavaMatch's performance in two different ways:

  • Translate the subqueries into JDOQL, to reduce the amount of objects that are iterated during the matching. This can only be done for those queries that have a corresponding JDOQL operator
  • Use JDOQL's min and max operators for Minimum and Maximum-queries, to avoid the pre-pass iteration. (This is a JDO 2.0 feature)

Prevayler

Prevayler does not use a database. It keeps the entire data structure in memory. Therefore, matching the data that is persisted in Prevayler is exactly the same as matching data that is not persisted.

Example

Prevayler has an example bank application, that is used to handle accounts. This can be found in directory src\org\prevayler\demos\demo2\gui in the Prevayler source distribution. The program maintains a list of accounts, each with a balance, where you can desposit, withdraw and transfer money.

With JavaMatch, this program can be extended to show a list of "most interesting accounts": The accounts that have the highest balance, or that are the most active (had the most deposits, withdrawals and transfers). The business logic doesn't need any changes, it's just another view on the same data.

To run this demo, put the file MatchFrame.java in directory src/org/prevayler/demos/demo2/gui. Then edit file src/org/prevayler/demos/demo2/gui/BankFrame.java: Where the frames are created (near line 27 in the current version), add the line

new MatchFrame(prevayler, desktop);

This adds another frame to the user interface, one that shows the results of the matching.

Before compiling the demo, add javamatch.jar to the lib directory, and add this to the classpath when compiling / running the application.

If you have ant, you might want to use build.xml. Put it in the prevayler-X.YY.ZZZ directory, run ant in that same directory, and you'll see the demo:
Prevayler screenshot