}
String preferencesDB = new File(dbDir, "db").getAbsolutePath();
// create custom preferences service...
HSQLEmbeddedPreferenceService service = new HSQLEmbeddedPreferenceService(
preferencesDB,
Application.PREFERENCES_MAP_PACKAGE,
name) {
protected void startTimer() {
// noop: disable commit timer
}
protected void initPreferences() {
// noop: disable commit timer
}
protected void initSchema() {
// throw - no schema means no DataSource data
throw new CayenneRuntimeException("No preferences matching location: "
+ location);
}
};
try {
service.startService();
return toDataSource(service.getDataContext(), location);
}
finally {
// make sure we cleanup after ourselves...
try {
service.stopService();
}
catch (Throwable th) {
// ignore..
}
}