Mercurial > hg > blitz_stable
view src/org/dancres/blitz/txn/StoragePersonalityFactory.java @ 32:243c74d599bf
Update ignores
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 12 Jun 2010 10:41:47 +0100 |
parents | 3dc0c5604566 |
children |
line wrap: on
line source
package org.dancres.blitz.txn; import java.io.File; import net.jini.config.ConfigurationException; import org.dancres.blitz.config.StorageModel; import org.dancres.blitz.config.Persistent; import org.dancres.blitz.config.TimeBarrierPersistent; import org.dancres.blitz.config.Transient; import org.dancres.blitz.config.ConfigurationFactory; /** @see org.dancres.blitz.txn.StoragePersonality */ public class StoragePersonalityFactory { private static StorageModel STORAGE_MODEL; private static StoragePersonality STORAGE_PERSONALITY; static { try { STORAGE_MODEL = ((StorageModel) ConfigurationFactory.getEntry("storageModel", StorageModel.class)); String myLogDir = (String) ConfigurationFactory.getEntry("logDir", String.class); new File(myLogDir).mkdirs(); if (STORAGE_MODEL instanceof Persistent) { STORAGE_PERSONALITY = new PersistentPersonality((Persistent) STORAGE_MODEL, myLogDir); } else if (STORAGE_MODEL instanceof Transient) { STORAGE_PERSONALITY = new TransientPersonality(myLogDir); } else if (STORAGE_MODEL instanceof TimeBarrierPersistent) { STORAGE_PERSONALITY = new TimeBarrierPersonality((TimeBarrierPersistent) STORAGE_MODEL, myLogDir); } else { throw new Error("Unrecognised storage personality, fatal: " + STORAGE_MODEL); } } catch (ConfigurationException aCE) { throw new Error("Problem loading configuration", aCE); } } public static StoragePersonality getPersonality() { return STORAGE_PERSONALITY; } }