1 4 package org.oddjob.persist; 5 6 import java.io.File ; 7 8 12 public class PersistRequest { 13 14 private final Object toPersist; 15 private final String id; 16 private final File directory; 17 private boolean persisted = false; 18 private final Object waitOn = new Object (); 19 20 public PersistRequest(Object toPersist, String id, 21 File directory) { 22 this.toPersist = toPersist; 23 this.id = id; 24 this.directory = directory; 25 } 26 27 public Object getToPersist() { 28 return toPersist; 29 } 30 31 public String getId() { 32 return id; 33 } 34 35 public File getDirectory() { 36 return directory; 37 } 38 39 public void persisted() { 40 synchronized (waitOn) { 41 persisted = true; 42 waitOn.notifyAll(); 43 } 44 } 45 46 public void waitPerist() { 47 synchronized (waitOn) { 48 while (!persisted) { 49 try { 50 waitOn.wait(); 51 } 52 catch (InterruptedException e) { 53 } 55 } 56 } 57 } 58 } 59 | Popular Tags |