Remote Execution Through Evaluation API

One of the ways to do that is using evaluation API. Evaluation/candidate classes are serialized and sent to the server. That means that if we will put the selection criteria and update code inside evaluation class, we will have that code on the server and executing a query using evaluation on the client side will run the update code on the server side.

For easier query execution we can use database singleton - a class that have only one instance saved in the database. That actually can be the class calling the query itself.

Let's fill up our server database:

RemoteExample.java: setObjects
01private static void setObjects() { 02 new File(DB4O_FILE_NAME).delete(); 03 ObjectContainer container = Db4o.openFile(DB4O_FILE_NAME); 04 try { 05 for (int i = 0; i < 5; i++) { 06 Car car = new Car("car" + i); 07 container.set(car); 08 } 09 container.set(new RemoteExample()); 10 } finally { 11 container.close(); 12 } 13 checkCars(); 14 }

This method has its pros and cons.

Pros:

Cons: