db4o is configured by its configuration API. The configuration allows you to adjust db4o to your scenarios.
In order to configure db4o, you need to create a new configuration-instance and set the desired settings on it. After that, you pass the configuration-instance to the object-container factory.
Note that you cannot share a configuration-instance. For each object-container you create, you need to pass in a new configuration-instance. It's recommended to create a method which will return a new configuration instance on request:
For an embedded container you can configure the common-, file- and id-system-configuration.
IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration(); // change the configuration... IObjectContainer container = Db4oEmbedded.OpenFile(configuration, "database.db4o");
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration() ' change the configuration... Dim container As IObjectContainer = Db4oEmbedded.OpenFile(configuration, "database.db4o")
For an server you can configure the common-, file-, networking-, server- and id-system-configuration.
IServerConfiguration configuration = Db4oClientServer.NewServerConfiguration(); // change the configuration... IObjectServer server = Db4oClientServer.OpenServer(configuration, "database.db4o", 1337);
Dim configuration As IServerConfiguration = Db4oClientServer.NewServerConfiguration() ' change the configuration... Dim server As IObjectServer = Db4oClientServer.OpenServer(configuration, "database.db4o", 1337)
For an client you can configure the common-, networking-, client- and id-system-configuration.
IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration(); // change the configuration... IObjectContainer container = Db4oClientServer.OpenClient(configuration, "localhost", 1337, "user", "pwd");
Dim configuration As IClientConfiguration = Db4oClientServer.NewClientConfiguration() ' change the configuration... Dim container As IObjectContainer = Db4oClientServer.OpenClient(configuration, "localhost", 1337, "user", "pwd")
The db4o configuration is not persistent with a few exception. This means that you need to configure db4o each time you create a object-container instance.
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.
The configuration-settings which are common across -client, embedded and db4o-server are summed up here: See "Common Configuration"