Source code: org/jellyfish/example/Example.java
1 package org.jellyfish.example;
2
3 import javax.jdo.PersistenceManager;
4
5 import org.jellyfish.DirectoryManager;
6 import org.jellyfish.JellyFishPersistenceManagerFactory;
7 import org.jellyfish.model.Person;
8
9 public class Example {
10
11 public static final String STORE = "store";
12 public static final String DELETE = "delete";
13 public static final String LOOKUP = "lookup";
14 public static PersistenceManager persistenceManager;
15
16 public static void main(String[] args) {
17 persistenceManager =
18 JellyFishPersistenceManagerFactory
19 .getInstance()
20 .getPersistenceManager();
21 Person person = new Person("Joe", "Smith");
22 if (STORE.equals(args[0])) {
23 store(person);
24 } else if (DELETE.equals(args[0])) {
25 delete(person);
26 } else if (LOOKUP.equals(args[0])) {
27 lookup();
28 }
29
30 System.exit(0);
31 }
32 private static void lookup() {
33 persistenceManager.makePersistent(new Person("Joe", "Smith"));
34 System.out.println(
35 "Found "
36 + ((DirectoryManager) persistenceManager).lookup(
37 new Person("Joe")));
38 }
39
40 private static void delete(Object object) {
41 persistenceManager.makePersistent(object);
42 persistenceManager.deletePersistent(object);
43 System.out.println("Deleted " + object);
44 }
45
46 private static void store(Object object) {
47 persistenceManager.makePersistent(object);
48 System.out.println("Stored " + object);
49
50 }
51 }