comparison src/org/dancres/blitz/txn/StoragePersonalityFactory.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3dc0c5604566
1 package org.dancres.blitz.txn;
2
3 import java.io.File;
4
5 import net.jini.config.ConfigurationException;
6
7 import org.dancres.blitz.config.StorageModel;
8 import org.dancres.blitz.config.Persistent;
9 import org.dancres.blitz.config.TimeBarrierPersistent;
10 import org.dancres.blitz.config.Transient;
11 import org.dancres.blitz.config.ConfigurationFactory;
12
13 /**
14 @see org.dancres.blitz.txn.StoragePersonality
15 */
16 public class StoragePersonalityFactory {
17
18 private static StorageModel STORAGE_MODEL;
19
20 private static StoragePersonality STORAGE_PERSONALITY;
21
22 static {
23 try {
24 STORAGE_MODEL =
25 ((StorageModel)
26 ConfigurationFactory.getEntry("storageModel",
27 StorageModel.class));
28
29 String myLogDir = (String)
30 ConfigurationFactory.getEntry("logDir", String.class);
31
32 new File(myLogDir).mkdirs();
33
34 if (STORAGE_MODEL instanceof Persistent) {
35 STORAGE_PERSONALITY =
36 new PersistentPersonality((Persistent) STORAGE_MODEL,
37 myLogDir);
38 } else if (STORAGE_MODEL instanceof Transient) {
39 STORAGE_PERSONALITY = new TransientPersonality(myLogDir);
40 } else if (STORAGE_MODEL instanceof TimeBarrierPersistent) {
41 STORAGE_PERSONALITY =
42 new TimeBarrierPersonality((TimeBarrierPersistent) STORAGE_MODEL, myLogDir);
43 } else {
44 throw new Error("Unrecognised storage personality, fatal: " + STORAGE_MODEL);
45 }
46
47 } catch (ConfigurationException aCE) {
48 throw new Error("Problem loading configuration", aCE);
49 }
50 }
51
52 public static StoragePersonality getPersonality() {
53 return STORAGE_PERSONALITY;
54 }
55 }