Java Doc for Configuration.java in  » Database-DBMS » db4o-6.4 » com » db4o » config » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db4o 6.4 » com.db4o.config 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.db4o.config.Configuration

All known Subclasses:   com.db4o.internal.Config4Impl,
Configuration
public interface Configuration (Code)
configuration interface.

This interface contains methods to configure db4o.

The global Configuration context is available with com.db4o.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.

Most configuration settings should be set before opening an ObjectContainer/ObjectServer.

Some configuration settings can be modified on an open ObjectContainer/ObjectServer. The local Configuration context is available with com.db4o.ext.ExtObjectContainer.configure and com.db4o.ext.ExtObjectServer.configure .




Method Summary
public  voidactivationDepth(int depth)
     sets the activation depth to the specified value.

Why activation?
When objects are instantiated from the database, the instantiation of member objects needs to be limited to a certain depth.
public  intactivationDepth()
     gets the configured activation depth.
public  voidadd(ConfigurationItem configurationItem)
     adds ConfigurationItems to be applied when an ObjectContainer or ObjectServer is opened.
public  voidaddAlias(Alias alias)
     adds a new Alias for a class, namespace or package.
public  voidallowVersionUpdates(boolean flag)
     turns automatic database file format version updates on.

Upon db4o database file format version changes, db4o can automatically update database files to the current version.
public  voidautomaticShutDown(boolean flag)
     turns automatic shutdown of the engine on and off.

Depending on the JDK, db4o uses one of the following two methods to shut down, if no more references to the ObjectContainer are being held or the JVM terminates:
- JDK 1.3 and above: Runtime.addShutdownHook()
- JDK 1.2 and below: System.runFinalizersOnExit(true) and code in the finalizer.

Some JVMs have severe problems with both methods.
public  voidbTreeCacheHeight(int height)
     configures caching of BTree nodes.

Clean BTree nodes will be unloaded on #commit and #rollback unless they are configured as cached here.

Default setting: 0
Possible settings: 1, 2 or 3

The potential number of cached BTree nodes can be calculated with the following forumula:
maxCachedNodes = bTreeNodeSize ^ bTreeCacheHeight

This setting should be used on both client and server in client-server environment.
public  voidbTreeNodeSize(int size)
     configures the size of BTree nodes in indexes.

Default setting: 100
Lower values will allow a lower memory footprint and more efficient reading and writing of small slots.
Higher values will reduce the overall number of read and write operations and allow better performance at the cost of more RAM use.

This setting should be used on both client and server in client-server environment.
public  voidblockSize(int bytes)
     sets the storage data blocksize for new ObjectContainers.
public  voidcallConstructors(boolean flag)
     advises db4o to try instantiating objects with/without calling constructors.

Not all JDKs / .NET-environments support this feature.
public  voidcallbacks(boolean flag)
     turns callback methods on and off.

Callbacks are turned on by default.

A tuning hint: If callbacks are not used, you can turn this feature off, to prevent db4o from looking for callback methods in persistent classes.
public  voidclassActivationDepthConfigurable(boolean flag)
     turns ObjectClass.maximumActivationDepth individual class activation depth configuration on and off.
public  ClientServerConfigurationclientServer()
     returns client/server configuration interface.
public  voiddetectSchemaChanges(boolean flag)
     tuning feature: configures whether db4o checks all persistent classes upon system startup, for added or removed fields.
public  DiagnosticConfigurationdiagnostic()
     returns the configuration interface for diagnostics.
public  voiddisableCommitRecovery()
     turns commit recovery off.

db4o uses a two-phase commit algorithm.
public  voiddiscardFreeSpace(int byteCount)
     tuning feature: configures the minimum size of free space slots in the database file that are to be reused.

When objects are updated or deleted, the space previously occupied in the database file is marked as "free", so it can be reused.
public  voidencrypt(boolean flag)
     configures the use of encryption.
public  voidexceptionsOnNotStorable(boolean flag)
     configures whether Exceptions are to be thrown, if objects can not be stored.

db4o requires the presence of a constructor that can be used to instantiate objects.
public  voidflushFileBuffers(boolean flag)
     configures file buffers to be flushed during transaction commits.

db4o uses a resume-commit-on-crash strategy to ensure ACID transactions. When a transaction commits,
- (1) a list "pointers that are to be modified" is written to the database file,
- (2) the database file is switched into "in-commit" mode,
- (3) the pointers are actually modified in the database file,
- (4) the database file is switched to "not-in-commit" mode.
If the system is halted by a hardware or power failure
- before (2)
all objects will be available as before the commit
- between (2) and (4) the commit is restarted when the database file is opened the next time, all pointers will be read from the "pointers to be modified" list and all of them will be modified to the state they are intended to have after commit
- after (4) no work is necessary, the transaction is committed.

In order for the above to be 100% failsafe, the order of writes to the storage medium has to be obeyed.
public  FreespaceConfigurationfreespace()
     returns the freespace configuration interface.
public  voidgenerateUUIDs(int setting)
     configures db4o to generate UUIDs for stored objects.
public  voidgenerateUUIDs(ConfigScope setting)
     configures db4o to generate UUIDs for stored objects.
public  voidgenerateVersionNumbers(int setting)
     configures db4o to generate version numbers for stored objects.
public  voidgenerateVersionNumbers(ConfigScope setting)
     configures db4o to generate version numbers for stored objects.
public  voidinternStrings(boolean flag)
     configures db4o to call #intern() on strings upon retrieval.
public  booleaninternStrings()
     returns true if strings will be interned.
public  voidio(IoAdapter adapter)
     allows to configure db4o to use a customized byte IO adapter.

Derive from the abstract class IoAdapter to write your own.
public  voidlockDatabaseFile(boolean flag)
     can be used to turn the database file locking thread off.
public  voidmarkTransient(String attributeName)
     allows to mark fields as transient with custom attributes.

.NET only: Call this method with the attribute name that you wish to use to mark fields as transient.
public  voidmessageLevel(int level)
     sets the detail level of db4o messages.
public  ObjectClassobjectClass(Object clazz)
     returns an ObjectClass ObjectClass object to configure the specified class.
public  voidoptimizeNativeQueries(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. On the Java platform the jars needed for native query optimization (db4o-X.x-nqopt.jar, bloat-X.x.jar) have to be on the classpath at runtime for this switch to have effect.
public  booleanoptimizeNativeQueries()
     indicates whether Native Queries will be optimized dynamically.
public  voidpassword(String pass)
     protects the database file with a password.
public  QueryConfigurationqueries()
     returns the Query configuration interface.
public  voidreadOnly(boolean flag)
     turns readOnly mode on and off.

This method configures the mode in which subsequent calls to com.db4o.Db4o.openFile Db4o.openFile() will open files.

Readonly mode allows to open an unlimited number of reading processes on one database file.
public  voidreflectWith(Reflector reflector)
     configures the use of a specially designed reflection implementation.

db4o internally uses java.lang.reflect.* by default.
public  voidrefreshClasses()
     forces analysis of all Classes during a running session.

This method may be useful in combination with a modified ClassLoader and allows exchanging classes during a running db4o session.

Calling this method on the global Configuration context will refresh the classes in all db4o sessions in the running VM.
public  voidremoveAlias(Alias alias)
     Removes an alias previously added with Configuration.addAlias(Alias) .
public  voidreserveStorageSpace(long byteCount)
     tuning feature only: reserves a number of bytes in database files.

The global setting is used for the creation of new database files.
public  voidsetBlobPath(String path)
     configures the path to be used to store and read Blob data.

In client-server environment this setting should be used on the server side.
public  voidsetClassLoader(Object classLoader)
     configures db4o to use a custom ClassLoader.
public  voidsetOut(PrintStream outStream)
     Assigns a java.io.PrintStream PrintStream where db4o is to print its event messages.

Messages are useful for debugging purposes and for learning to understand, how db4o works.
public  voidtestConstructors(boolean flag)
     tuning feature: configures whether db4o should try to instantiate one instance of each persistent class on system startup.

In a production environment this setting can be set to false, if all persistent classes have public default constructors.

In client-server environment this setting should be used on both client and server side.
public  voidunicode(boolean flag)
     configures the storage format of Strings.
public  voidupdateDepth(int depth)
     specifies the global updateDepth.
public  voidweakReferenceCollectionInterval(int milliseconds)
     configures the timer for WeakReference collection.
public  voidweakReferences(boolean flag)
     turns weak reference management on or off.



Method Detail
activationDepth
public void activationDepth(int depth)(Code)
sets the activation depth to the specified value.

Why activation?
When objects are instantiated from the database, the instantiation of member objects needs to be limited to a certain depth. Otherwise a single object could lead to loading the complete database into memory, if all objects where reachable from a single root object.

db4o uses the concept "depth", the number of field-to-field hops an object is away from another object. The preconfigured "activation depth" db4o uses in the default setting is 5.

Whenever an application iterates through the com.db4o.ObjectSet ObjectSet of a query result, the result objects will be activated to the configured activation depth.

A concrete example with the preconfigured activation depth of 5:
 // 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
foo, member1, member2, member3 and member4 will be activated
member5 will be deactivated, all of it's members will be null
member5 can be activated at any time by calling com.db4o.ObjectContainer.activate ObjectContainer#activate(member5, depth) .

Note that raising the global activation depth will consume more memory and have negative effects on the performance of first-time retrievals. Lowering the global activation depth needs more individual activation work but can increase performance of queries.

com.db4o.ObjectContainer.deactivate ObjectContainer#deactivate(Object, depth) can be used to manually free memory by deactivating objects.

In client/server environment the same setting should be used on both client and server

.
Parameters:
  depth - the desired global activation depth.
See Also:   ObjectClass.maximumActivationDepth
See Also:    configuring classes individually



activationDepth
public int activationDepth()(Code)
gets the configured activation depth. the configured activation depth.



add
public void add(ConfigurationItem configurationItem)(Code)
adds ConfigurationItems to be applied when an ObjectContainer or ObjectServer is opened.
Parameters:
  configurationItem - the ConfigurationItem



addAlias
public void addAlias(Alias alias)(Code)
adds a new Alias for a class, namespace or package.

Aliases can be used to persist classes in the running application to different persistent classes in a database file or on a db4o server.

Two simple Alias implementations are supplied along with db4o:
- TypeAlias provides an #equals() resolver to match names directly.
- WildcardAlias allows simple pattern matching with one single '*' wildcard character.

It is possible to create own complex Alias constructs by creating own resolvers that implement the Alias interface.

Examples of concrete usecases:

// Creating an Alias for a single class
Db4o.configure().addAlias(
  new TypeAlias("com.f1.Pilot", "com.f1.Driver"));


// Accessing a .NET assembly from a Java package
Db4o.configure().addAlias(
  new WildcardAlias(
    "Tutorial.F1.*, Tutorial",
    "com.f1.*"));


// Mapping a Java package onto another
Db4o.configure().addAlias(
  new WildcardAlias(
    "com.f1.*",
    "com.f1.client*"));


Aliases that translate the persistent name of a class to a name that already exists as a persistent name in the database (or on the server) are not permitted and will throw an exception when the database file is opened.

Aliases should be configured before opening a database file or connecting to a server.

In client/server environment this setting should be used on the server side.



allowVersionUpdates
public void allowVersionUpdates(boolean flag)(Code)
turns automatic database file format version updates on.

Upon db4o database file format version changes, db4o can automatically update database files to the current version. db4objects does not provide functionality to reverse this process. It is not ensured that updated database files can be read with older db4o versions. In some cases (Example: using ObjectManager) it may not be desirable to update database files automatically therefore automatic updating is turned off by default for security reasons.

Call this method to turn automatic database file version updating on.

If automatic updating is turned off, db4o will refuse to open database files that use an older database file format.

In client-server environment this setting should be used on both client and server.



automaticShutDown
public void automaticShutDown(boolean flag)(Code)
turns automatic shutdown of the engine on and off.

Depending on the JDK, db4o uses one of the following two methods to shut down, if no more references to the ObjectContainer are being held or the JVM terminates:
- JDK 1.3 and above: Runtime.addShutdownHook()
- JDK 1.2 and below: System.runFinalizersOnExit(true) and code in the finalizer.

Some JVMs have severe problems with both methods. For these rare cases the autoShutDown feature may be turned off.

The default and recommended setting is true.

In client-server environment this setting should be used on both client and server.
Parameters:
  flag - whether db4o should shut down automatically.



bTreeCacheHeight
public void bTreeCacheHeight(int height)(Code)
configures caching of BTree nodes.

Clean BTree nodes will be unloaded on #commit and #rollback unless they are configured as cached here.

Default setting: 0
Possible settings: 1, 2 or 3

The potential number of cached BTree nodes can be calculated with the following forumula:
maxCachedNodes = bTreeNodeSize ^ bTreeCacheHeight

This setting should be used on both client and server in client-server environment.
Parameters:
  height - the height of the cache from the root



bTreeNodeSize
public void bTreeNodeSize(int size)(Code)
configures the size of BTree nodes in indexes.

Default setting: 100
Lower values will allow a lower memory footprint and more efficient reading and writing of small slots.
Higher values will reduce the overall number of read and write operations and allow better performance at the cost of more RAM use.

This setting should be used on both client and server in client-server environment.
Parameters:
  size - the number of elements held in one BTree node.



blockSize
public void blockSize(int bytes) throws GlobalOnlyConfigException(Code)
sets the storage data blocksize for new ObjectContainers.

The standard setting is 1 allowing for a maximum database file size of 2GB. This value can be increased to allow larger database files, although some space will be lost to padding because the size of some stored objects will not be an exact multiple of the block size. A recommended setting for large database files is 8, since internal pointers have this length.

This setting is only effective when the database is first created, in client-server environment in most cases it means that the setting should be used on the server side.
Parameters:
  bytes - the size in bytes from 1 to 127



callConstructors
public void callConstructors(boolean flag)(Code)
advises db4o to try instantiating objects with/without calling constructors.

Not all JDKs / .NET-environments support this feature. db4o will attempt, to follow the setting as good as the enviroment supports. In doing so, it may call implementation-specific features like sun.reflect.ReflectionFactory#newConstructorForSerialization on the Sun Java 1.4.x/5 VM (not available on other VMs) and FormatterServices.GetUninitializedObject() on the .NET framework (not available on CompactFramework). This setting may also be overridden for individual classes in ObjectClass.callConstructor(boolean) .

The default setting depends on the features supported by your current environment.

In client/server environment this setting should be used on both client and server.


Parameters:
  flag - - specify true, to request calling constructors, specifyfalse to request not calling constructors.
See Also:   ObjectClass.callConstructor



callbacks
public void callbacks(boolean flag)(Code)
turns callback methods on and off.

Callbacks are turned on by default.

A tuning hint: If callbacks are not used, you can turn this feature off, to prevent db4o from looking for callback methods in persistent classes. This will increase the performance on system startup.

In client/server environment this setting should be used on both client and server.
Parameters:
  flag - false to turn callback methods off
See Also:   com.db4o.ext.ObjectCallbacks
See Also:    Using callbacks



classActivationDepthConfigurable
public void classActivationDepthConfigurable(boolean flag)(Code)
turns ObjectClass.maximumActivationDepth individual class activation depth configuration on and off.

This feature is turned on by default.

In client/server environment this setting should be used on both client and server.


Parameters:
  flag - false to turn the possibility to individually configure classactivation depths off
See Also:   Configuration.activationDepth
See Also:    Why activation?



clientServer
public ClientServerConfiguration clientServer()(Code)
returns client/server configuration interface.



detectSchemaChanges
public void detectSchemaChanges(boolean flag)(Code)
tuning feature: configures whether db4o checks all persistent classes upon system startup, for added or removed fields.

In a production environment this setting can be set to false, if all necessary classes have been stored to the database file and none of them have been modified since the last use.

In client/server environment this setting should be used on both client and server.

Default value:
true
Parameters:
  flag - the desired setting



diagnostic
public DiagnosticConfiguration diagnostic()(Code)
returns the configuration interface for diagnostics. the configuration interface for diagnostics.



disableCommitRecovery
public void disableCommitRecovery()(Code)
turns commit recovery off.

db4o uses a two-phase commit algorithm. In a first step all intended changes are written to a free place in the database file, the "transaction commit record". In a second step the actual changes are performed. If the system breaks down during commit, the commit process is restarted when the database file is opened the next time. On very rare occasions (possibilities: hardware failure or editing the database file with an external tool) the transaction commit record may be broken. In this case, this method can be used to try to open the database file without commit recovery. The method should only be used in emergency situations after consulting db4o support.



discardFreeSpace
public void discardFreeSpace(int byteCount)(Code)
tuning feature: configures the minimum size of free space slots in the database file that are to be reused.

When objects are updated or deleted, the space previously occupied in the database file is marked as "free", so it can be reused. db4o maintains two lists in RAM, sorted by address and by size. Adjacent entries are merged. After a large number of updates or deletes have been executed, the lists can become large, causing RAM consumption and performance loss for maintenance. With this method you can specify an upper bound for the byte slot size to discard.

Pass Integer.MAX_VALUE to this method to discard all free slots for the best possible startup time.

The downside of setting this value: Database files will necessarily grow faster.

Default value:
0 all space is reused
Parameters:
  byteCount - Slots with this size or smaller will be lost.



encrypt
public void encrypt(boolean flag) throws GlobalOnlyConfigException(Code)
configures the use of encryption.

This method needs to be called before a database file is created with the first com.db4o.Db4o.openFile(java.lang.String) .

If encryption is set to true, you need to supply a password to seed the encryption mechanism.

db4o database files keep their encryption format after creation.

IoAdapter
Parameters:
  flag - true for turning encryption on, false for turning encryption off.
See Also:   Configuration.password



exceptionsOnNotStorable
public void exceptionsOnNotStorable(boolean flag)(Code)
configures whether Exceptions are to be thrown, if objects can not be stored.

db4o requires the presence of a constructor that can be used to instantiate objects. If no default public constructor is present, all available constructors are tested, whether an instance of the class can be instantiated. Null is passed to all constructor parameters. The first constructor that is successfully tested will be used throughout the running db4o session. If an instance of the class can not be instantiated, the object will not be stored. By default, execution will continue without any message or error. This method can be used to configure db4o to throw an com.db4o.ext.ObjectNotStorableException ObjectNotStorableException if an object can not be stored.

The default for this setting is false.

In client/server environment this setting should be used on both client and server.


Parameters:
  flag - true to throw Exceptions if objects can not be stored.



flushFileBuffers
public void flushFileBuffers(boolean flag)(Code)
configures file buffers to be flushed during transaction commits.

db4o uses a resume-commit-on-crash strategy to ensure ACID transactions. When a transaction commits,
- (1) a list "pointers that are to be modified" is written to the database file,
- (2) the database file is switched into "in-commit" mode,
- (3) the pointers are actually modified in the database file,
- (4) the database file is switched to "not-in-commit" mode.
If the system is halted by a hardware or power failure
- before (2)
all objects will be available as before the commit
- between (2) and (4) the commit is restarted when the database file is opened the next time, all pointers will be read from the "pointers to be modified" list and all of them will be modified to the state they are intended to have after commit
- after (4) no work is necessary, the transaction is committed.

In order for the above to be 100% failsafe, the order of writes to the storage medium has to be obeyed. On operating systems that use in-memory file caching, the OS cache may revert the order of writes to optimize file performance.

db4o enforces the correct write order by flushing file buffers after every single one of the above steps during transaction commit. Flush calls have a strong impact on performance. It is possible to tune an application by turning flushing off, at the risc of less security for hardware-, power- or operating system failures.

In client/server environment this setting should be used on both client and server.


Parameters:
  flag - true for flushing file buffers



freespace
public FreespaceConfiguration freespace()(Code)
returns the freespace configuration interface.



generateUUIDs
public void generateUUIDs(int setting)(Code)
configures db4o to generate UUIDs for stored objects.
Parameters:
  setting - one of the following values:
-1 - off
1 - configure classes individually
Integer.MAX_Value - on for all classes

This setting should be used when the database is first created.Configuration.generateUUIDs(ConfigScope)



generateUUIDs
public void generateUUIDs(ConfigScope setting)(Code)
configures db4o to generate UUIDs for stored objects. This setting should be used when the database is first created.


Parameters:
  setting - the scope for UUID generation: disabled, generate for all classes, or configure individually



generateVersionNumbers
public void generateVersionNumbers(int setting)(Code)
configures db4o to generate version numbers for stored objects.
Parameters:
  setting - one of the following values:
-1 - off
1 - configure classes individually
Integer.MAX_Value - on for all classes

This setting should be used when the database is first created.Configuration.generateVersionNumbers(ConfigScope)



generateVersionNumbers
public void generateVersionNumbers(ConfigScope setting)(Code)
configures db4o to generate version numbers for stored objects. This setting should be used when the database is first created.
Parameters:
  setting - the scope for version number generation: disabled, generate for all classes, or configure individually



internStrings
public void internStrings(boolean flag)(Code)
configures db4o to call #intern() on strings upon retrieval. In client/server environment the setting should be used on both client and server.
Parameters:
  flag - true to intern strings



internStrings
public boolean internStrings()(Code)
returns true if strings will be interned.



io
public void io(IoAdapter adapter) throws GlobalOnlyConfigException(Code)
allows to configure db4o to use a customized byte IO adapter.

Derive from the abstract class 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.

An example of a custom io adapter can be found in xtea_db4o community project:
http://developer.db4o.com/ProjectSpaces/view.aspx/XTEA

In client-server environment this setting should be used on the server (adapter class must be available)


Parameters:
  adapter - - the IoAdapter



lockDatabaseFile
public void lockDatabaseFile(boolean flag)(Code)
can be used to turn the database file locking thread off.

Since Java does not support file locking up to JDK 1.4, db4o uses an additional thread per open database file to prohibit concurrent access to the same database file by different db4o sessions in different VMs.

To improve performance and to lower ressource consumption, this method provides the possibility to prevent the locking thread from being started.

Caution!
If database file locking is turned off, concurrent write access to the same database file from different JVM sessions will corrupt the database file immediately.

This method has no effect on open ObjectContainers. It will only affect how ObjectContainers are opened.

The default setting is true.

In client-server environment this setting should be used on both client and server.


Parameters:
  flag - false to turn database file locking off.



markTransient
public void markTransient(String attributeName)(Code)
allows to mark fields as transient with custom attributes.

.NET only: Call this method with the attribute name that you wish to use to mark fields as transient. Multiple transient attributes are possible by calling this method multiple times with different attribute names.

In client/server environment the setting should be used on both client and server.


Parameters:
  attributeName - - the fully qualified name of the attribute, includingit's namespace



messageLevel
public void messageLevel(int level)(Code)
sets the detail level of db4o messages. Messages will be output to the configured output java.io.PrintStream PrintStream .

Level 0 - no messages
Level 1 - open and close messages
Level 2 - messages for new, update and delete
Level 3 - messages for activate and deactivate

When using client-server and the level is set to 0, the server will override this and set it to 1. To get around this you can set the level to -1. This has the effect of not returning any messages.

In client-server environment this setting can be used on client or on server depending on which information do you want to track (server side provides more detailed information).


Parameters:
  level - integer from 0 to 3
See Also:   Configuration.setOut



objectClass
public ObjectClass objectClass(Object clazz)(Code)
returns an ObjectClass ObjectClass object to configure the specified class.

The clazz parameter can be any of the following:
- a fully qualified classname as a String.
- a Class object.
- any other object to be used as a template.


Parameters:
  clazz - class name, Class object, or example object.

an instance of an ObjectClass ObjectClassobject for configuration.



optimizeNativeQueries
public void optimizeNativeQueries(boolean optimizeNQ)(Code)
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. On the Java platform the jars needed for native query optimization (db4o-X.x-nqopt.jar, bloat-X.x.jar) have to be on the classpath at runtime for this switch to have effect.

The default setting is true.

In client-server environment this setting should be used on both client and server.


Parameters:
  optimizeNQ - true, if db4o should try to optimizenative queries at query execution time, false otherwise



optimizeNativeQueries
public boolean optimizeNativeQueries()(Code)
indicates whether Native Queries will be optimized dynamically. boolean true if Native Queries will be optimizeddynamically.
See Also:   Configuration.optimizeNativeQueries



password
public void password(String pass) throws GlobalOnlyConfigException(Code)
protects the database file with a password.

To set a password for a database file, this method needs to be called before a database file is created with the first com.db4o.Db4o.openFile .

All further attempts to open the file, are required to set the same password.

The password is used to seed the encryption mechanism, which makes it impossible to read the database file without knowing the password.

IoAdapter
Parameters:
  pass - the password to be used.



queries
public QueryConfiguration queries()(Code)
returns the Query configuration interface.



readOnly
public void readOnly(boolean flag)(Code)
turns readOnly mode on and off.

This method configures the mode in which subsequent calls to com.db4o.Db4o.openFile Db4o.openFile() will open files.

Readonly mode allows to open an unlimited number of reading processes on one database file. It is also convenient for deploying db4o database files on CD-ROM.

In client-server environment this setting should be used on the server side in embedded mode and ONLY on client side in networked mode.


Parameters:
  flag - true for configuring readOnly mode for subsequentcalls to com.db4o.Db4o.openFile Db4o.openFile().



reflectWith
public void reflectWith(Reflector reflector)(Code)
configures the use of a specially designed reflection implementation.

db4o internally uses java.lang.reflect.* by default. On platforms that do not support this package, customized implementations may be written to supply all the functionality of the interfaces in the com.db4o.reflect package. This method can be used to install a custom reflection implementation.

In client-server environment this setting should be used on the server side (reflector class must be available)




refreshClasses
public void refreshClasses()(Code)
forces analysis of all Classes during a running session.

This method may be useful in combination with a modified ClassLoader and allows exchanging classes during a running db4o session.

Calling this method on the global Configuration context will refresh the classes in all db4o sessions in the running VM. Calling this method in an ObjectContainer Configuration context, only the classes of the respective ObjectContainer will be refreshed.


See Also:   Configuration.setClassLoader



removeAlias
public void removeAlias(Alias alias)(Code)
Removes an alias previously added with Configuration.addAlias(Alias) .
Parameters:
  alias - the alias to remove



reserveStorageSpace
public void reserveStorageSpace(long byteCount) throws DatabaseReadOnlyException, NotSupportedException(Code)
tuning feature only: reserves a number of bytes in database files.

The global setting is used for the creation of new database files. Continous calls on an ObjectContainer Configuration context (see com.db4o.ext.ExtObjectContainer.configure ) will continually allocate space.

The allocation of a fixed number of bytes at one time makes it more likely that the database will be stored in one chunk on the mass storage. Less read/write head movevement can result in improved performance.

Note:
Allocated space will be lost on abnormal termination of the database engine (hardware crash, VM crash). A Defragment run will recover the lost space. For the best possible performance, this method should be called before the Defragment run to configure the allocation of storage space to be slightly greater than the anticipated database file size.

In client-server environment this setting should be used on the server side.

Default configuration: 0


Parameters:
  byteCount - the number of bytes to reserve



setBlobPath
public void setBlobPath(String path) throws IOException(Code)
configures the path to be used to store and read Blob data.

In client-server environment this setting should be used on the server side.


Parameters:
  path - the path to be used



setClassLoader
public void setClassLoader(Object classLoader)(Code)
configures db4o to use a custom ClassLoader.


Parameters:
  classLoader - the ClassLoader to be used



setOut
public void setOut(PrintStream outStream)(Code)
Assigns a java.io.PrintStream PrintStream where db4o is to print its event messages.

Messages are useful for debugging purposes and for learning to understand, how db4o works. The message level can be raised with Configuration.messageLevel(int) to produce more detailed messages.

Use setOut(System.out) to print messages to the console.

In client-server environment this setting should be used on the same side where Configuration.messageLevel(int) is used.


Parameters:
  outStream - the new PrintStream for messages.
See Also:   Configuration.messageLevel



testConstructors
public void testConstructors(boolean flag)(Code)
tuning feature: configures whether db4o should try to instantiate one instance of each persistent class on system startup.

In a production environment this setting can be set to false, if all persistent classes have public default constructors.

In client-server environment this setting should be used on both client and server side.

Default value:
true
Parameters:
  flag - the desired setting



unicode
public void unicode(boolean flag)(Code)
configures the storage format of Strings.

This method needs to be called before a database file is created with the first com.db4o.Db4o.openFile or com.db4o.Db4o.openServer . db4o database files keep their string format after creation.

Turning Unicode support off reduces the file storage space for strings by factor 2 and improves performance.

Default setting: true


Parameters:
  flag - true for turning Unicode support on, false for turningUnicode support off.



updateDepth
public void updateDepth(int depth)(Code)
specifies the global updateDepth.

see the documentation of com.db4o.ObjectContainer.set for further details.

The value be may be overridden for individual classes.

The default setting is 1: Only the object passed to com.db4o.ObjectContainer.set will be updated.

In client-server environment this setting should be used on both client and server sides.


Parameters:
  depth - the depth of the desired update.
See Also:   ObjectClass.updateDepth
See Also:   ObjectClass.cascadeOnUpdate
See Also:   com.db4o.ext.ObjectCallbacks
See Also:    Using callbacks



weakReferenceCollectionInterval
public void weakReferenceCollectionInterval(int milliseconds)(Code)
configures the timer for WeakReference collection.

The default setting is 1000 milliseconds.

Configure this setting to zero to turn WeakReference collection off.

Ignored on JDKs before 1.2.


Parameters:
  milliseconds - the time in milliseconds



weakReferences
public void weakReferences(boolean flag)(Code)
turns weak reference management on or off.

This method must be called before opening a database.

Performance may be improved by running db4o without using weak references durring memory management at the cost of higher memory consumption or by alternatively implementing a manual memory management scheme using com.db4o.ext.ExtObjectContainer.purge(java.lang.Object)

Setting the value to false causes db4o to use hard references to objects, preventing the garbage collection process from disposing of unused objects.

The default setting is true.

Ignored on JDKs before 1.2.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.