| 1 6 package com.nightlabs.ipanema.person; 7 8 import java.util.Iterator ; 9 10 import javax.jdo.PersistenceManager; 11 12 import org.apache.log4j.Logger; 13 14 23 public class PersonRegistry { 24 25 public static final Logger LOGGER = Logger.getLogger(PersonRegistry.class); 26 27 30 private long nextPersonID; 31 32 public synchronized long createPersonID() { 33 long tmpLong = nextPersonID; 34 nextPersonID = tmpLong+1; 35 return tmpLong; 36 } 37 38 public static PersonRegistry getRegistry(PersistenceManager pm) { 39 Iterator it = pm.getExtent(PersonRegistry.class).iterator(); 40 if (it.hasNext()) { 41 return (PersonRegistry)it.next(); 42 } 43 else { 44 PersonRegistry registry = new PersonRegistry(); 45 pm.makePersistent(registry); 46 return registry; 47 } 48 } 49 } 50 | Popular Tags |