View Javadoc
1   package ordertracker;
2   
3   import javax.persistence.EntityManagerFactory;
4   import javax.persistence.Persistence;
5   
6   import org.apache.log4j.Logger;
7   
8   public class App {
9   
10      private static Logger log = Logger.getLogger(App.class);
11  
12      public static void startup() {
13  
14          log.info("starting up");
15  
16          // create the entity manager factory
17          EntityManagerFactory emf = Persistence.createEntityManagerFactory("testPersistenceUnit");
18  
19          // pass the EntityManagerFactory and pool size to the generated xuml
20          // Context
21          Context.setEntityManagerFactory(emf, "hibernate.hikari.maximumPoolSize");
22  
23          // set the behaviour factories
24          Order.setBehaviourFactory(OrderBehaviour.class);
25          Depot.setBehaviourFactory(DepotBehaviour.class);
26          SystemEvent.setBehaviourFactory(SystemEventBehaviour.class);
27  
28          // send any signals not processed from last shutdown
29          Context.sendSignalsInQueue();
30  
31          // create the singleton event entity
32          SystemEvent.create(new SystemEvent.Events.Create("1"));
33          // create the example depot
34          Depot.create(new Depot.Events.Create("1", "Gundagai", -35.0, 142.0));
35  
36          log.info("started up");
37      }
38  
39      public static void shutdown() {
40          // shutdown the actor system
41          Context.stop();
42  
43          // close the entity manager factory if desired
44          Context.close();
45  
46      }
47  
48  }