db4o provides a wide range of configuration methods to request special behaviour.
For a complete list of all available methods see Configuration, ClientServerConfiguration, ObjectClass and ObjectField interfaces, and API documentation for the com.db4o.config package/namespace.
The following paragraphs contain some useful hints around using configuration calls.
Configuration can be obtained using the following methods:
.NET:
IConfiguration configuration = Db4oFactory.NewConfiguration();
To apply the configuration to an ObjectContainer/Client/Server use one of the following methods:
.NET:
Db4oFactory.OpenFile(configuration, databaseFileName)
Db4oFactory.OpenServer(configuration, databaseFileName, port)
Db4oFactory.OpenClient(configuration, hostName, port, user, password)
Configuration settings are not stored in db4o database files. Accordingly you will need to pass the same configuration object every time you open an ObjectContainer/Client/Server.
For using db4o in client/server mode it is recommended to use the same configuration on the server and on the client. To set this up nicely it makes sense to create one application class with one method that returns the required configuration and to deploy this class both to the server and to all clients.
Client/Server specific configuration calls reside in ClientServerConfiguration interface (.NET conventional name IClientServerConfiguration). These settings are accessed with:
.NET:
IClientServerConfiguration configuration = Db4oFactory.NewConfiguration().ClientServer();
For db4o versions before 6.0 the above-mentioned method of working with the configuration was not available. Instead, you could use:
These methods are still available, however their usage is not advised due to their limitations.
Global configuration can be set using:
.NET:
Db4oFactory.Configure()
Starting from version 6.0 you can obtain a clone of the global configuration:
.NET:
IConfiguration configuration = Db4oFactory.CloneConfiguration()
When an ObjectContainer/ObjectServer is opened, the global configuration context is cloned and copied into the newly opened ObjectContainer/ObjectServer. Subsequent calls against the global context with Db4o.configure() have no effect on open ObjectContainers/ObjectServers.
Global configuration has a number of disadvantages:
Object Container instance configuration can be used for an open ObjectContainer/Client/Server:
.NET:
objectContainer.Ext().Configure()
objectServer.Ext().Configure()
Closing the container will erase all the settings.
The obvious disadvantages are:
some configuration methods effect the way the system works on opening an object container therefore have no influence on the open object container;
some configuration methods only effect the creation of a database;
Some configuration switches are discussed in more detail in the following chapters: