1 import org.ozoneDB.LocalDatabase; 2 import org.ozoneDB.OzoneInterface; 3 4 10 public class LocalClient { 11 12 13 public static void main(String [] args) throws Exception { 14 LocalDatabase db = new LocalDatabase(); 17 String dbLocation = System.getProperty("user.home") + "/testdb"; 18 if (!db.exists(dbLocation)) { 19 db.create(dbLocation); 20 } 21 db.open(dbLocation); 22 23 db.reloadClasses(); 24 System.out.println("connected..."); 25 26 Bus bus = (Bus) db.createObject(BusImpl.class.getName()); 27 System.out.println("bus:" + bus); 28 bus.print(); 29 db.deleteObject(bus); 30 31 Auto auto = (Auto) db.objectForName("auto"); 32 if (auto == null) { 33 auto = (Auto) db.createObject(AutoImpl.class.getName(), OzoneInterface.Public, "auto"); 34 } 35 36 Auto auto2 = (Auto) auto.doSomething(auto); 39 40 System.out.println("auto:" + auto); 41 auto.setAge(3); 42 System.out.println("auto.setAge (3)"); 43 System.out.println("auto2:" + auto2); 45 46 Auto copy = (Auto) db.copyObject(auto); 47 copy.setAge(100); 48 System.out.println("\nauto:" + auto); 49 System.out.println("copy:" + copy); 50 51 db.deleteObject(copy); 52 53 db.close(); 54 System.out.println("disconnected..."); 55 } 56 57 } 58 | Popular Tags |