Package animals

Source Code of animals.Story

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();
  }


}
TOP

Related Classes of animals.Story

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.