1 package net.sf.cantina;
2
3 import net.sf.cantina.exceptions.ObjectNotFoundException;
4 import net.sf.cantina.exceptions.DuplicateKeyException;
5
6 import java.util.Collection;
7
8
9 /***
10 * An object that knows how to save/delete/load
11 * stuff
12 */
13 public abstract class DataSource
14 {
15 public static DataSource instance;
16
17 public static DataSource getInstance()
18 {
19 return instance;
20 }
21
22 public abstract void createDocument(String documentId)
23 throws DuplicateKeyException, Exception;
24
25 public abstract Document loadDocument(String documentId)
26 throws ObjectNotFoundException, Exception;
27
28 public abstract void saveDocument(Document d)
29 throws Exception;
30
31 public abstract void removeDocument(String documentId)
32 throws Exception;
33
34 public abstract Realm loadRealm(String name)
35 throws ObjectNotFoundException, Exception;
36
37 public abstract void saveRealm(Realm r) throws Exception;
38
39 public abstract void createRealm(String name) throws DuplicateKeyException,Exception;
40
41 public abstract void removeRealm(String name) throws Exception;
42
43 public abstract Collection findAllRealms() throws Exception;
44
45 public abstract Collection selectAllDocumentIds() throws Exception;
46
47 /***
48 * Close the database session.
49 */
50
51 public abstract void closeSession();
52
53 /***
54 * Releases all database resources.
55 */
56
57 public abstract void release();
58
59 }
60