public interface Configuration
Db4o.configure().
When an ObjectContainer or ObjectServer is opened, the global Configuration
context is cloned and copied into the ObjectContainer/ObjectServer.
That means every ObjectContainer/ObjectServer gets it's own copy of
configuration settings.ExtObjectContainer.configure()
and ExtObjectServer.configure().| Modifier and Type | Method and Description |
|---|---|
int |
activationDepth()
gets the configured activation depth.
|
void |
activationDepth(int depth)
sets the activation depth to the specified value.
|
void |
add(ConfigurationItem configurationItem)
adds ConfigurationItems to be applied when
an ObjectContainer or ObjectServer is opened.
|
void |
addAlias(Alias alias)
adds a new Alias for a class, namespace or package.
|
void |
allowVersionUpdates(boolean flag)
turns automatic database file format version updates on.
|
void |
automaticShutDown(boolean flag)
turns automatic shutdown of the engine on and off.
|
void |
blockSize(int bytes)
sets the storage data blocksize for new ObjectContainers.
|
void |
bTreeCacheHeight(int height)
configures caching of BTree nodes.
|
void |
bTreeNodeSize(int size)
configures the size of BTree nodes in indexes.
|
CacheConfiguration |
cache()
returns the Cache configuration interface.
|
void |
callbacks(boolean flag)
turns callback methods on and off.
|
void |
callConstructors(boolean flag)
advises db4o to try instantiating objects with/without calling
constructors.
|
void |
classActivationDepthConfigurable(boolean flag)
turns
individual class activation depth configuration on
and off. |
ClientServerConfiguration |
clientServer()
returns client/server configuration interface.
|
void |
databaseGrowthSize(int bytes)
configures the size database files should grow in bytes, when no
free slot is found within.
|
void |
detectSchemaChanges(boolean flag)
tuning feature: configures whether db4o checks all persistent classes upon system
startup, for added or removed fields.
|
DiagnosticConfiguration |
diagnostic()
returns the configuration interface for diagnostics.
|
void |
disableCommitRecovery()
turns commit recovery off.
|
void |
encrypt(boolean flag)
Deprecated.
use a custom encrypting
IoAdapter instead |
void |
exceptionsOnNotStorable(boolean flag)
configures whether Exceptions are to be thrown, if objects can not be stored.
|
FreespaceConfiguration |
freespace()
returns the freespace configuration interface.
|
void |
generateCommitTimestamps(boolean flag)
Configures db4o to generate commit timestamps for all stored objects.
All the objects commited within a transaction will share the same commit timestamp. |
void |
generateUUIDs(ConfigScope setting)
configures db4o to generate UUIDs for stored objects.
|
void |
generateVersionNumbers(ConfigScope setting)
Deprecated.
As of version 8.0 please use
generateCommitTimestamps(boolean) instead. |
boolean |
internStrings()
returns true if strings will be interned.
|
void |
internStrings(boolean flag)
configures db4o to call #intern() on strings upon retrieval.
|
IoAdapter |
io()
Deprecated.
Use
storage() instead. |
void |
io(IoAdapter adapter)
Deprecated.
Use
storage(Storage) instead. |
void |
lockDatabaseFile(boolean flag)
can be used to turn the database file locking thread off.
|
void |
markTransient(java.lang.String attributeName)
allows to mark fields as transient with custom attributes.
|
int |
maxStackDepth() |
void |
maxStackDepth(int maxStackDepth) |
void |
messageLevel(int level)
sets the detail level of db4o messages.
|
ObjectClass |
objectClass(java.lang.Object clazz)
returns an
ObjectClass object
to configure the specified class. |
boolean |
optimizeNativeQueries()
indicates whether Native Queries will be optimized dynamically.
|
void |
optimizeNativeQueries(boolean optimizeNQ)
If set to true, db4o will try to optimize native queries
dynamically at query execution time, otherwise it will
run native queries in unoptimized mode as SODA evaluations.
|
void |
password(java.lang.String pass)
Deprecated.
use a custom encrypting
IoAdapter instead |
QueryConfiguration |
queries()
returns the Query configuration interface.
|
void |
readOnly(boolean flag)
turns readOnly mode on and off.
|
void |
recoveryMode(boolean flag)
turns recovery mode on and off.
Recovery mode can be used to try to retrieve as much as possible out of an already corrupted database. |
void |
reflectWith(Reflector reflector)
configures the use of a specially designed reflection implementation.
|
void |
registerTypeHandler(TypeHandlerPredicate predicate,
TypeHandler4 typeHandler)
allows registering special TypeHandlers for customized marshalling
and customized comparisons.
|
void |
removeAlias(Alias alias)
Removes an alias previously added with
addAlias(Alias). |
void |
reserveStorageSpace(long byteCount)
tuning feature only: reserves a number of bytes in database files.
|
void |
setBlobPath(java.lang.String path)
configures the path to be used to store and read
Blob data.
|
void |
setOut(java.io.PrintStream outStream)
Assigns a
PrintStream where db4o is to print its event messages. |
Storage |
storage()
returns the configured
Storage |
void |
storage(Storage factory)
allows to configure db4o to use a customized byte IO storage mechanism.
|
void |
stringEncoding(StringEncoding encoding)
configures the string encoding to be used.
|
void |
testConstructors(boolean flag)
tuning feature: configures whether db4o should try to instantiate one instance
of each persistent class on system startup.
|
void |
updateDepth(int depth)
specifies the global updateDepth.
|
void |
weakReferenceCollectionInterval(int milliseconds)
configures the timer for WeakReference collection.
|
void |
weakReferences(boolean flag)
turns weak reference management on or off.
|
void activationDepth(int depth)
ObjectSet of a query result, the result objects
will be activated to the configured activation depth.// Object foo is the result of a query, it is delivered by the ObjectSet Object foo = objectSet.next();foo.member1.member2.member3.member4.member5 will be a valid object
ObjectContainer.activate(Object, int).
ObjectContainer.deactivate(Object, int)
can be used to manually free memory by deactivating objects.depth - the desired global activation depth.configuring classes individuallyint activationDepth()
void add(ConfigurationItem configurationItem)
configurationItem - the ConfigurationItemvoid addAlias(Alias alias)
TypeAlias provides an #equals() resolver to match
names directly.WildcardAlias allows simple pattern matching
with one single '*' wildcard character.Alias constructs by creating own resolvers
that implement the Alias interface.
EmbeddedConfiguration config = Db4oEmbedded.newConfiguration();
// Creating an Alias for a single class
config.common().addAlias(
new TypeAlias("com.f1.Pilot", "com.f1.Driver"));
// Mapping a Java package onto another
config.common().addAlias(
new WildcardAlias(
"com.f1.*",
"com.f1.client*"));
void removeAlias(Alias alias)
addAlias(Alias).alias - the alias to removevoid allowVersionUpdates(boolean flag)
void automaticShutDown(boolean flag)
true.flag - whether db4o should shut down automatically.void blockSize(int bytes)
throws GlobalOnlyConfigException
bytes - the size in bytes from 1 to 127GlobalOnlyConfigExceptionvoid bTreeNodeSize(int size)
size - the number of elements held in one BTree node.void bTreeCacheHeight(int height)
height - the height of the cache from the rootCacheConfiguration cache()
void callbacks(boolean flag)
flag - false to turn callback methods offUsing callbacksvoid callConstructors(boolean flag)
ObjectClass.callConstructor(boolean).
flag - - specify true, to request calling constructors, specify
false to request not calling constructors.ObjectClass.callConstructor(boolean)void classActivationDepthConfigurable(boolean flag)
individual class activation depth configuration on
and off.
flag - false to turn the possibility to individually configure class
activation depths offWhy activation?ClientServerConfiguration clientServer()
void databaseGrowthSize(int bytes)
bytes - amount of bytesvoid detectSchemaChanges(boolean flag)
trueflag - the desired settingDiagnosticConfiguration diagnostic()
void disableCommitRecovery()
void encrypt(boolean flag)
throws GlobalOnlyConfigException
IoAdapter insteadDb4o.openFile(java.lang.String).
flag - true for turning encryption on, false for turning encryption
off.GlobalOnlyConfigExceptionpassword(java.lang.String)void exceptionsOnNotStorable(boolean flag)
ObjectNotStorableException
if an object can not be stored.
flag - false to not throw Exceptions if objects can not be stored (fail silently).FreespaceConfiguration freespace()
void generateUUIDs(ConfigScope setting)
setting - the scope for UUID generation: disabled, generate for all classes, or configure individually@Deprecated void generateVersionNumbers(ConfigScope setting)
generateCommitTimestamps(boolean) instead.setting - the scope for version number generation: disabled, generate for all classes, or configure individuallyvoid generateCommitTimestamps(boolean flag)
ObjectContainer container = ...; ObjectInfo objectInfo = container.ext().getObjectInfo(obj); long commitTimestamp = objectInfo.getVersion();
flag - if true, commit timetamps will be generated for all stored
objects. If you already have commit timestamps for stored
objects and later set this flag to false, although you wont be
able to access them, the commit timestamps will still be taking
space in your file container. The only way to free that space
is defragmenting the container.void internStrings(boolean flag)
flag - true to intern stringsboolean internStrings()
void io(IoAdapter adapter) throws GlobalOnlyConfigException
storage(Storage) instead.IoAdapter to
write your own. Possible usecases could be improved performance
with a native library, mirrored write to two files, encryption or
read-on-write fail-safety control.adapter - - the IoAdapterGlobalOnlyConfigExceptionvoid storage(Storage factory) throws GlobalOnlyConfigException
Storage to
write your own. Possible usecases could be improved performance
with a native library, mirrored write to two files, encryption or
read-on-write fail-safety control.factory - - the factoryGlobalOnlyConfigExceptionCachingStorage,
MemoryStorage,
FileStorage,
StorageDecoratorvoid markTransient(java.lang.String attributeName)
attributeName - - the fully qualified name of the attribute, including
it's namespacevoid messageLevel(int level)
PrintStream.
level - integer from 0 to 3setOut(java.io.PrintStream)void lockDatabaseFile(boolean flag)
true.flag - false to turn database file locking off.ObjectClass objectClass(java.lang.Object clazz)
ObjectClass object
to configure the specified class.
clazz - class name, Class object, or example object.ObjectClass
object for configuration.void optimizeNativeQueries(boolean optimizeNQ)
true.optimizeNQ - true, if db4o should try to optimize
native queries at query execution time, false otherwiseboolean optimizeNativeQueries()
optimizeNativeQueries(boolean)void password(java.lang.String pass)
throws GlobalOnlyConfigException
IoAdapter insteadDb4o.openFile(java.lang.String).
pass - the password to be used.GlobalOnlyConfigExceptionQueryConfiguration queries()
void readOnly(boolean flag)
Db4o.openFile() will open files.
flag - true for configuring readOnly mode for subsequent
calls to Db4o.openFile().void recoveryMode(boolean flag)
flag - true to turn recover mode on.void reflectWith(Reflector reflector)
void reserveStorageSpace(long byteCount)
throws DatabaseReadOnlyException,
NotSupportedException
ExtObjectContainer.configure()) will
continually allocate space.
byteCount - the number of bytes to reserveDatabaseReadOnlyExceptionNotSupportedExceptionvoid setBlobPath(java.lang.String path)
throws java.io.IOException
path - the path to be usedjava.io.IOExceptionvoid setOut(java.io.PrintStream outStream)
PrintStream where db4o is to print its event messages.
messageLevel(int)
to produce more detailed messages.
setOut(System.out) to print messages to the
console.messageLevel(int) is used.outStream - the new PrintStream for messages.messageLevel(int)void stringEncoding(StringEncoding encoding)
Db4o.openFile(java.lang.String) or Db4o.openServer(java.lang.String, int).
config.stringEncoding(StringEncodings.utf8()));StringEncodingsvoid testConstructors(boolean flag)
false,
if all persistent classes have public default constructors.
trueflag - the desired settingvoid updateDepth(int depth)
com.db4o.ObjectContainer#set
for further details.com.db4o.ObjectContainer#set
will be updated.depth - the depth of the desired update.ObjectClass.updateDepth(int),
ObjectClass.cascadeOnUpdate(boolean),
Using callbacksvoid weakReferences(boolean flag)
ExtObjectContainer.purge(java.lang.Object)
false causes db4o to use hard
references to objects, preventing the garbage collection process
from disposing of unused objects.
true.void weakReferenceCollectionInterval(int milliseconds)
milliseconds - the time in millisecondsvoid registerTypeHandler(TypeHandlerPredicate predicate, TypeHandler4 typeHandler)
predicate - to specify for which classes and versions the
TypeHandler is to be used.typeHandler - to be used for the classes that match the predicate.int maxStackDepth()
CommonConfiguration.maxStackDepth()void maxStackDepth(int maxStackDepth)