Our project has complex object graphs in memory to calculate the available slot for scheduler. Core engine needs to solve the problem of constrains of routing, resource, machine, people and tools. This is a NP hard problem. So we consume very big big object graphs to represent whole scheduler in memory. We create our own cache, command, even-handler and transaction control. We have to make sure the complex object graphs can do things like transaction to create, read, update and delete. Especially scheduler has to be rollback both in memory and database. Here is example:

//unit of work
try{
   transaction.start();
   commandSyncOrder.create(orderbean);
   transaction.end()
}catch(Exception ex){

   //rollback in memory
   commandSyncOrder.undo();

   //rollback in database
   transaction.rollback();
}finally{

   commandSyncOrder.close(); //enforce object clean up
                            //not to depend on finalized from garbage collection
   transaction.close();     //close JDBC connection
}

Now I try to redesign this core scheduler engine to use Spring and Hibernate because we already implement that for 3 tier client-server web application. I found those post may solve my problem.

Advertisements