Mercurial > hg > Database > jungle-network
comparison src/alice/jungle/persistence/PersistentJournal.java @ 86:bcaf28f8244d
Added PersistentChageList and PersistentJournalTest
author | one |
---|---|
date | Tue, 29 Oct 2013 16:52:12 +0900 |
parents | e641f559559c |
children | 0c98717f186e |
comparison
equal
deleted
inserted
replaced
85:e641f559559c | 86:bcaf28f8244d |
---|---|
17 public class PersistentJournal implements Journal { | 17 public class PersistentJournal implements Journal { |
18 | 18 |
19 private static PersistentChangeListWriter WRITER; | 19 private static PersistentChangeListWriter WRITER; |
20 private static PersistentChangeListReader READER; | 20 private static PersistentChangeListReader READER; |
21 private static MessagePack msgpack; | 21 private static MessagePack msgpack; |
22 private static OutputStream out; | 22 private static OutputStream out = null; |
23 private static InputStream in; | 23 private static InputStream in = null; |
24 | |
25 public PersistentJournal() { | |
26 msgpack = new MessagePack(); | |
27 } | |
24 | 28 |
25 public PersistentJournal(File file) throws FileNotFoundException { | 29 public PersistentJournal(File file) throws FileNotFoundException { |
26 out = new FileOutputStream(file, true); | 30 out = new FileOutputStream(file, true); |
27 in = new FileInputStream(file); | 31 in = new FileInputStream(file); |
28 WRITER = new PersistentChangeListWriter(out); | 32 WRITER = new PersistentChangeListWriter(out); |
36 } | 40 } |
37 | 41 |
38 @Override | 42 @Override |
39 public ChangeListWriter getWriter() { | 43 public ChangeListWriter getWriter() { |
40 return WRITER; | 44 return WRITER; |
45 } | |
46 | |
47 public void setOutputFile(File file) throws FileNotFoundException { | |
48 out = new FileOutputStream(file); | |
49 WRITER = new PersistentChangeListWriter(out); | |
50 } | |
51 | |
52 public void setInputFile(File file) throws FileNotFoundException { | |
53 in = new FileInputStream(file); | |
54 READER = new PersistentChangeListReader(in); | |
41 } | 55 } |
42 | 56 |
43 public void close() throws IOException { | 57 public void close() throws IOException { |
44 out.close(); | 58 out.close(); |
45 in.close(); | 59 in.close(); |