use of org.jaffa.persistence.engines.IPersistenceEngine in project jaffa-framework by jaffa-projects.
the class PersistenceEngineFactory method createPersistenceEngine.
/**
* Creates a new PersistenceEngine object.
* Reads the 'framework.persistence.Persistence_Engine' property from the framework.properties file.
* Instantiates the class returned by the property.
*
* @return an instance of IPersistenceEngine.
* @throws EngineInstantiationException when the property is not defined, the class cannot be found,
* or the class cannot be instantiated.
*/
private static IPersistenceEngine createPersistenceEngine() throws EngineInstantiationException {
String engineName = null;
try {
IPersistenceEngine engine;
if (persistenceEngineFactory != null) {
engine = persistenceEngineFactory.newPersistenceEngine();
} else {
engineName = (String) Config.getProperty(ENGINE_KEY);
if (log.isDebugEnabled())
log.debug("Creating an instance of the Persistence Engine: " + engineName);
Class engineClass = Class.forName(engineName);
engine = (IPersistenceEngine) engineClass.newInstance();
}
return engine;
} catch (Exception e) {
log.error(String.format(FAILED_ENGINE_INSTANTIATION, engineName), e);
throw new EngineInstantiationException(null, e);
}
}
Aggregations