*/
public void startService() {
// use custom DataSourceFactory to prepare the DB...
final HSQLDataSourceFactory dataSourceFactory = new HSQLDataSourceFactory();
DefaultConfiguration configuration = new DefaultConfiguration() {
@Override
public DataSourceFactory getDataSourceFactory(String userFactoryName) {
return dataSourceFactory;
}
};
if (cayenneConfigPackage != null) {
configuration.addClassPath(cayenneConfigPackage);
}
try {
configuration.initialize();
}
catch (Exception ex) {
throw new CayenneRuntimeException("Error connecting to preference DB.", ex);
}
configuration.didInitialize();
this.configuration = configuration;
this.dataContext = configuration.getDomain().createDataContext();
// create DB if it does not exist...
if (dataSourceFactory.needSchemaUpdate && !upgradeDB()) {
initSchema();
}