* for the defrag process and <code>false</code> otherwise to return a normal
* configuration suitable for the application.
* @return Configuration
*/
public static final Configuration createConfiguration(boolean forDefrag) {
Configuration config = Db4o.newConfiguration();
//TODO We can use dbExists to configure our parameters for a more
//efficient startup. For example, the following could be used. We'd have
//to include a file when we need to evolve the schema or something similar
//config.detectSchemaChanges(false)
if (getLargeBlockSizeMarkerFile().exists())
config.blockSize(LARGE_DB_BLOCK_SIZE); //The DB has been migrated to a larger block size
config.setOut(new PrintStream(new ByteArrayOutputStream()) {
@Override
public void write(byte[] buf, int off, int len) {
if (buf != null && len >= 0 && off >= 0 && off <= buf.length - len)
CoreUtils.appendLogMessage(new String(buf, off, len));
}
});
config.lockDatabaseFile(true);
config.queries().evaluationMode(forDefrag ? QueryEvaluationMode.LAZY : QueryEvaluationMode.IMMEDIATE);
config.automaticShutDown(false);
config.callbacks(false);
config.activationDepth(2);
config.flushFileBuffers(false);
config.callConstructors(true);
config.exceptionsOnNotStorable(true);
configureAbstractEntity(config);
config.objectClass(BookMark.class).objectField("fFeedLink").indexed(true); //$NON-NLS-1$
config.objectClass(ConditionalGet.class).objectField("fLink").indexed(true); //$NON-NLS-1$
configureFeed(config);
configureNews(config);
configureFolder(config);
config.objectClass(Description.class).objectField("fNewsId").indexed(true); //$NON-NLS-1$
config.objectClass(NewsCounter.class).cascadeOnDelete(true);
config.objectClass(Preference.class).cascadeOnDelete(true);
config.objectClass(Preference.class).objectField("fKey").indexed(true); //$NON-NLS-1$
config.objectClass(SearchFilter.class).objectField("fActions").cascadeOnDelete(true); //$NON-NLS-1$
if (isIBM_VM_1_6()) //See defect 733
config.objectClass("java.util.MiniEnumSet").translate(new com.db4o.config.TSerializable()); //$NON-NLS-1$
return config;
}