1 package animals; 2 3 import org.objectweb.speedo.runtime.SpeedoPersistenceManagerFactory; 4 import org.objectweb.speedo.api.ExceptionHelper; 5 6 import java.io.FileInputStream ; 7 import java.util.Properties ; 8 9 public class Story { 10 11 javax.jdo.PersistenceManagerFactory pmf; 12 13 public static void main(String args[]) { 14 Story story = new Story(); 15 story.initPersitency(args); 16 try { 17 story.run(); 18 } catch (Exception e) { 19 ExceptionHelper.getNested(e).printStackTrace(); 20 System.exit(-1); 21 } 22 } 23 24 public void initPersitency(String [] args) { 25 try { 26 Properties p = new Properties (); 27 p.load(new FileInputStream (args[0])); 28 p.setProperty("log.config.file", args[1]); 29 pmf = new SpeedoPersistenceManagerFactory(); 30 } catch (Exception e) { 32 ExceptionHelper.getNested(e).printStackTrace(); 33 System.exit(-1); 34 } 35 } 36 37 public void run() throws Exception { 38 javax.jdo.PersistenceManager pm = pmf.getPersistenceManager(); 39 javax.jdo.Transaction utx = pm.currentTransaction(); 40 utx.begin(); 41 42 44 Cat felix = new Cat("felix"); 45 Dog rex = new Dog("rex", 0); 46 rex.owner = "James"; 47 rex.attack(felix.name); 48 pm.makePersistent(felix); 49 52 utx.commit(); 53 pm.close(); 54 } 55 56 57 } 58 | Popular Tags |