package animals;
import org.objectweb.speedo.runtime.SpeedoPersistenceManagerFactory;
import org.objectweb.speedo.api.ExceptionHelper;
import java.io.FileInputStream;
import java.util.Properties;
public class Story {
javax.jdo.PersistenceManagerFactory pmf;
public static void main(String args[]) {
Story story = new Story();
story.initPersitency(args);
try {
story.run();
} catch (Exception e) {
ExceptionHelper.getNested(e).printStackTrace();
System.exit(-1);
}
}
public void initPersitency(String[] args) {
try {
Properties p = new Properties();
p.load(new FileInputStream(args[0]));
p.setProperty("log.config.file", args[1]);
pmf = new SpeedoPersistenceManagerFactory();
//((SpeedoPersistenceManagerFactory) pmf).init(p);
} catch (Exception e) {
ExceptionHelper.getNested(e).printStackTrace();
System.exit(-1);
}
}
public void run() throws Exception {
javax.jdo.PersistenceManager pm = pmf.getPersistenceManager();
javax.jdo.Transaction utx = pm.currentTransaction();
utx.begin();
//---- A Story ---//
Cat felix = new Cat("felix");
Dog rex = new Dog("rex", 0);
rex.owner = "James";
rex.attack(felix.name);
pm.makePersistent(felix);
//System.out.println("The enemey of the cat " + felix.name + " is " + felix.enemy);
//----------------//
utx.commit();
pm.close();
}
}