KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > persist > PersistRequest


1 /*
2  * Copyright © 2004, Rob Gordon.
3  */

4 package org.oddjob.persist;
5
6 import java.io.File JavaDoc;
7
8 /**
9  *
10  * @author Rob Gordon.
11  */

12 public class PersistRequest {
13
14     private final Object JavaDoc toPersist;
15     private final String JavaDoc id;
16     private final File JavaDoc directory;
17     private boolean persisted = false;
18     private final Object JavaDoc waitOn = new Object JavaDoc();
19
20     public PersistRequest(Object JavaDoc toPersist, String JavaDoc id,
21             File JavaDoc directory) {
22         this.toPersist = toPersist;
23         this.id = id;
24         this.directory = directory;
25     }
26
27     public Object JavaDoc getToPersist() {
28         return toPersist;
29     }
30     
31     public String JavaDoc getId() {
32         return id;
33     }
34     
35     public File JavaDoc 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 JavaDoc e) {
53                     // ignore
54
}
55             }
56         }
57     }
58 }
59
Popular Tags